2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-08-29 13:28:19 +00:00

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 <alex.murray@canonical.com>
This commit is contained in:
Alex Murray 2025-02-24 22:08:04 +10:30
parent 52e0be286b
commit db87670698
No known key found for this signature in database
GPG Key ID: F498D2D9DE7DAD9C

View File

@ -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'