Re #203 - validate tokens (#204)

* Re #203 - validate tokens
This commit is contained in:
dgtlmoon
2021-08-22 18:45:32 +02:00
committed by GitHub
parent 4683b0d120
commit fbe9270528
3 changed files with 58 additions and 7 deletions

View File

@@ -98,10 +98,15 @@ def test_check_notification(client, live_server):
res = client.post(
url_for("settings_page"),
data={"notification_title": "New ChangeDetection.io Notification - {watch_url}",
"notification_body": "{base_url}\n{watch_url}\n{preview_url}\n{diff_url}\n{current_snapshot}\n:-)",
"notification_body": "BASE URL: {base_url}\n"
"Watch URL: {watch_url}\n"
"Preview: {preview_url}\n"
"Diff URL: {diff_url}\n"
"Snapshot: {current_snapshot}\n"
":-)",
"notification_urls": "json://foobar.com", #Re #143 should not see that it sent without [test checkbox]
"minutes_between_check": 180,
"fetch_backend": "html_requests",
"fetch_backend": "html_requests"
},
follow_redirects=True
)
@@ -145,3 +150,18 @@ def test_check_notification(client, live_server):
client.get(url_for("api_watch_checknow"), follow_redirects=True)
time.sleep(3)
assert os.path.exists("test-datastore/notification.txt") == False
# Now adding a wrong token should give us an error
res = client.post(
url_for("settings_page"),
data={"notification_title": "New ChangeDetection.io Notification - {watch_url}",
"notification_body": "Rubbish: {rubbish}\n",
"notification_urls": "json://foobar.com",
"minutes_between_check": 180,
"fetch_backend": "html_requests"
},
follow_redirects=True
)
assert bytes("is not a valid token".encode('utf-8')) in res.data