mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Cascade for restricted token view-table/view-database/view-instance operations (#2154)
Closes #2102 * Permission is now a dataclass, not a namedtuple - refs https://github.com/simonw/datasette/pull/2154/#discussion_r1308087800 * datasette.get_permission() method
This commit is contained in:
parent
a1f3d75a52
commit
50da908213
8 changed files with 427 additions and 50 deletions
|
|
@ -159,3 +159,17 @@ def test_datasette_error_if_string_not_list(tmpdir):
|
|||
db_path = str(tmpdir / "data.db")
|
||||
with pytest.raises(ValueError):
|
||||
ds = Datasette(db_path)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_permission(ds_client):
|
||||
ds = ds_client.ds
|
||||
for name_or_abbr in ("vi", "view-instance", "vt", "view-table"):
|
||||
permission = ds.get_permission(name_or_abbr)
|
||||
if "-" in name_or_abbr:
|
||||
assert permission.name == name_or_abbr
|
||||
else:
|
||||
assert permission.abbr == name_or_abbr
|
||||
# And test KeyError
|
||||
with pytest.raises(KeyError):
|
||||
ds.get_permission("missing-permission")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue