Compare commits

..

11 Commits

Author SHA1 Message Date
dgtlmoon
23c73cafa0 remove check 2023-01-29 21:07:42 +01:00
dgtlmoon
b957dc9153 rss token now always required 2023-01-29 20:35:59 +01:00
dgtlmoon
7b54a5e533 remove dupe code 2023-01-29 20:14:03 +01:00
dgtlmoon
ebd9c1cbc3 Simplify 2023-01-29 20:12:00 +01:00
dgtlmoon
8e9fe9c288 tidying up rss token test 2023-01-29 20:07:16 +01:00
dgtlmoon
9f1577331c Fix for RSS perms 2023-01-29 19:41:26 +01:00
dgtlmoon
952ba38b46 Refactor user session handling 2023-01-29 19:35:02 +01:00
dgtlmoon
8f5cb68319 Adding test 2023-01-29 15:37:42 +01:00
dgtlmoon
02682b288f Merge branch 'master' into share-diff 2023-01-29 15:05:57 +01:00
dgtlmoon
782ed32b05 WIP 2023-01-28 23:27:44 +01:00
dgtlmoon
cb0d124a46 WIP 2023-01-28 16:54:00 +01:00
4 changed files with 8 additions and 95 deletions

View File

@@ -36,7 +36,7 @@ from flask import (
from changedetectionio import html_tools
from changedetectionio.api import api_v1
__version__ = '0.40.2'
__version__ = '0.40.1.1'
datastore = None
@@ -53,6 +53,7 @@ app = Flask(__name__,
static_url_path="",
static_folder="static",
template_folder="templates")
from flask_compress import Compress
# Super handy for compressing large BrowserSteps responses and others
FlaskCompress(app)
@@ -891,9 +892,8 @@ def changedetection_app(config=None, datastore_o=None):
system_uses_webdriver = datastore.data['settings']['application']['fetch_backend'] == 'html_webdriver'
is_html_webdriver = False
if (watch.get('fetch_backend') == 'system' and system_uses_webdriver) or watch.get('fetch_backend') == 'html_webdriver':
is_html_webdriver = True
is_html_webdriver = True if watch.get('fetch_backend') == 'html_webdriver' or (
watch.get('fetch_backend', None) is None and system_uses_webdriver) else False
password_enabled_and_share_is_off = False
if datastore.data['settings']['application'].get('password') or os.getenv("SALTED_PASS", False):

View File

@@ -297,8 +297,8 @@ class base_html_playwright(Fetcher):
proxy=self.proxy,
# This is needed to enable JavaScript execution on GitHub and others
bypass_csp=True,
# Should be `allow` or `block` - sites like YouTube can transmit large amounts of data via Service Workers
service_workers=os.getenv('PLAYWRIGHT_SERVICE_WORKERS', 'allow'),
# Can't think why we need the service workers for our use case?
service_workers='block',
# Should never be needed
accept_downloads=False
)
@@ -568,6 +568,7 @@ class html_requests(Fetcher):
if not r.content or not len(r.content):
raise EmptyReply(url=url, status_code=r.status_code)
# @todo test this
# @todo maybe you really want to test zero-byte return pages?
if r.status_code != 200 and not ignore_status_codes:
# maybe check with content works?

View File

@@ -15,78 +15,10 @@ def test_inscriptus():
stripped_text_from_html = get_text(html_content)
assert stripped_text_from_html == 'test!\nok man'
def test_setup(client, live_server):
live_server_setup(live_server)
# Assert that non-200's dont give notifications or register as a change
def test_non_200_doesnt_trigger_change(client, live_server):
# live_server_setup(live_server)
set_original_response()
url = url_for('test_changing_status_code_endpoint', _external=True)
# Add our URL to the import page
res = client.post(
url_for("import_page"),
data={"urls": url},
follow_redirects=True
)
assert b"1 Imported" in res.data
time.sleep(sleep_time_for_fetch_thread)
res = client.post(
url_for("edit_page", uuid="first"),
data={
"include_filters": ".foobar-detection",
"fetch_backend": "html_requests",
"headers": "",
"tag": "",
"url": url
},
follow_redirects=True
)
# A recheck will happen here automatically
time.sleep(sleep_time_for_fetch_thread)
# hit the mark all viewed link
res = client.get(url_for("mark_all_viewed"), follow_redirects=True)
# Now be sure the filter is missing and then recheck it
set_modified_response()
# https://github.com/dgtlmoon/changedetection.io/issues/962#issuecomment-1416807742
for ecode in ['429', '400', '204', '429', '403', '404', '500']:
with open("test-endpoint-status-code.txt", 'w') as f:
f.write(ecode)
res = client.get(url_for("form_watch_checknow"), follow_redirects=True)
assert b'1 watches queued for rechecking.' in res.data
time.sleep(sleep_time_for_fetch_thread)
# No change should be seen/no trigger of change
res = client.get(url_for("index"))
assert b'unviewed' not in res.data
# load preview page so we can see what was returned
res = client.get(url_for("preview_page", uuid="first"))
# with open('/tmp/debug-'+ecode+'.html', 'wb') as f:
# f.write(res.data)
# Should still say the original 200, because "ignore_status_codes" should be off by default
# commented out - this will fail because we also show what the error was
# assert b'code: '+ecode.encode('utf-8') not in res.data
assert b'code: 200' in res.data
# Cleanup everything
res = client.get(url_for("form_delete", uuid="all"), follow_redirects=True)
assert b'Deleted' in res.data
def test_check_basic_change_detection_functionality(client, live_server):
set_original_response()
live_server_setup(live_server)
# Add our URL to the import page
res = client.post(

View File

@@ -1,5 +1,4 @@
#!/usr/bin/python3
import os.path
from flask import make_response, request
from flask import url_for
@@ -113,25 +112,6 @@ def live_server_setup(live_server):
import secrets
return "Random content - {}\n".format(secrets.token_hex(64))
@live_server.app.route('/test-changing-status-code-endpoint')
def test_changing_status_code_endpoint():
# status_code can also be overriden in a file, used for doing things that it wouldnt normally expect
# (test_non_200_doesnt_trigger_change)
status_code = '200'
if os.path.isfile("test-endpoint-status-code.txt"):
with open("test-endpoint-status-code.txt", 'r') as f:
status_code = f.read().strip()
os.unlink("test-endpoint-status-code.txt")
# Contents includes the status code, which will change and should not trigger a change
# (Non-200 should get ignored)
with open("test-datastore/endpoint-content.txt", "r") as f:
contents ="{} code: {} ".format(f.read(), status_code)
if status_code == '204':
contents=''
resp = make_response(contents, status_code)
resp.headers['Content-Type'] = 'text/html'
return resp, status_code
@live_server.app.route('/test-endpoint')
def test_endpoint():