mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Implemented view-instance permission, refs #811
This commit is contained in:
parent
ece0ba6f4b
commit
8571ce388a
2 changed files with 24 additions and 0 deletions
|
|
@ -20,3 +20,23 @@ def test_execute_sql(allow, expected_anon, expected_auth):
|
|||
"/fixtures/q", cookies={"ds_actor": client.ds.sign({"id": "root"}, "actor")}
|
||||
)
|
||||
assert expected_auth == auth_response.status
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"allow,expected_anon,expected_auth",
|
||||
[(None, 200, 200), ({}, 403, 403), ({"id": "root"}, 403, 200),],
|
||||
)
|
||||
def test_view_instance(allow, expected_anon, expected_auth):
|
||||
with make_app_client(metadata={"allow": allow}) as client:
|
||||
for path in (
|
||||
"/",
|
||||
"/fixtures",
|
||||
"/fixtures/compound_three_primary_keys",
|
||||
"/fixtures/compound_three_primary_keys/a,a,a",
|
||||
):
|
||||
anon_response = client.get(path)
|
||||
assert expected_anon == anon_response.status
|
||||
auth_response = client.get(
|
||||
path, cookies={"ds_actor": client.ds.sign({"id": "root"}, "actor")},
|
||||
)
|
||||
assert expected_auth == auth_response.status
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue