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