kopia lustrzana https://github.com/simonw/datasette
Show padlock on private index page, refs #811
rodzic
cc218fa9be
commit
1cf86e5ecc
|
@ -5,7 +5,7 @@
|
|||
{% block body_class %}index{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1>{{ metadata.title or "Datasette" }}</h1>
|
||||
<h1>{{ metadata.title or "Datasette" }}{% if private %} 🔒{% endif %}</h1>
|
||||
|
||||
{% block description_source_license %}{% include "_description_source_license.html" %}{% endblock %}
|
||||
|
||||
|
|
|
@ -121,5 +121,8 @@ class IndexView(BaseView):
|
|||
"databases": databases,
|
||||
"metadata": self.ds.metadata(),
|
||||
"datasette_version": __version__,
|
||||
"private": not await self.ds.permission_allowed(
|
||||
None, "view-instance"
|
||||
),
|
||||
},
|
||||
)
|
||||
|
|
|
@ -16,10 +16,16 @@ def test_view_instance(allow, expected_anon, expected_auth):
|
|||
):
|
||||
anon_response = client.get(path)
|
||||
assert expected_anon == anon_response.status
|
||||
if allow and path == "/" and anon_response.status == 200:
|
||||
# Should be no padlock
|
||||
assert "<h1>Datasette 🔒</h1>" not in anon_response.text
|
||||
auth_response = client.get(
|
||||
path, cookies={"ds_actor": client.ds.sign({"id": "root"}, "actor")},
|
||||
)
|
||||
assert expected_auth == auth_response.status
|
||||
# Check for the padlock
|
||||
if allow and path == "/" and expected_anon == 403 and expected_auth == 200:
|
||||
assert "<h1>Datasette 🔒</h1>" in auth_response.text
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
|
Ładowanie…
Reference in New Issue