Don't include _memory on /-/create-token, refs #1947

pull/1961/head
Simon Willison 2022-12-13 21:19:31 -08:00
rodzic 420d0a0ee2
commit 1a3dcf4943
2 zmienionych plików z 13 dodań i 1 usunięć

Wyświetl plik

@ -235,7 +235,7 @@ class CreateTokenView(BaseView):
# Build list of databases and tables the user has permission to view
database_with_tables = []
for database in self.ds.databases.values():
if database.name == "_internal":
if database.name in ("_internal", "_memory"):
continue
if not await self.ds.permission_allowed(
request.actor, "view-database", database.name

Wyświetl plik

@ -1,3 +1,4 @@
from bs4 import BeautifulSoup as Soup
from .fixtures import app_client
from click.testing import CliRunner
from datasette.utils import baseconv
@ -160,6 +161,17 @@ def test_auth_create_token(
response = app_client.get("/-/create-token", cookies={"ds_actor": ds_actor})
assert response.status == 200
assert ">Create an API token<" in response.text
# Confirm some aspects of expected set of checkboxes
soup = Soup(response.text, "html.parser")
checkbox_names = {el["name"] for el in soup.select('input[type="checkbox"]')}
assert checkbox_names.issuperset(
{
"all:view-instance",
"all:view-query",
"database:fixtures:drop-table",
"resource:fixtures:foreign_key_references:insert-row",
}
)
# Now try actually creating one
response2 = app_client.post(
"/-/create-token",