mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Logout link in nav, refs #875
This commit is contained in:
parent
51427323e6
commit
2115d7e345
7 changed files with 73 additions and 2 deletions
|
|
@ -78,3 +78,17 @@ def test_logout(app_client):
|
|||
# Should also have set a message
|
||||
messages = app_client.ds.unsign(response4.cookies["ds_messages"], "messages")
|
||||
assert [["You are now logged out", 2]] == messages
|
||||
|
||||
|
||||
@pytest.mark.parametrize("path", ["/", "/fixtures", "/fixtures/facetable"])
|
||||
def test_logout_button_in_navigation(app_client, path):
|
||||
response = app_client.get(
|
||||
path, cookies={"ds_actor": app_client.actor_cookie({"id": "test"})}
|
||||
)
|
||||
anon_response = app_client.get(path)
|
||||
for fragment in (
|
||||
"<strong>test</strong> ·",
|
||||
'<form action="/-/logout" method="post">',
|
||||
):
|
||||
assert fragment in response.text
|
||||
assert fragment not in anon_response.text
|
||||
|
|
|
|||
|
|
@ -517,3 +517,22 @@ def test_actor_matches_allow(actor, allow, expected):
|
|||
)
|
||||
def test_resolve_env_secrets(config, expected):
|
||||
assert expected == utils.resolve_env_secrets(config, {"FOO": "x"})
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"actor,expected",
|
||||
[
|
||||
({"id": "blah"}, "blah"),
|
||||
({"id": "blah", "login": "l"}, "l"),
|
||||
({"id": "blah", "login": "l"}, "l"),
|
||||
({"id": "blah", "login": "l", "username": "u"}, "u"),
|
||||
({"login": "l", "name": "n"}, "n"),
|
||||
(
|
||||
{"id": "blah", "login": "l", "username": "u", "name": "n", "display": "d"},
|
||||
"d",
|
||||
),
|
||||
({"weird": "shape"}, "{'weird': 'shape'}"),
|
||||
],
|
||||
)
|
||||
def test_display_actor(actor, expected):
|
||||
assert expected == utils.display_actor(actor)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue