kopia lustrzana https://github.com/dgtlmoon/changedetection.io
Re #44 - Broke the menu by accident, adding tests and fixing.
rodzic
4953e253e9
commit
4164ad29e3
|
@ -92,6 +92,7 @@ class User(flask_login.UserMixin):
|
|||
def get_user(self, email="defaultuser@changedetection.io"):
|
||||
return self
|
||||
def is_authenticated(self):
|
||||
|
||||
return True
|
||||
def is_active(self):
|
||||
return True
|
||||
|
|
|
@ -110,7 +110,7 @@ class ChangeDetectionStore:
|
|||
self.add_watch(url='https://changedetection.io', tag='Tech news')
|
||||
|
||||
|
||||
self.__data['version_tag'] = "0.29"
|
||||
self.__data['version_tag'] = "0.291"
|
||||
|
||||
if not 'app_guid' in self.__data:
|
||||
self.__data['app_guid'] = str(uuid_builder.uuid4())
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
<div class="header">
|
||||
<div class="home-menu pure-menu pure-menu-horizontal pure-menu-fixed">
|
||||
{% if not current_user.is_authenticated %}
|
||||
{% if has_password and not current_user.is_authenticated %}
|
||||
<a class="pure-menu-heading" href="https://github.com/dgtlmoon/changedetection.io" rel="noopener"><strong>Change</strong>Detection.io</a>
|
||||
{% else %}
|
||||
<a class="pure-menu-heading" href="/"><strong>Change</strong>Detection.io</a>
|
||||
|
@ -31,7 +31,7 @@
|
|||
{% endif %}
|
||||
|
||||
<ul class="pure-menu-list">
|
||||
{% if current_user.is_authenticated %}
|
||||
{% if current_user.is_authenticated or not has_password %}
|
||||
<li class="pure-menu-item">
|
||||
<a href="/backup" class="pure-menu-link">BACKUP</a>
|
||||
</li>
|
||||
|
@ -47,9 +47,9 @@
|
|||
</li>
|
||||
{% endif %}
|
||||
|
||||
{% if current_user.is_authenticated %}
|
||||
<li class="pure-menu-item"><a href="/logout" class="pure-menu-link">LOG OUT</a></li>
|
||||
{% endif %}
|
||||
{% if current_user.is_authenticated %}
|
||||
<li class="pure-menu-item"><a href="/logout" class="pure-menu-link">LOG OUT</a></li>
|
||||
{% endif %}
|
||||
<li class="pure-menu-item"><a class="github-link" href="https://github.com/dgtlmoon/changedetection.io">
|
||||
<svg class="octicon octicon-mark-github v-align-middle" height="32" viewBox="0 0 16 16"
|
||||
version="1.1"
|
||||
|
|
|
@ -75,6 +75,12 @@ def test_check_basic_change_detection_functionality(client, live_server):
|
|||
assert b'unviewed' not in res.data
|
||||
assert b'test-endpoint' in res.data
|
||||
|
||||
# Default no password set, this stuff should be always available.
|
||||
|
||||
assert b"SETTINGS" in res.data
|
||||
assert b"BACKUP" in res.data
|
||||
assert b"IMPORT" in res.data
|
||||
|
||||
#####################
|
||||
|
||||
# Make a change
|
||||
|
@ -139,6 +145,13 @@ def test_check_access_control(client):
|
|||
client.get(url_for("import_page"), follow_redirects=True)
|
||||
assert b"Password" in res.data
|
||||
|
||||
# Menu should not be available yet
|
||||
assert b"SETTINGS" not in res.data
|
||||
assert b"BACKUP" not in res.data
|
||||
assert b"IMPORT" not in res.data
|
||||
|
||||
|
||||
|
||||
#defaultuser@changedetection.io is actually hardcoded for now, we only use a single password
|
||||
res = client.post(
|
||||
url_for("login"),
|
||||
|
@ -149,6 +162,12 @@ def test_check_access_control(client):
|
|||
assert b"LOG OUT" in res.data
|
||||
|
||||
client.get(url_for("settings_page"), follow_redirects=True)
|
||||
# Menu should be available now
|
||||
assert b"SETTINGS" in res.data
|
||||
assert b"BACKUP" in res.data
|
||||
assert b"IMPORT" in res.data
|
||||
|
||||
|
||||
assert b"LOG OUT" in res.data
|
||||
|
||||
# Now remove the password so other tests function, @todo this should happen before each test automatically
|
||||
|
|
|
@ -70,11 +70,10 @@ def main(argv):
|
|||
|
||||
@app.context_processor
|
||||
def inject_version():
|
||||
return dict(version=datastore.data['version_tag'])
|
||||
|
||||
@app.context_processor
|
||||
def inject_new_version_available():
|
||||
return dict(new_version_available=app.config['NEW_VERSION_AVAILABLE'])
|
||||
return dict(version=datastore.data['version_tag'],
|
||||
new_version_available=app.config['NEW_VERSION_AVAILABLE'],
|
||||
has_password=datastore.data['settings']['application']['password'] != False
|
||||
)
|
||||
|
||||
if ssl_mode:
|
||||
# @todo finalise SSL config, but this should get you in the right direction if you need it.
|
||||
|
|
Ładowanie…
Reference in New Issue