From 12343b1c5ae4fce50722e5b7210959bb84954b38 Mon Sep 17 00:00:00 2001 From: Abhinav Singh Date: Fri, 19 Nov 2021 15:43:48 +0530 Subject: [PATCH 1/2] Use `127.0.0.1` as target address and a random port --- tests/integration/test_integration.py | 7 ++++++- tests/integration/test_integration.sh | 21 ++++++++++++++------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/tests/integration/test_integration.py b/tests/integration/test_integration.py index cc07d0eb39..180f349178 100644 --- a/tests/integration/test_integration.py +++ b/tests/integration/test_integration.py @@ -5,9 +5,13 @@ import pytest +from proxy.common.utils import get_available_port from proxy.common._compat import IS_WINDOWS # noqa: WPS436 +PROXY_PY_PORT = get_available_port() + + # FIXME: Ignore is necessary for as long as pytest hasn't figured out # FIXME: typing for their fixtures. # Refs: @@ -22,6 +26,7 @@ def _proxy_py_instance() -> Generator[None, None, None]: proxy_cmd = ( 'proxy', '--hostname', '127.0.0.1', + '--port', str(PROXY_PY_PORT), '--enable-web-server', ) proxy_proc = Popen(proxy_cmd) @@ -49,4 +54,4 @@ def test_curl() -> None: this_test_module = Path(__file__) shell_script_test = this_test_module.with_suffix('.sh') - check_output(str(shell_script_test)) + check_output([str(shell_script_test), str(PROXY_PY_PORT)]) diff --git a/tests/integration/test_integration.sh b/tests/integration/test_integration.sh index 87f37570e2..b31b8452bf 100755 --- a/tests/integration/test_integration.sh +++ b/tests/integration/test_integration.sh @@ -9,9 +9,16 @@ # to clean up any background process including # proxy.py +PROXY_PY_PORT=$1 +if [[ -z "$PROXY_PY_PORT" ]]; then + echo "PROXY_PY_PORT required as argument." + exit 1 +fi + # Wait for server to come up +WAIT_FOR_PROXY="lsof -i TCP:$PROXY_PY_PORT | wc -l | tr -d ' '" while true; do - if [[ $(lsof -i TCP:8899 | wc -l | tr -d ' ') == 0 ]]; then + if [[ $WAIT_FOR_PORT == 0 ]]; then echo "Waiting for proxy..." sleep 1 else @@ -24,8 +31,8 @@ while true; do curl -v \ --max-time 1 \ --connect-timeout 1 \ - -x localhost:8899 \ - http://localhost:8899/ 2>/dev/null + -x 127.0.0.1:$PROXY_PY_PORT \ + http://127.0.0.1:$PROXY_PY_PORT/ 2>/dev/null if [[ $? == 0 ]]; then break fi @@ -41,7 +48,7 @@ done # detect if we have internet access. If we do, # then use httpbin.org for integration testing. curl -v \ - -x localhost:8899 \ + -x 127.0.0.1:$PROXY_PY_PORT \ http://httpbin.org/get if [[ $? != 0 ]]; then echo "http request failed" @@ -49,7 +56,7 @@ if [[ $? != 0 ]]; then fi curl -v \ - -x localhost:8899 \ + -x 127.0.0.1:$PROXY_PY_PORT \ https://httpbin.org/get if [[ $? != 0 ]]; then echo "https request failed" @@ -57,8 +64,8 @@ if [[ $? != 0 ]]; then fi curl -v \ - -x localhost:8899 \ - http://localhost:8899/ + -x 127.0.0.1:$PROXY_PY_PORT \ + http://127.0.0.1:$PROXY_PY_PORT/ if [[ $? != 0 ]]; then echo "http request to built in webserver failed" exit 1 From 15534076a97c34be3ad23b0e01e2fd28435ee5be Mon Sep 17 00:00:00 2001 From: Abhinav Singh Date: Fri, 19 Nov 2021 15:52:30 +0530 Subject: [PATCH 2/2] Fix spellcheck-docs --- docs/spelling_wordlist.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/spelling_wordlist.txt b/docs/spelling_wordlist.txt index 79ecc548cf..5562179d58 100644 --- a/docs/spelling_wordlist.txt +++ b/docs/spelling_wordlist.txt @@ -5,3 +5,9 @@ scm Threadless threadless youtube +socio +sexualized +https +www +html +faq