mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Test + default impl for view-query permission, refs #811
This commit is contained in:
parent
abc7339124
commit
ece0ba6f4b
2 changed files with 40 additions and 3 deletions
22
tests/test_permissions.py
Normal file
22
tests/test_permissions.py
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
from .fixtures import make_app_client
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"allow,expected_anon,expected_auth",
|
||||
[(None, 200, 200), ({}, 403, 403), ({"id": "root"}, 403, 200),],
|
||||
)
|
||||
def test_execute_sql(allow, expected_anon, expected_auth):
|
||||
with make_app_client(
|
||||
metadata={
|
||||
"databases": {
|
||||
"fixtures": {"queries": {"q": {"sql": "select 1 + 1", "allow": allow}}}
|
||||
}
|
||||
}
|
||||
) as client:
|
||||
anon_response = client.get("/fixtures/q")
|
||||
assert expected_anon == anon_response.status
|
||||
auth_response = client.get(
|
||||
"/fixtures/q", 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