diff --git a/changedetectionio/run_socks_proxy_tests.sh b/changedetectionio/run_socks_proxy_tests.sh index 2040d552..6db4bb41 100755 --- a/changedetectionio/run_socks_proxy_tests.sh +++ b/changedetectionio/run_socks_proxy_tests.sh @@ -16,25 +16,31 @@ echo "---------------------------------- SOCKS5 -------------------" docker run --network changedet-network \ -v `pwd`/tests/proxy_socks5/proxies.json-example:/app/changedetectionio/test-datastore/proxies.json \ --rm \ + -e "FLASK_SERVER_NAME=cdio" \ + --hostname cdio \ -e "SOCKSTEST=proxiesjson" \ test-changedetectionio \ - bash -c 'cd changedetectionio && pytest tests/proxy_socks5/test_socks5_proxy_sources.py' + bash -c 'cd changedetectionio && pytest --live-server-host=0.0.0.0 --live-server-port=5004 -s tests/proxy_socks5/test_socks5_proxy_sources.py' # SOCKS5 related - by manually entering in UI docker run --network changedet-network \ --rm \ + -e "FLASK_SERVER_NAME=cdio" \ + --hostname cdio \ -e "SOCKSTEST=manual" \ test-changedetectionio \ - bash -c 'cd changedetectionio && pytest tests/proxy_socks5/test_socks5_proxy.py' + bash -c 'cd changedetectionio && pytest --live-server-host=0.0.0.0 --live-server-port=5004 -s tests/proxy_socks5/test_socks5_proxy.py' # SOCKS5 related - test from proxies.json via playwright - NOTE- PLAYWRIGHT DOESNT SUPPORT AUTHENTICATING PROXY docker run --network changedet-network \ -e "SOCKSTEST=manual-playwright" \ + --hostname cdio \ + -e "FLASK_SERVER_NAME=cdio" \ -v `pwd`/tests/proxy_socks5/proxies.json-example-noauth:/app/changedetectionio/test-datastore/proxies.json \ -e "PLAYWRIGHT_DRIVER_URL=ws://sockpuppetbrowser:3000" \ --rm \ test-changedetectionio \ - bash -c 'cd changedetectionio && pytest tests/proxy_socks5/test_socks5_proxy_sources.py' + bash -c 'cd changedetectionio && pytest --live-server-host=0.0.0.0 --live-server-port=5004 -s tests/proxy_socks5/test_socks5_proxy_sources.py' echo "socks5 server logs" docker logs socks5proxy diff --git a/changedetectionio/tests/proxy_socks5/test_socks5_proxy.py b/changedetectionio/tests/proxy_socks5/test_socks5_proxy.py index f9ce166d..01152050 100644 --- a/changedetectionio/tests/proxy_socks5/test_socks5_proxy.py +++ b/changedetectionio/tests/proxy_socks5/test_socks5_proxy.py @@ -1,12 +1,27 @@ #!/usr/bin/env python3 import os -import time from flask import url_for from changedetectionio.tests.util import live_server_setup, wait_for_all_checks +def set_response(): + import time + data = f""" + +

Awesome, you made it

+ yeah the socks request worked + + + """ + + with open("test-datastore/endpoint-content.txt", "w") as f: + f.write(data) + time.sleep(1) + + def test_socks5(client, live_server, measure_memory_usage): live_server_setup(live_server) + set_response() # Setup a proxy res = client.post( @@ -24,7 +39,10 @@ def test_socks5(client, live_server, measure_memory_usage): assert b"Settings updated." in res.data - test_url = "https://changedetection.io/CHANGELOG.txt?socks-test-tag=" + os.getenv('SOCKSTEST', '') + # Because the socks server should connect back to us + test_url = url_for('test_endpoint', _external=True) + f"?socks-test-tag={os.getenv('SOCKSTEST', '')}" + test_url = test_url.replace('localhost.localdomain', 'cdio') + test_url = test_url.replace('localhost', 'cdio') res = client.post( url_for("form_quick_watch_add"), @@ -60,4 +78,4 @@ def test_socks5(client, live_server, measure_memory_usage): ) # Should see the proper string - assert "+0200:".encode('utf-8') in res.data + assert "Awesome, you made it".encode('utf-8') in res.data diff --git a/changedetectionio/tests/proxy_socks5/test_socks5_proxy_sources.py b/changedetectionio/tests/proxy_socks5/test_socks5_proxy_sources.py index 0da50acc..a5d3b69f 100644 --- a/changedetectionio/tests/proxy_socks5/test_socks5_proxy_sources.py +++ b/changedetectionio/tests/proxy_socks5/test_socks5_proxy_sources.py @@ -1,16 +1,32 @@ #!/usr/bin/env python3 import os -import time from flask import url_for from changedetectionio.tests.util import live_server_setup, wait_for_all_checks +def set_response(): + import time + data = f""" + +

Awesome, you made it

+ yeah the socks request worked + + + """ + + with open("test-datastore/endpoint-content.txt", "w") as f: + f.write(data) + time.sleep(1) + # should be proxies.json mounted from run_proxy_tests.sh already # -v `pwd`/tests/proxy_socks5/proxies.json-example:/app/changedetectionio/test-datastore/proxies.json def test_socks5_from_proxiesjson_file(client, live_server, measure_memory_usage): live_server_setup(live_server) - - test_url = "https://changedetection.io/CHANGELOG.txt?socks-test-tag=" + os.getenv('SOCKSTEST', '') + set_response() + # Because the socks server should connect back to us + test_url = url_for('test_endpoint', _external=True) + f"?socks-test-tag={os.getenv('SOCKSTEST', '')}" + test_url = test_url.replace('localhost.localdomain', 'cdio') + test_url = test_url.replace('localhost', 'cdio') res = client.get(url_for("settings_page")) assert b'name="requests-proxy" type="radio" value="socks5proxy"' in res.data @@ -49,4 +65,4 @@ def test_socks5_from_proxiesjson_file(client, live_server, measure_memory_usage) ) # Should see the proper string - assert "+0200:".encode('utf-8') in res.data + assert "Awesome, you made it".encode('utf-8') in res.data