From db87670698b9db8ed5d9a3651adb42c307c51d6c Mon Sep 17 00:00:00 2001 From: Alex Murray Date: Mon, 24 Feb 2025 22:08:04 +1030 Subject: [PATCH] tests/profiles/tinyproxy: use local http server for functional test Instead of relying on neverssl.com spin up a local http server and test tinyproxy against that to ensure the test can run even if the wider internet is not accessible. Signed-off-by: Alex Murray --- tests/profiles/tinyproxy/task.yaml | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/tests/profiles/tinyproxy/task.yaml b/tests/profiles/tinyproxy/task.yaml index e4b66c224..59bf90daa 100644 --- a/tests/profiles/tinyproxy/task.yaml +++ b/tests/profiles/tinyproxy/task.yaml @@ -1,4 +1,14 @@ summary: smoke test for the tinyproxy profile +prepare: | + # start a simple local web server which we will use later for functional + # tests + python3 -m http.server 1>/dev/null 2>&1 & + echo $! > .http-server.pid + +restore: | + kill $(cat .http-server.pid) + rm -f .http-server.pid + execute: | # restart tinyproxy service as it may already be running systemctl restart tinyproxy @@ -16,9 +26,9 @@ execute: | # previous test it could possibly being done by systemd instead "$SPREAD_PATH"/tests/bin/actual-profile-of tinyproxy | MATCH 'tinyproxy \(enforce\)' - # interact with tinyproxy to make sure it works and we get the expected - # response headers - http_proxy=http://localhost:8888 curl -s -i http://neverssl.com | MATCH '^Via: .*tinyproxy' + # interact with local web server via tinyproxy to make sure it works and we + # get the expected response headers + env http_proxy=http://localhost:8888 curl -s -i http://localhost:8000/task.yaml | MATCH '^Via: .*tinyproxy' # also check we can get the statistics page - http_proxy=http://localhost:8888 curl -s http://tinyproxy.stats | MATCH 'tinyproxy .* statistics' + env http_proxy=http://localhost:8888 curl -s http://tinyproxy.stats | MATCH 'tinyproxy .* statistics'