/-/allow-debug tool, closes #908

This commit is contained in:
Simon Willison 2020-07-24 15:54:41 -07:00
commit 12c0bc09cc
5 changed files with 125 additions and 0 deletions

View file

@ -2,6 +2,7 @@ from .fixtures import app_client, assert_permissions_checked, make_app_client
from bs4 import BeautifulSoup as Soup
import copy
import pytest
import urllib
@pytest.mark.parametrize(
@ -312,6 +313,23 @@ def test_permissions_debug(app_client):
] == checks
@pytest.mark.parametrize(
"actor,allow,expected_fragment",
[
('{"id":"root"}', "{}", "Result: deny"),
('{"id":"root"}', '{"id": "*"}', "Result: allow"),
('{"', '{"id": "*"}', "Actor JSON error"),
('{"id":"root"}', '"*"}', "Allow JSON error"),
],
)
def test_allow_debug(app_client, actor, allow, expected_fragment):
response = app_client.get(
"/-/allow-debug?" + urllib.parse.urlencode({"actor": actor, "allow": allow})
)
assert 200 == response.status
assert expected_fragment in response.text
@pytest.mark.parametrize(
"allow,expected",
[({"id": "root"}, 403), ({"id": "root", "unauthenticated": True}, 200),],