summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2015-09-15 00:33:12 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2015-09-15 10:16:09 +0200
commit6c0765c096ffb4df14169236c865bbb2b10974ae (patch)
treed4b37ceb25dec384ba08007a8b83d0ab4a6b7f92 /test
parentaf81ab9030229b4ce6cbe28f0f0831d4896fda01 (diff)
downloadapt-6c0765c096ffb4df14169236c865bbb2b10974ae.tar.gz
tests: don't use hardcoded port for http and https
This allows running tests in parallel. Git-Dch: Ignore
Diffstat (limited to 'test')
-rw-r--r--test/integration/framework34
-rwxr-xr-xtest/integration/test-acquire-same-file-multiple-times12
-rwxr-xr-xtest/integration/test-acquire-same-repository-multiple-times4
-rwxr-xr-xtest/integration/test-apt-acquire-additional-files90
-rwxr-xr-xtest/integration/test-apt-download-progress4
-rwxr-xr-xtest/integration/test-apt-get-changelog30
-rwxr-xr-xtest/integration/test-apt-helper52
-rwxr-xr-xtest/integration/test-apt-https-no-redirect8
-rwxr-xr-xtest/integration/test-apt-key-net-update4
-rwxr-xr-xtest/integration/test-apt-update-expected-size4
-rwxr-xr-xtest/integration/test-apt-update-ims68
-rwxr-xr-xtest/integration/test-apt-update-not-modified4
-rwxr-xr-xtest/integration/test-apt-update-stale2
-rwxr-xr-xtest/integration/test-authentication-basic20
-rwxr-xr-xtest/integration/test-bug-595691-empty-and-broken-archive-files8
-rwxr-xr-xtest/integration/test-bug-602412-dequote-redirect4
-rwxr-xr-xtest/integration/test-bug-624218-Translation-file-handling4
-rwxr-xr-xtest/integration/test-bug-717891-abolute-uris-for-proxies2
-rwxr-xr-xtest/integration/test-bug-738785-switch-protocol17
-rwxr-xr-xtest/integration/test-bug-778375-server-has-no-reason-phrase4
-rwxr-xr-xtest/integration/test-bug-lp1445239-download-loop2
-rwxr-xr-xtest/integration/test-cve-2013-1051-InRelease-parsing4
-rwxr-xr-xtest/integration/test-handle-redirect-as-used-mirror-change17
-rwxr-xr-xtest/integration/test-partial-file-support4
-rwxr-xr-xtest/integration/test-releasefile-verification12
-rwxr-xr-xtest/integration/test-ubuntu-bug-1098738-apt-get-source-md5sum44
-rwxr-xr-xtest/integration/test-ubuntu-bug-346386-apt-get-update-paywall12
-rw-r--r--test/interactive-helper/aptwebserver.cc33
28 files changed, 276 insertions, 227 deletions
diff --git a/test/integration/framework b/test/integration/framework
index 83f93217f..2fb924802 100644
--- a/test/integration/framework
+++ b/test/integration/framework
@@ -1119,7 +1119,7 @@ redatereleasefiles() {
}
webserverconfig() {
- local WEBSERVER="${3:-http://localhost:8080}"
+ local WEBSERVER="${3:-http://localhost:${APTHTTPPORT}}"
local NOCHECK=false
if [ "$1" = '--no-check' ]; then
NOCHECK=true
@@ -1128,13 +1128,14 @@ webserverconfig() {
local DOWNLOG='rootdir/tmp/download-testfile.log'
local STATUS='downloaded/webserverconfig.status'
rm -f "$STATUS" "$DOWNLOG"
+ # very very basic URI encoding
local URI
if [ -n "$2" ]; then
msgtest "Set webserver config option '${1}' to" "$2"
- URI="${WEBSERVER}/_config/set/${1}/${2}"
+ URI="${WEBSERVER}/_config/set/$(echo "${1}" | sed -e 's/\//%2f/g')/$(echo "${2}" | sed -e 's/\//%2f/g')"
else
msgtest 'Clear webserver config option' "${1}"
- URI="${WEBSERVER}/_config/clear/${1}"
+ URI="${WEBSERVER}/_config/clear/$(echo "${1}" | sed -e 's/\//%2f/g')"
fi
if downloadfile "$URI" "$STATUS" > "$DOWNLOG"; then
msgpass
@@ -1149,7 +1150,7 @@ webserverconfig() {
rewritesourceslist() {
local APTARCHIVE="file://$(readlink -f "${TMPWORKINGDIRECTORY}/aptarchive" | sed 's# #%20#g')"
for LIST in $(find rootdir/etc/apt/sources.list.d/ -name 'apt-test-*.list'); do
- sed -i $LIST -e "s#$APTARCHIVE#${1}#" -e "s#http://localhost:8080/#${1}#" -e "s#https://localhost:4433/#${1}#"
+ sed -i $LIST -e "s#$APTARCHIVE#${1}#" -e "s#http://localhost:${APTHTTPPORT}/#${1}#" -e "s#https://localhost:${APTHTTPSPORT}/#${1}#"
done
}
@@ -1168,28 +1169,37 @@ waitforpidfile() {
}
changetowebserver() {
+ local REWRITE='no'
if [ "$1" != '--no-rewrite' ]; then
- rewritesourceslist 'http://localhost:8080/'
+ REWRITE='yes'
else
shift
fi
if test -x "${APTWEBSERVERBINDIR}/aptwebserver"; then
cd aptarchive
local LOG="webserver.log"
- if ! aptwebserver -o aptwebserver::fork=1 "$@" >$LOG 2>&1 ; then
+ if ! aptwebserver --port 0 -o aptwebserver::fork=1 -o aptwebserver::portfile='aptwebserver.port' "$@" >$LOG 2>&1 ; then
cat $LOG
false
fi
- waitforpidfile aptwebserver.pid
+ waitforpidfile aptwebserver.pid
local PID="$(cat aptwebserver.pid)"
if [ -z "$PID" ]; then
msgdie 'Could not fork aptwebserver successfully'
fi
addtrap "kill $PID;"
+ waitforpidfile aptwebserver.port
+ APTHTTPPORT="$(cat aptwebserver.port)"
+ if [ -z "$APTHTTPPORT" ]; then
+ msgdie 'Could not get port for aptwebserver successfully'
+ fi
cd - > /dev/null
else
msgdie 'You have to build aptwerbserver or install a webserver'
fi
+ if [ "$REWRTE" != 'yes' ]; then
+ rewritesourceslist "http://localhost:${APTHTTPPORT}/"
+ fi
}
changetohttpswebserver() {
@@ -1204,8 +1214,8 @@ cert = ${TMPWORKINGDIRECTORY}/rootdir/etc/webserver.pem
output = /dev/null
[https]
-accept = 4433
-connect = 8080
+accept = 0
+connect = $APTHTTPPORT
" > "${TMPWORKINGDIRECTORY}/stunnel.conf"
stunnel4 "${TMPWORKINGDIRECTORY}/stunnel.conf"
waitforpidfile "${TMPWORKINGDIRECTORY}/aptarchive/stunnel.pid"
@@ -1214,7 +1224,9 @@ connect = 8080
msgdie 'Could not fork stunnel4 successfully'
fi
addtrap 'prefix' "kill ${PID};"
- rewritesourceslist 'https://localhost:4433/'
+ APTHTTPSPORT="$(lsof -i | awk "/^stunnel4 / && \$2 == \"${PID}\" {print \$9; exit; }" | cut -d':' -f 2)"
+ webserverconfig 'aptwebserver::port::https' "$APTHTTPSPORT" "https://localhost:${APTHTTPSPORT}"
+ rewritesourceslist "https://localhost:${APTHTTPSPORT}/"
}
changetocdrom() {
@@ -1671,7 +1683,7 @@ testwebserverlaststatuscode() {
local STATUS='downloaded/webserverstatus-statusfile.log'
rm -f "$DOWNLOG" "$STATUS"
msgtest 'Test last status code from the webserver was' "$1"
- if downloadfile "http://localhost:8080/_config/find/aptwebserver::last-status-code" "$STATUS" > "$DOWNLOG" && [ "$(cat "$STATUS")" = "$1" ]; then
+ if downloadfile "http://localhost:${APTHTTPPORT}/_config/find/aptwebserver::last-status-code" "$STATUS" > "$DOWNLOG" && [ "$(cat "$STATUS")" = "$1" ]; then
msgpass
else
local OUTPUT="${TMPWORKINGDIRECTORY}/rootdir/tmp/testwebserverlaststatuscode.output"
diff --git a/test/integration/test-acquire-same-file-multiple-times b/test/integration/test-acquire-same-file-multiple-times
index 255a71a33..354c683f2 100755
--- a/test/integration/test-acquire-same-file-multiple-times
+++ b/test/integration/test-acquire-same-file-multiple-times
@@ -12,7 +12,8 @@ APTARCHIVE="$(readlink -f ./aptarchive)"
filedown() {
msgtest 'Downloading the same URI twice over file' "$1"
- testsuccess --nomsg apthelper download-file "file:///$APTARCHIVE/foo" ./downloaded/foo1 '' "file:///$APTARCHIVE/foo" ./downloaded/foo2 '' -o Debug::pkgAcquire::Worker=1
+ testsuccess --nomsg apthelper download-file "file:///$APTARCHIVE/foo" './downloaded/foo1' '' \
+ "file:///$APTARCHIVE/foo" './downloaded/foo2' '' -o Debug::pkgAcquire::Worker=1
cp rootdir/tmp/testsuccess.output download.log
testsuccess cmp "$TESTFILE" ./downloaded/foo1
testsuccess cmp ./downloaded/foo1 ./downloaded/foo2
@@ -44,7 +45,8 @@ changetowebserver -o aptwebserver::redirect::replace::/foo2=/foo
httpdown() {
msgtest 'Downloading the same URI to different files' 'twice over http'
- testsuccess --nomsg apthelper download-file http://localhost:8080/foo ./downloaded/foo1 '' http://localhost:8080/foo ./downloaded/foo2 '' -o Debug::pkgAcquire::Worker=1 -o Debug::Acquire::http=1
+ testsuccess --nomsg apthelper download-file "http://localhost:${APTHTTPPORT}/foo" "./downloaded/foo1" '' \
+ "http://localhost:${APTHTTPPORT}/foo" './downloaded/foo2' '' -o Debug::pkgAcquire::Worker=1 -o Debug::Acquire::http=1
cp rootdir/tmp/testsuccess.output download.log
testsuccess cmp "$TESTDIR/framework" ./downloaded/foo1
testsuccess cmp ./downloaded/foo1 ./downloaded/foo2
@@ -56,7 +58,8 @@ testrun 'httpdown'
httpredirectdown() {
msgtest 'Redirect leads' 'first URI to the second URI'
- testsuccess --nomsg apthelper download-file http://localhost:8080/foo2 ./downloaded/foo1 '' http://localhost:8080/foo ./downloaded/foo2 '' -o Debug::pkgAcquire::Worker=1 -o Debug::Acquire::http=1
+ testsuccess --nomsg apthelper download-file "http://localhost:${APTHTTPPORT}/foo2" "./downloaded/foo1" '' \
+ "http://localhost:${APTHTTPPORT}/foo" './downloaded/foo2' '' -o Debug::pkgAcquire::Worker=1 -o Debug::Acquire::http=1
cp rootdir/tmp/testsuccess.output download.log
testsuccess cmp "$TESTDIR/framework" ./downloaded/foo1
testsuccess cmp ./downloaded/foo1 ./downloaded/foo2
@@ -69,7 +72,8 @@ testrun 'httpredirectdown'
httpsamedown() {
msgtest 'Downloading two files via the same URI to' 'the same file'
- testsuccess --nomsg apthelper download-file http://localhost:8080/foo ./downloaded/foo1 '' http://localhost:8080/foo ./downloaded/foo1 '' -o Debug::pkgAcquire::Worker=1
+ testsuccess --nomsg apthelper download-file "http://localhost:${APTHTTPPORT}/foo" "./downloaded/foo1" '' \
+ "http://localhost:${APTHTTPPORT}/foo" './downloaded/foo1' '' -o Debug::pkgAcquire::Worker=1
cp rootdir/tmp/testsuccess.output download.log
testsuccess cmp "$TESTDIR/framework" ./downloaded/foo1
testequal '1' grep -c '200%20URI%20Start' ./download.log
diff --git a/test/integration/test-acquire-same-repository-multiple-times b/test/integration/test-acquire-same-repository-multiple-times
index 19a18cb63..b99496e35 100755
--- a/test/integration/test-acquire-same-repository-multiple-times
+++ b/test/integration/test-acquire-same-repository-multiple-times
@@ -74,11 +74,11 @@ rm -rf rootdir/var/lib/apt/lists
changetowebserver
-tworepos 'http' '//localhost:8080' 'no partial'
+tworepos 'http' "//localhost:${APTHTTPPORT}" 'no partial'
testequal '10' grep -c '200%20URI%20Start' ./download.log
testequal '10' grep -c '201%20URI%20Done' ./download.log
testequal '6' grep -c '^ @ Queue: Action combined' ./download.log
-tworepos 'http' '//localhost:8080' 'hit'
+tworepos 'http' "//localhost:${APTHTTPPORT}" 'hit'
testequal '2' grep -c '200%20URI%20Start' ./download.log
testequal '4' grep -c '201%20URI%20Done' ./download.log
testequal '0' grep -c '^ @ Queue: Action combined' ./download.log
diff --git a/test/integration/test-apt-acquire-additional-files b/test/integration/test-apt-acquire-additional-files
index 6008c0695..4ba3c5bd9 100755
--- a/test/integration/test-apt-acquire-additional-files
+++ b/test/integration/test-apt-acquire-additional-files
@@ -16,15 +16,15 @@ buildsimplenativepackage 'foo' 'amd64' '1' 'unstable'
setupaptarchive --no-update
changetowebserver
-testequal "'http://localhost:8080/dists/unstable/InRelease' localhost:8080_dists_unstable_InRelease 0
-'http://localhost:8080/dists/unstable/main/source/Sources.xz' localhost:8080_dists_unstable_main_source_Sources 0
-'http://localhost:8080/dists/unstable/main/binary-amd64/Packages.xz' localhost:8080_dists_unstable_main_binary-amd64_Packages 0
-'http://localhost:8080/dists/unstable/main/i18n/Translation-en.xz' localhost:8080_dists_unstable_main_i18n_Translation-en 0 " aptget update --print-uris
-
-testsuccessequal "Get:1 http://localhost:8080 unstable InRelease [$(stat -c%s aptarchive/dists/unstable/InRelease) B]
-Get:2 http://localhost:8080 unstable/main Sources [$(stat -c%s aptarchive/dists/unstable/main/source/Sources.gz) B]
-Get:3 http://localhost:8080 unstable/main amd64 Packages [$(stat -c%s aptarchive/dists/unstable/main/binary-amd64/Packages.gz) B]
-Get:4 http://localhost:8080 unstable/main Translation-en [$(stat -c%s aptarchive/dists/unstable/main/i18n/Translation-en.gz) B]
+testequal "'http://localhost:${APTHTTPPORT}/dists/unstable/InRelease' localhost:${APTHTTPPORT}_dists_unstable_InRelease 0
+'http://localhost:${APTHTTPPORT}/dists/unstable/main/source/Sources.xz' localhost:${APTHTTPPORT}_dists_unstable_main_source_Sources 0
+'http://localhost:${APTHTTPPORT}/dists/unstable/main/binary-amd64/Packages.xz' localhost:${APTHTTPPORT}_dists_unstable_main_binary-amd64_Packages 0
+'http://localhost:${APTHTTPPORT}/dists/unstable/main/i18n/Translation-en.xz' localhost:${APTHTTPPORT}_dists_unstable_main_i18n_Translation-en 0 " aptget update --print-uris
+
+testsuccessequal "Get:1 http://localhost:${APTHTTPPORT} unstable InRelease [$(stat -c%s aptarchive/dists/unstable/InRelease) B]
+Get:2 http://localhost:${APTHTTPPORT} unstable/main Sources [$(stat -c%s aptarchive/dists/unstable/main/source/Sources.gz) B]
+Get:3 http://localhost:${APTHTTPPORT} unstable/main amd64 Packages [$(stat -c%s aptarchive/dists/unstable/main/binary-amd64/Packages.gz) B]
+Get:4 http://localhost:${APTHTTPPORT} unstable/main Translation-en [$(stat -c%s aptarchive/dists/unstable/main/i18n/Translation-en.gz) B]
Reading package lists..." aptget update
testempty find rootdir/var/lib/apt/lists -name '*Contents*'
@@ -37,40 +37,40 @@ Acquire::IndexTargets::deb::Contents {
};
EOF
-testequal "$(readlink -f ./rootdir/var/lib/apt/lists/localhost:8080_dists_unstable_main_Contents-amd64)" aptget indextargets --no-release-info --format '$(FILENAME)' 'Created-By: Contents'
+testequal "$(readlink -f ./rootdir/var/lib/apt/lists/localhost:${APTHTTPPORT}_dists_unstable_main_Contents-amd64)" aptget indextargets --no-release-info --format '$(FILENAME)' 'Created-By: Contents'
testempty aptget indextargets --format '$(FILENAME)' 'Created-By: Contents'
# lets fake the existence of a compressed Contents file
-touch ./rootdir/var/lib/apt/lists/localhost:8080_dists_unstable_main_Contents-amd64.gz
-testequal "$(readlink -f ./rootdir/var/lib/apt/lists/localhost:8080_dists_unstable_main_Contents-amd64.gz)" aptget indextargets --format '$(FILENAME)' 'Created-By: Contents'
+touch ./rootdir/var/lib/apt/lists/localhost:${APTHTTPPORT}_dists_unstable_main_Contents-amd64.gz
+testequal "$(readlink -f ./rootdir/var/lib/apt/lists/localhost:${APTHTTPPORT}_dists_unstable_main_Contents-amd64.gz)" aptget indextargets --format '$(FILENAME)' 'Created-By: Contents'
-testequal "'http://localhost:8080/dists/unstable/InRelease' localhost:8080_dists_unstable_InRelease 0
-'http://localhost:8080/dists/unstable/main/source/Sources.xz' localhost:8080_dists_unstable_main_source_Sources 0
-'http://localhost:8080/dists/unstable/main/binary-amd64/Packages.xz' localhost:8080_dists_unstable_main_binary-amd64_Packages 0
-'http://localhost:8080/dists/unstable/main/i18n/Translation-en.xz' localhost:8080_dists_unstable_main_i18n_Translation-en 0
-'http://localhost:8080/dists/unstable/main/Contents-amd64.xz' localhost:8080_dists_unstable_main_Contents-amd64 0 " aptget update --print-uris
+testequal "'http://localhost:${APTHTTPPORT}/dists/unstable/InRelease' localhost:${APTHTTPPORT}_dists_unstable_InRelease 0
+'http://localhost:${APTHTTPPORT}/dists/unstable/main/source/Sources.xz' localhost:${APTHTTPPORT}_dists_unstable_main_source_Sources 0
+'http://localhost:${APTHTTPPORT}/dists/unstable/main/binary-amd64/Packages.xz' localhost:${APTHTTPPORT}_dists_unstable_main_binary-amd64_Packages 0
+'http://localhost:${APTHTTPPORT}/dists/unstable/main/i18n/Translation-en.xz' localhost:${APTHTTPPORT}_dists_unstable_main_i18n_Translation-en 0
+'http://localhost:${APTHTTPPORT}/dists/unstable/main/Contents-amd64.xz' localhost:${APTHTTPPORT}_dists_unstable_main_Contents-amd64 0 " aptget update --print-uris
-testsuccessequal "Hit:1 http://localhost:8080 unstable InRelease
-Get:2 http://localhost:8080 unstable/main amd64 Contents [$(stat -c%s aptarchive/dists/unstable/main/Contents-amd64.gz) B]
+testsuccessequal "Hit:1 http://localhost:${APTHTTPPORT} unstable InRelease
+Get:2 http://localhost:${APTHTTPPORT} unstable/main amd64 Contents [$(stat -c%s aptarchive/dists/unstable/main/Contents-amd64.gz) B]
Reading package lists..." aptget update
-testequal 'rootdir/var/lib/apt/lists/localhost:8080_dists_unstable_main_Contents-amd64' find rootdir/var/lib/apt/lists -name '*Contents*'
-testequal "$(readlink -f ./rootdir/var/lib/apt/lists/localhost:8080_dists_unstable_main_Contents-amd64)" aptget indextargets --format '$(FILENAME)' 'Created-By: Contents'
-testsuccess cmp 'rootdir/var/lib/apt/lists/localhost:8080_dists_unstable_main_Contents-amd64' 'aptarchive/dists/unstable/main/Contents-amd64'
+testequal "rootdir/var/lib/apt/lists/localhost:${APTHTTPPORT}_dists_unstable_main_Contents-amd64" find rootdir/var/lib/apt/lists -name '*Contents*'
+testequal "$(readlink -f ./rootdir/var/lib/apt/lists/localhost:${APTHTTPPORT}_dists_unstable_main_Contents-amd64)" aptget indextargets --format '$(FILENAME)' 'Created-By: Contents'
+testsuccess cmp "rootdir/var/lib/apt/lists/localhost:${APTHTTPPORT}_dists_unstable_main_Contents-amd64" 'aptarchive/dists/unstable/main/Contents-amd64'
-rm ./rootdir/var/lib/apt/lists/localhost:8080_dists_unstable_main_Contents-amd64
+rm ./rootdir/var/lib/apt/lists/localhost:${APTHTTPPORT}_dists_unstable_main_Contents-amd64
testempty aptget indextargets --format '$(FILENAME)' 'Created-By: Contents'
# if we asked for keeping it compressed, keep it
echo 'Acquire::IndexTargets::deb::Contents::KeepCompressed "true";' >> rootdir/etc/apt/apt.conf.d/content-target.conf
-testsuccessequal "Hit:1 http://localhost:8080 unstable InRelease
-Get:2 http://localhost:8080 unstable/main amd64 Contents [$(stat -c%s aptarchive/dists/unstable/main/Contents-amd64.gz) B]
+testsuccessequal "Hit:1 http://localhost:${APTHTTPPORT} unstable InRelease
+Get:2 http://localhost:${APTHTTPPORT} unstable/main amd64 Contents [$(stat -c%s aptarchive/dists/unstable/main/Contents-amd64.gz) B]
Reading package lists..." aptget update
-testequal 'rootdir/var/lib/apt/lists/localhost:8080_dists_unstable_main_Contents-amd64.gz' find rootdir/var/lib/apt/lists -name '*Contents*'
-testequal "$(readlink -f ./rootdir/var/lib/apt/lists/localhost:8080_dists_unstable_main_Contents-amd64.gz)" aptget indextargets --format '$(FILENAME)' 'Created-By: Contents'
-testsuccess cmp 'rootdir/var/lib/apt/lists/localhost:8080_dists_unstable_main_Contents-amd64.gz' 'aptarchive/dists/unstable/main/Contents-amd64.gz'
+testequal "rootdir/var/lib/apt/lists/localhost:${APTHTTPPORT}_dists_unstable_main_Contents-amd64.gz" find rootdir/var/lib/apt/lists -name '*Contents*'
+testequal "$(readlink -f ./rootdir/var/lib/apt/lists/localhost:${APTHTTPPORT}_dists_unstable_main_Contents-amd64.gz)" aptget indextargets --format '$(FILENAME)' 'Created-By: Contents'
+testsuccess cmp "rootdir/var/lib/apt/lists/localhost:${APTHTTPPORT}_dists_unstable_main_Contents-amd64.gz" 'aptarchive/dists/unstable/main/Contents-amd64.gz'
-rm ./rootdir/var/lib/apt/lists/localhost:8080_dists_unstable_main_Contents-amd64.gz
+rm ./rootdir/var/lib/apt/lists/localhost:${APTHTTPPORT}_dists_unstable_main_Contents-amd64.gz
testempty aptget indextargets --format '$(FILENAME)' 'Created-By: Contents'
# and no automatic uncompress based on the name please,
@@ -84,28 +84,28 @@ Acquire::IndexTargets::deb::Contents {
EOF
# the last line is utter bogus of course, but how should apt know…
-testequal "'http://localhost:8080/dists/unstable/InRelease' localhost:8080_dists_unstable_InRelease 0
-'http://localhost:8080/dists/unstable/main/source/Sources.xz' localhost:8080_dists_unstable_main_source_Sources 0
-'http://localhost:8080/dists/unstable/main/binary-amd64/Packages.xz' localhost:8080_dists_unstable_main_binary-amd64_Packages 0
-'http://localhost:8080/dists/unstable/main/i18n/Translation-en.xz' localhost:8080_dists_unstable_main_i18n_Translation-en 0
-'http://localhost:8080/dists/unstable/main/Contents-amd64.gz.xz' localhost:8080_dists_unstable_main_Contents-amd64.gz 0 " aptget update --print-uris
-
-testsuccessequal "Hit:1 http://localhost:8080 unstable InRelease
-Get:2 http://localhost:8080 unstable/main amd64 Contents.gz [$(stat -c%s aptarchive/dists/unstable/main/Contents-amd64.gz) B]
+testequal "'http://localhost:${APTHTTPPORT}/dists/unstable/InRelease' localhost:${APTHTTPPORT}_dists_unstable_InRelease 0
+'http://localhost:${APTHTTPPORT}/dists/unstable/main/source/Sources.xz' localhost:${APTHTTPPORT}_dists_unstable_main_source_Sources 0
+'http://localhost:${APTHTTPPORT}/dists/unstable/main/binary-amd64/Packages.xz' localhost:${APTHTTPPORT}_dists_unstable_main_binary-amd64_Packages 0
+'http://localhost:${APTHTTPPORT}/dists/unstable/main/i18n/Translation-en.xz' localhost:${APTHTTPPORT}_dists_unstable_main_i18n_Translation-en 0
+'http://localhost:${APTHTTPPORT}/dists/unstable/main/Contents-amd64.gz.xz' localhost:${APTHTTPPORT}_dists_unstable_main_Contents-amd64.gz 0 " aptget update --print-uris
+
+testsuccessequal "Hit:1 http://localhost:${APTHTTPPORT} unstable InRelease
+Get:2 http://localhost:${APTHTTPPORT} unstable/main amd64 Contents.gz [$(stat -c%s aptarchive/dists/unstable/main/Contents-amd64.gz) B]
Reading package lists..." aptget update
-testequal 'rootdir/var/lib/apt/lists/localhost:8080_dists_unstable_main_Contents-amd64.gz' find rootdir/var/lib/apt/lists -name '*Contents*'
-testequal "$(readlink -f ./rootdir/var/lib/apt/lists/localhost:8080_dists_unstable_main_Contents-amd64.gz)" aptget indextargets --format '$(FILENAME)' 'Created-By: Contents'
-testsuccess cmp 'rootdir/var/lib/apt/lists/localhost:8080_dists_unstable_main_Contents-amd64.gz' 'aptarchive/dists/unstable/main/Contents-amd64.gz'
+testequal "rootdir/var/lib/apt/lists/localhost:${APTHTTPPORT}_dists_unstable_main_Contents-amd64.gz" find rootdir/var/lib/apt/lists -name '*Contents*'
+testequal "$(readlink -f ./rootdir/var/lib/apt/lists/localhost:${APTHTTPPORT}_dists_unstable_main_Contents-amd64.gz)" aptget indextargets --format '$(FILENAME)' 'Created-By: Contents'
+testsuccess cmp "rootdir/var/lib/apt/lists/localhost:${APTHTTPPORT}_dists_unstable_main_Contents-amd64.gz" 'aptarchive/dists/unstable/main/Contents-amd64.gz'
rm -f rootdir/etc/apt/apt.conf.d/content-target.conf
-testequal "'http://localhost:8080/dists/unstable/InRelease' localhost:8080_dists_unstable_InRelease 0
-'http://localhost:8080/dists/unstable/main/source/Sources.xz' localhost:8080_dists_unstable_main_source_Sources 0
-'http://localhost:8080/dists/unstable/main/binary-amd64/Packages.xz' localhost:8080_dists_unstable_main_binary-amd64_Packages 0
-'http://localhost:8080/dists/unstable/main/i18n/Translation-en.xz' localhost:8080_dists_unstable_main_i18n_Translation-en 0 " aptget update --print-uris
+testequal "'http://localhost:${APTHTTPPORT}/dists/unstable/InRelease' localhost:${APTHTTPPORT}_dists_unstable_InRelease 0
+'http://localhost:${APTHTTPPORT}/dists/unstable/main/source/Sources.xz' localhost:${APTHTTPPORT}_dists_unstable_main_source_Sources 0
+'http://localhost:${APTHTTPPORT}/dists/unstable/main/binary-amd64/Packages.xz' localhost:${APTHTTPPORT}_dists_unstable_main_binary-amd64_Packages 0
+'http://localhost:${APTHTTPPORT}/dists/unstable/main/i18n/Translation-en.xz' localhost:${APTHTTPPORT}_dists_unstable_main_i18n_Translation-en 0 " aptget update --print-uris
-testsuccessequal "Hit:1 http://localhost:8080 unstable InRelease
+testsuccessequal "Hit:1 http://localhost:${APTHTTPPORT} unstable InRelease
Reading package lists..." aptget update
testempty find rootdir/var/lib/apt/lists -name '*Contents*'
diff --git a/test/integration/test-apt-download-progress b/test/integration/test-apt-download-progress
index bf6a412ad..64a122a06 100755
--- a/test/integration/test-apt-download-progress
+++ b/test/integration/test-apt-download-progress
@@ -30,12 +30,12 @@ OPT='-o APT::Status-Fd=3 -o Debug::pkgAcquire::Worker=1 -o Debug::Acquire::http=
msgtest 'download progress works via' 'http'
exec 3> apt-progress.log
-testsuccess --nomsg apthelper download-file "http://localhost:8080/$TESTFILE" ./downloaded/http-$TESTFILE $OPT -o Acquire::http::Dl-Limit=800
+testsuccess --nomsg apthelper download-file "http://localhost:${APTHTTPPORT}/$TESTFILE" ./downloaded/http-$TESTFILE $OPT -o Acquire::http::Dl-Limit=800
assertprogress apt-progress.log
msgtest 'download progress works via' 'https'
exec 3> apt-progress.log
-testsuccess --nomsg apthelper download-file "https://localhost:4433/$TESTFILE" ./downloaded/https-$TESTFILE $OPT -o Acquire::https::Dl-Limit=800
+testsuccess --nomsg apthelper download-file "https://localhost:${APTHTTPSPORT}/$TESTFILE" ./downloaded/https-$TESTFILE $OPT -o Acquire::https::Dl-Limit=800
assertprogress apt-progress.log
# cleanup
diff --git a/test/integration/test-apt-get-changelog b/test/integration/test-apt-get-changelog
index 502920617..1c0c45c61 100755
--- a/test/integration/test-apt-get-changelog
+++ b/test/integration/test-apt-get-changelog
@@ -33,18 +33,18 @@ releasechanger 'Label' 'Debian'
testsuccessequal "'http://changelogs.ubuntu.com/changelogs/pool/main/f/foo/foo_1.0/changelog' foo.changelog
'http://changelogs.ubuntu.com/changelogs/pool/main/libb/libbar/libbar_1.0/changelog' libbar.changelog" aptget changelog foo libbar --print-uris
-testsuccessequal "'http://localhost:8080/main/f/foo/foo_1.0.changelog' foo.changelog
-'http://localhost:8080/main/libb/libbar/libbar_1.0.changelog' libbar.changelog" aptget changelog foo libbar --print-uris -o Acquire::Changelogs::URI::Label::Debian='http://localhost:8080/CHANGEPATH.changelog'
+testsuccessequal "'http://localhost:${APTHTTPPORT}/main/f/foo/foo_1.0.changelog' foo.changelog
+'http://localhost:${APTHTTPPORT}/main/libb/libbar/libbar_1.0.changelog' libbar.changelog" aptget changelog foo libbar --print-uris -o Acquire::Changelogs::URI::Label::Debian="http://localhost:${APTHTTPPORT}/CHANGEPATH.changelog"
sed -i '/^Origin: / a\
Changelogs: http://example.org/CHANGEPATH-changelog' $(find rootdir/var/lib/apt/lists -name '*Release')
rm -f rootdir/var/cache/apt/*.bin
testsuccessequal "'http://example.org/main/f/foo/foo_1.0-changelog' foo.changelog
-'http://example.org/main/libb/libbar/libbar_1.0-changelog' libbar.changelog" aptget changelog foo libbar --print-uris -o Acquire::Changelogs::URI::Label::Debian='http://localhost:8080/CHANGEPATH.changelog'
+'http://example.org/main/libb/libbar/libbar_1.0-changelog' libbar.changelog" aptget changelog foo libbar --print-uris -o Acquire::Changelogs::URI::Label::Debian="http://localhost:${APTHTTPPORT}/CHANGEPATH.changelog"
-testsuccessequal "'http://localhost:8080/main/f/foo/foo_1.0.changelog' foo.changelog
-'http://localhost:8080/main/libb/libbar/libbar_1.0.changelog' libbar.changelog" aptget changelog foo libbar --print-uris -o Acquire::Changelogs::URI::Override::Label::Debian='http://localhost:8080/CHANGEPATH.changelog'
+testsuccessequal "'http://localhost:${APTHTTPPORT}/main/f/foo/foo_1.0.changelog' foo.changelog
+'http://localhost:${APTHTTPPORT}/main/libb/libbar/libbar_1.0.changelog' libbar.changelog" aptget changelog foo libbar --print-uris -o Acquire::Changelogs::URI::Override::Label::Debian="http://localhost:${APTHTTPPORT}/CHANGEPATH.changelog"
releasechanger 'Changelogs' 'no'
if [ "$(id -u)" = '0' ]; then
@@ -57,12 +57,12 @@ fi
sed -i '/^Changelogs: / d' $(find rootdir/var/lib/apt/lists -name '*Release')
releasechanger 'Label' 'Testcases'
-echo 'Acquire::Changelogs::URI::Label::Testcases "http://localhost:8080/CHANGEPATH/change.txt";' > rootdir/etc/apt/apt.conf.d/changelog.conf
-testsuccessequal "'http://localhost:8080/main/f/foo/foo_1.0/change.txt' foo.changelog
-'http://localhost:8080/main/libb/libbar/libbar_1.0/change.txt' libbar.changelog" aptget changelog foo libbar --print-uris
+echo "Acquire::Changelogs::URI::Label::Testcases \"http://localhost:${APTHTTPPORT}/CHANGEPATH/change.txt\";" > rootdir/etc/apt/apt.conf.d/changelog.conf
+testsuccessequal "'http://localhost:${APTHTTPPORT}/main/f/foo/foo_1.0/change.txt' foo.changelog
+'http://localhost:${APTHTTPPORT}/main/libb/libbar/libbar_1.0/change.txt' libbar.changelog" aptget changelog foo libbar --print-uris
-echo 'Acquire::Changelogs::URI::Label::Testcases "http://localhost:8080/pool/CHANGEPATH/changelog";' > rootdir/etc/apt/apt.conf.d/changelog.conf
-testsuccessequal "'http://localhost:8080/pool/main/f/foo/foo_1.0/changelog' foo.changelog" aptget changelog foo --print-uris
+echo "Acquire::Changelogs::URI::Label::Testcases \"http://localhost:${APTHTTPPORT}/pool/CHANGEPATH/changelog\";" > rootdir/etc/apt/apt.conf.d/changelog.conf
+testsuccessequal "'http://localhost:${APTHTTPPORT}/pool/main/f/foo/foo_1.0/changelog' foo.changelog" aptget changelog foo --print-uris
testsuccess aptget changelog foo -qq
@@ -87,8 +87,8 @@ testfileequal 'foo.changelog' "$(cat ../aptarchive/pool/main/f/foo/foo_1.0/chan
rm -f libbar.changelog foo.changelog
# as such bogus, but can happen with multiple binaries from the same source
-testsuccessequal "'http://localhost:8080/pool/main/f/foo/foo_1.0/changelog' foo.changelog
-'http://localhost:8080/pool/main/f/foo/foo_1.0/changelog' foo.changelog" aptget changelog foo foo --print-uris
+testsuccessequal "'http://localhost:${APTHTTPPORT}/pool/main/f/foo/foo_1.0/changelog' foo.changelog
+'http://localhost:${APTHTTPPORT}/pool/main/f/foo/foo_1.0/changelog' foo.changelog" aptget changelog foo foo --print-uris
testsuccess aptget changelog foo foo -qq
testfileequal '../rootdir/tmp/testsuccess.output' "$(cat ../aptarchive/pool/main/f/foo/foo_1.0/changelog)
$(cat ../aptarchive/pool/main/f/foo/foo_1.0/changelog)"
@@ -99,9 +99,9 @@ rm -f foo.changelog
# no CHANGEPATH in the URI
testequal 'E: Failed to fetch changelog:/foo.changelog Changelog unavailable for foo=1.0
-' aptget changelog foo -qq -d -o Acquire::Changelogs::URI::Label::Testcases='http://localhost:8080/change.txt'
+' aptget changelog foo -qq -d -o Acquire::Changelogs::URI::Label::Testcases="http://localhost:${APTHTTPPORT}/change.txt"
testfailure test -e foo.changelog
-testequal 'E: Failed to fetch http://localhost:8080/does/not/exist/main/f/foo/foo_1.0/change.txt Changelog unavailable for foo=1.0 (404 Not Found)
-' aptget changelog foo -qq -d -o Acquire::Changelogs::URI::Label::Testcases='http://localhost:8080/does/not/exist/CHANGEPATH/change.txt'
+testequal "E: Failed to fetch http://localhost:${APTHTTPPORT}/does/not/exist/main/f/foo/foo_1.0/change.txt Changelog unavailable for foo=1.0 (404 Not Found)
+" aptget changelog foo -qq -d -o Acquire::Changelogs::URI::Label::Testcases="http://localhost:${APTHTTPPORT}/does/not/exist/CHANGEPATH/change.txt"
testfailure test -e foo.changelog
diff --git a/test/integration/test-apt-helper b/test/integration/test-apt-helper
index 944406580..b78201ef0 100755
--- a/test/integration/test-apt-helper
+++ b/test/integration/test-apt-helper
@@ -9,49 +9,53 @@ configarchitecture 'i386'
changetohttpswebserver
+echo 'foo' > aptarchive/foo
+echo 'bar' > aptarchive/foo2
+
test_apt_helper_download() {
- echo 'foo' > aptarchive/foo
- echo 'bar' > aptarchive/foo2
+ msgmsg 'Test with' "$1"
msgtest 'apt-file download-file' 'md5sum'
- testsuccess --nomsg apthelper download-file http://localhost:8080/foo ./downloaded/foo2 MD5Sum:d3b07384d113edec49eaa6238ad5ff00
+ testsuccess --nomsg apthelper download-file "${1}/foo" './downloaded/foo2' 'MD5Sum:d3b07384d113edec49eaa6238ad5ff00'
testfileequal ./downloaded/foo2 'foo'
msgtest 'apt-file download-file' 'sha1'
- testsuccess --nomsg apthelper download-file http://localhost:8080/foo ./downloaded/foo1 SHA1:f1d2d2f924e986ac86fdf7b36c94bcdf32beec15
+ testsuccess --nomsg apthelper download-file "${1}/foo" './downloaded/foo1' 'SHA1:f1d2d2f924e986ac86fdf7b36c94bcdf32beec15'
testfileequal ./downloaded/foo1 'foo'
msgtest 'apt-file download-file' 'sha256'
- testsuccess --nomsg apthelper download-file http://localhost:8080/foo ./downloaded/foo3 SHA256:b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c
+ testsuccess --nomsg apthelper download-file "${1}/foo" './downloaded/foo3' 'SHA256:b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c'
testfileequal ./downloaded/foo3 'foo'
msgtest 'apt-file download-file' 'no-hash'
- testsuccess --nomsg apthelper download-file http://localhost:8080/foo ./downloaded/foo4
+ testsuccess --nomsg apthelper download-file "${1}/foo" './downloaded/foo4'
testfileequal ./downloaded/foo4 'foo'
msgtest 'apt-file download-file' 'wrong md5sum'
- testfailure --nomsg apthelper -qq download-file http://localhost:8080/foo ./downloaded/foo5 MD5Sum:aabbcc
- testfileequal rootdir/tmp/testfailure.output 'E: Failed to fetch http://localhost:8080/foo Hash Sum mismatch
+ testfailure --nomsg apthelper -qq download-file "${1}/foo" './downloaded/foo5' 'MD5Sum:aabbcc'
+ testfileequal rootdir/tmp/testfailure.output "E: Failed to fetch ${1}/foo Hash Sum mismatch
-E: Download Failed'
+E: Download Failed"
testfileequal ./downloaded/foo5.FAILED 'foo'
msgtest 'apt-file download-file' 'wrong sha256'
- testfailure --nomsg apthelper -qq download-file http://localhost:8080/foo ./downloaded/foo6 SHA256:aabbcc
- testfileequal rootdir/tmp/testfailure.output 'E: Failed to fetch http://localhost:8080/foo Hash Sum mismatch
+ testfailure --nomsg apthelper -qq download-file "${1}/foo" './downloaded/foo6' 'SHA256:aabbcc'
+ testfileequal rootdir/tmp/testfailure.output "E: Failed to fetch ${1}/foo Hash Sum mismatch
-E: Download Failed'
- testfileequal ./downloaded/foo6.FAILED 'foo'
+E: Download Failed"
+ testfileequal './downloaded/foo6.FAILED' 'foo'
msgtest 'apt-file download-file' 'sha256 sha1'
- testsuccess --nomsg apthelper download-file http://localhost:8080/foo ./downloaded/foo8 SHA256:b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c http://localhost:8080/foo2 ./downloaded/foo7 SHA1:e242ed3bffccdf271b7fbaf34ed72d089537b42f
- testfileequal ./downloaded/foo8 'foo'
- testfileequal ./downloaded/foo7 'bar'
+ testsuccess --nomsg apthelper download-file "${1}/foo" './downloaded/foo8' 'SHA256:b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c' \
+ "${1}/foo2" './downloaded/foo7' 'SHA1:e242ed3bffccdf271b7fbaf34ed72d089537b42f'
+ testfileequal './downloaded/foo8' 'foo'
+ testfileequal './downloaded/foo7' 'bar'
msgtest 'apt-file download-file' 'md5sum sha1'
- testsuccess --nomsg apthelper download-file http://localhost:8080/foo ./downloaded/foo9 MD5Sum:d3b07384d113edec49eaa6238ad5ff00 http://localhost:8080/foo2 ./downloaded/foo10 SHA1:e242ed3bffccdf271b7fbaf34ed72d089537b42f
- testfileequal ./downloaded/foo9 'foo'
- testfileequal ./downloaded/foo10 'bar'
+ testsuccess --nomsg apthelper download-file "${1}/foo" './downloaded/foo9' 'MD5Sum:d3b07384d113edec49eaa6238ad5ff00' \
+ "${1}/foo2" './downloaded/foo10' 'SHA1:e242ed3bffccdf271b7fbaf34ed72d089537b42f'
+ testfileequal './downloaded/foo9' 'foo'
+ testfileequal './downloaded/foo10' 'bar'
}
test_apt_helper_detect_proxy() {
@@ -81,14 +85,16 @@ EOF
testsuccessequal "Using proxy 'https://https-proxy' for URL 'https://ssl.example.com/'" apthelper auto-detect-proxy https://ssl.example.com
}
-test_apt_helper_download
+test_apt_helper_download "http://localhost:${APTHTTPPORT}"
+test_apt_helper_download "https://localhost:${APTHTTPSPORT}"
test_apt_helper_detect_proxy
# test failure modes
testfailureequal 'E: Invalid operation download' apthelper download
testfailureequal 'E: Must specify at least one pair url/filename' apthelper download-file
-testfailureequal 'E: Must specify at least one pair url/filename' apthelper download-file http://example.org/
+testfailureequal 'E: Must specify at least one pair url/filename' apthelper download-file 'http://example.org/'
testfailureequal 'E: Need one URL as argument' apthelper auto-detect-proxy
testfailureequal 'E: Must specify at least one SRV record' apthelper srv-lookup
-testfailureequal 'E: GetSrvRec failed for localhost' apthelper srv-lookup localhost
-testfailureequal 'E: GetSrvRec failed for localhost:8080' apthelper srv-lookup localhost:8080
+testfailureequal 'E: GetSrvRec failed for localhost' apthelper srv-lookup 'localhost'
+testfailureequal "E: GetSrvRec failed for localhost:${APTHTTPPORT}" apthelper srv-lookup "localhost:${APTHTTPPORT}"
+testfailureequal "E: GetSrvRec failed for localhost:${APTHTTPSPORT}" apthelper srv-lookup "localhost:${APTHTTPSPORT}"
diff --git a/test/integration/test-apt-https-no-redirect b/test/integration/test-apt-https-no-redirect
index c91c78916..a29c0dacf 100755
--- a/test/integration/test-apt-https-no-redirect
+++ b/test/integration/test-apt-https-no-redirect
@@ -11,18 +11,18 @@ insertpackage 'stable' 'apt' 'all' '1'
setupaptarchive --no-update
echo 'alright' > aptarchive/working
-changetohttpswebserver -o 'aptwebserver::redirect::replace::/redirectme/=http://localhost:8080/'
+changetohttpswebserver -o "aptwebserver::redirect::replace::/redirectme/=http://localhost:${APTHTTPPORT}/"
msgtest 'download of a file works via' 'http'
-testsuccess --nomsg downloadfile 'http://localhost:8080/working' httpfile
+testsuccess --nomsg downloadfile "http://localhost:${APTHTTPPORT}/working" httpfile
testfileequal httpfile 'alright'
msgtest 'download of a file works via' 'https'
-testsuccess --nomsg downloadfile 'https://localhost:4433/working' httpsfile
+testsuccess --nomsg downloadfile "https://localhost:${APTHTTPSPORT}/working" httpsfile
testfileequal httpsfile 'alright'
msgtest 'download of a file does not work if' 'https redirected to http'
-testfailure --nomsg downloadfile 'https://localhost:4433/redirectme/working' redirectfile
+testfailure --nomsg downloadfile "https://localhost:${APTHTTPSPORT}/redirectme/working" redirectfile
msgtest 'libcurl has forbidden access in last request to' 'http resource'
testsuccess --nomsg grep -q -E -- 'Protocol "?http"? not supported or disabled in libcurl' rootdir/tmp/testfailure.output
diff --git a/test/integration/test-apt-key-net-update b/test/integration/test-apt-key-net-update
index 2a0823bec..93c72dd5b 100755
--- a/test/integration/test-apt-key-net-update
+++ b/test/integration/test-apt-key-net-update
@@ -19,7 +19,7 @@ echo "APT::Key::MasterKeyring \"${TMPWORKINGDIRECTORY}/usr/share/keyrings/test-m
# setup archive-keyring
mkdir -p aptarchive/ubuntu/project
install -m0644 keys/test-archive-keyring.pub aptarchive/ubuntu/project/
-echo 'APT::Key::ArchiveKeyringURI "http://localhost:8080/ubuntu/project/test-archive-keyring.pub";' >> ./aptconfig.conf
+echo "APT::Key::ArchiveKeyringURI \"http://localhost:${APTHTTPPORT}/ubuntu/project/test-archive-keyring.pub\";" >> ./aptconfig.conf
echo 'APT::Key::Net-Update-Enabled "1";' >> ./aptconfig.conf
# test against the "real" webserver
@@ -36,7 +36,7 @@ pub 2048R/DBAC8DAE 2010-08-18'
# setup archive-keyring
mkdir -p aptarchive/ubuntu/project
install -m0644 keys/marvinparanoid.pub aptarchive/ubuntu/project/
-echo 'APT::Key::ArchiveKeyringURI "http://localhost:8080/ubuntu/project/marvinparanoid.pub";' >> ./aptconfig.conf
+echo "APT::Key::ArchiveKeyringURI \"http://localhost:${APTHTTPPORT}/ubuntu/project/marvinparanoid.pub\";" >> ./aptconfig.conf
echo 'APT::Key::Net-Update-Enabled "1";' >> ./aptconfig.conf
# test against the "real" webserver
diff --git a/test/integration/test-apt-update-expected-size b/test/integration/test-apt-update-expected-size
index 24ca85133..21568e9c2 100755
--- a/test/integration/test-apt-update-expected-size
+++ b/test/integration/test-apt-update-expected-size
@@ -71,7 +71,7 @@ methodtest() {
}
changetowebserver
-methodtest 'http://localhost:8080'
+methodtest "http://localhost:${APTHTTPPORT}"
changetohttpswebserver
-methodtest 'https://localhost:4433'
+methodtest "https://localhost:${APTHTTPSPORT}"
diff --git a/test/integration/test-apt-update-ims b/test/integration/test-apt-update-ims
index 80ef28093..bc7a2b1bf 100755
--- a/test/integration/test-apt-update-ims
+++ b/test/integration/test-apt-update-ims
@@ -55,18 +55,18 @@ runtest() {
}
msgmsg 'InRelease'
-EXPECT='Hit:1 http://localhost:8080 unstable InRelease
-Reading package lists...'
+EXPECT="Hit:1 http://localhost:${APTHTTPPORT} unstable InRelease
+Reading package lists..."
echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
runtest
echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
runtest
msgmsg 'Release/Release.gpg'
-EXPECT='Ign:1 http://localhost:8080 unstable InRelease
+EXPECT="Ign:1 http://localhost:${APTHTTPPORT} unstable InRelease
404 Not Found
-Hit:2 http://localhost:8080 unstable Release
-Reading package lists...'
+Hit:2 http://localhost:${APTHTTPPORT} unstable Release
+Reading package lists..."
find aptarchive -name 'InRelease' -delete
echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
runtest
@@ -74,13 +74,13 @@ echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
runtest
msgmsg 'Release only'
-EXPECT="Ign:1 http://localhost:8080 unstable InRelease
+EXPECT="Ign:1 http://localhost:${APTHTTPPORT} unstable InRelease
404 Not Found
-Hit:2 http://localhost:8080 unstable Release
-Ign:3 http://localhost:8080 unstable Release.gpg
+Hit:2 http://localhost:${APTHTTPPORT} unstable Release
+Ign:3 http://localhost:${APTHTTPPORT} unstable Release.gpg
404 Not Found
Reading package lists...
-W: The data from 'http://localhost:8080 unstable Release' is not signed. Packages from that repository can not be authenticated."
+W: The data from 'http://localhost:${APTHTTPPORT} unstable Release' is not signed. Packages from that repository can not be authenticated."
find aptarchive -name 'Release.gpg' -delete
echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
runtest 'warning'
@@ -96,20 +96,20 @@ Valid-Until: $(date -d '-1 weeks' '+%a, %d %b %Y %H:%M:%S %Z')" '{}' \;
signreleasefiles
msgmsg 'expired InRelease'
-EXPECT='Hit:1 http://localhost:8080 unstable InRelease
+EXPECT="Hit:1 http://localhost:${APTHTTPPORT} unstable InRelease
Reading package lists...
-E: Release file for http://localhost:8080/dists/unstable/InRelease is expired (invalid since). Updates for this repository will not be applied.'
+E: Release file for http://localhost:${APTHTTPPORT}/dists/unstable/InRelease is expired (invalid since). Updates for this repository will not be applied."
echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
runtest 'failure'
echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
runtest 'failure'
msgmsg 'expired Release/Release.gpg'
-EXPECT='Ign:1 http://localhost:8080 unstable InRelease
+EXPECT="Ign:1 http://localhost:${APTHTTPPORT} unstable InRelease
404 Not Found
-Hit:2 http://localhost:8080 unstable Release
+Hit:2 http://localhost:${APTHTTPPORT} unstable Release
Reading package lists...
-E: Release file for http://localhost:8080/dists/unstable/Release is expired (invalid since). Updates for this repository will not be applied.'
+E: Release file for http://localhost:${APTHTTPPORT}/dists/unstable/Release is expired (invalid since). Updates for this repository will not be applied."
find aptarchive -name 'InRelease' -delete
echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
runtest 'failure'
@@ -117,14 +117,14 @@ echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
runtest 'failure'
msgmsg 'expired Release only'
-EXPECT="Ign:1 http://localhost:8080 unstable InRelease
+EXPECT="Ign:1 http://localhost:${APTHTTPPORT} unstable InRelease
404 Not Found
-Hit:2 http://localhost:8080 unstable Release
-Ign:3 http://localhost:8080 unstable Release.gpg
+Hit:2 http://localhost:${APTHTTPPORT} unstable Release
+Ign:3 http://localhost:${APTHTTPPORT} unstable Release.gpg
404 Not Found
Reading package lists...
-W: The data from 'http://localhost:8080 unstable Release' is not signed. Packages from that repository can not be authenticated.
-E: Release file for http://localhost:8080/dists/unstable/Release is expired (invalid since). Updates for this repository will not be applied."
+W: The data from 'http://localhost:${APTHTTPPORT} unstable Release' is not signed. Packages from that repository can not be authenticated.
+E: Release file for http://localhost:${APTHTTPPORT}/dists/unstable/Release is expired (invalid since). Updates for this repository will not be applied."
find aptarchive -name 'Release.gpg' -delete
echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
runtest 'failure' 'warning'
@@ -133,33 +133,33 @@ runtest 'failure' 'warning'
msgmsg 'no Release at all'
-EXPECT="Ign:1 http://localhost:8080 unstable InRelease
+EXPECT="Ign:1 http://localhost:${APTHTTPPORT} unstable InRelease
404 Not Found
-Ign:2 http://localhost:8080 unstable Release
+Ign:2 http://localhost:${APTHTTPPORT} unstable Release
404 Not Found
-Ign:3 http://localhost:8080 unstable/main Sources
+Ign:3 http://localhost:${APTHTTPPORT} unstable/main Sources
404 Not Found
-Ign:4 http://localhost:8080 unstable/main amd64 Packages
+Ign:4 http://localhost:${APTHTTPPORT} unstable/main amd64 Packages
404 Not Found
-Ign:5 http://localhost:8080 unstable/main Translation-en
+Ign:5 http://localhost:${APTHTTPPORT} unstable/main Translation-en
404 Not Found
-Ign:3 http://localhost:8080 unstable/main Sources
+Ign:3 http://localhost:${APTHTTPPORT} unstable/main Sources
404 Not Found
-Ign:4 http://localhost:8080 unstable/main amd64 Packages
+Ign:4 http://localhost:${APTHTTPPORT} unstable/main amd64 Packages
404 Not Found
-Ign:5 http://localhost:8080 unstable/main Translation-en
+Ign:5 http://localhost:${APTHTTPPORT} unstable/main Translation-en
404 Not Found
-Ign:3 http://localhost:8080 unstable/main Sources
+Ign:3 http://localhost:${APTHTTPPORT} unstable/main Sources
404 Not Found
-Ign:4 http://localhost:8080 unstable/main amd64 Packages
+Ign:4 http://localhost:${APTHTTPPORT} unstable/main amd64 Packages
404 Not Found
-Ign:5 http://localhost:8080 unstable/main Translation-en
+Ign:5 http://localhost:${APTHTTPPORT} unstable/main Translation-en
404 Not Found
-Hit:3 http://localhost:8080 unstable/main Sources
-Hit:4 http://localhost:8080 unstable/main amd64 Packages
-Hit:5 http://localhost:8080 unstable/main Translation-en
+Hit:3 http://localhost:${APTHTTPPORT} unstable/main Sources
+Hit:4 http://localhost:${APTHTTPPORT} unstable/main amd64 Packages
+Hit:5 http://localhost:${APTHTTPPORT} unstable/main Translation-en
Reading package lists...
-W: The repository 'http://localhost:8080 unstable Release' does not have a Release file. This is deprecated, please contact the owner of the repository."
+W: The repository 'http://localhost:${APTHTTPPORT} unstable Release' does not have a Release file. This is deprecated, please contact the owner of the repository."
find aptarchive -name '*Release*' -delete
echo 'Acquire::GzipIndexes "0";
Acquire::PDiffs "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
diff --git a/test/integration/test-apt-update-not-modified b/test/integration/test-apt-update-not-modified
index 8c580245a..8cfc766d3 100755
--- a/test/integration/test-apt-update-not-modified
+++ b/test/integration/test-apt-update-not-modified
@@ -155,7 +155,7 @@ Reading package lists..." aptget update
}
changetowebserver
-methodtest 'http://localhost:8080'
+methodtest "http://localhost:${APTHTTPPORT}"
changetohttpswebserver
-methodtest 'https://localhost:4433'
+methodtest "https://localhost:${APTHTTPSPORT}"
diff --git a/test/integration/test-apt-update-stale b/test/integration/test-apt-update-stale
index 8a2703fd1..dd4799d95 100755
--- a/test/integration/test-apt-update-stale
+++ b/test/integration/test-apt-update-stale
@@ -39,6 +39,6 @@ cp -p aptarchive/dists/unstable/main/binary-i386/saved/Packages* \
aptarchive/dists/unstable/main/binary-i386/
# ensure this raises an error
-testfailuremsg "W: Failed to fetch copy:$(readlink -f ./rootdir)/var/lib/apt/lists/localhost:8080_dists_unstable_main_binary-i386_Packages Hash Sum mismatch
+testfailuremsg "W: Failed to fetch copy:$(readlink -f ./rootdir)/var/lib/apt/lists/localhost:${APTHTTPPORT}_dists_unstable_main_binary-i386_Packages Hash Sum mismatch
E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update -o Debug::pkgAcquire::Worker=1 -o Debug::Acquire::http=1
testfileequal lists.before "$(listcurrentlistsdirectory)"
diff --git a/test/integration/test-authentication-basic b/test/integration/test-authentication-basic
index 3a6897b59..e6dfc0272 100755
--- a/test/integration/test-authentication-basic
+++ b/test/integration/test-authentication-basic
@@ -83,24 +83,24 @@ password hunter2'
}
msgmsg 'server basic auth'
-rewritesourceslist 'http://localhost:8080'
-runtest 'http://localhost:8080'
-rewritesourceslist 'https://localhost:4433'
-runtest 'https://localhost:4433'
-rewritesourceslist 'http://localhost:8080'
+rewritesourceslist "http://localhost:${APTHTTPPORT}"
+runtest "http://localhost:${APTHTTPPORT}"
+rewritesourceslist "https://localhost:${APTHTTPSPORT}"
+runtest "https://localhost:${APTHTTPSPORT}"
+rewritesourceslist "http://localhost:${APTHTTPPORT}"
msgmsg 'proxy to server basic auth'
webserverconfig 'aptwebserver::request::absolute' 'uri'
-export http_proxy='http://localhost:8080'
-runtest 'http://localhost:8080'
+export http_proxy="http://localhost:${APTHTTPPORT}"
+runtest "http://localhost:${APTHTTPPORT}"
unset http_proxy
msgmsg 'proxy basic auth to server basic auth'
webserverconfig 'aptwebserver::proxy-authorization' "$(printf 'moon:deer2' | base64)"
-export http_proxy='http://moon:deer2@localhost:8080'
-runtest 'http://localhost:8080'
+export http_proxy="http://moon:deer2@localhost:${APTHTTPPORT}"
+runtest "http://localhost:${APTHTTPPORT}"
msgmsg 'proxy basic auth to server'
authfile ''
webserverconfig 'aptwebserver::authorization' ''
-testauthsuccess 'http://localhost:8080'
+testauthsuccess "http://localhost:${APTHTTPPORT}"
diff --git a/test/integration/test-bug-595691-empty-and-broken-archive-files b/test/integration/test-bug-595691-empty-and-broken-archive-files
index f73dfdd68..57e3c3dcf 100755
--- a/test/integration/test-bug-595691-empty-and-broken-archive-files
+++ b/test/integration/test-bug-595691-empty-and-broken-archive-files
@@ -63,16 +63,16 @@ testoverhttp() {
forcecompressor "$1"
createemptyarchive 'Packages'
- testaptgetupdate "Get:2 http://localhost:8080 Packages []
+ testaptgetupdate "Get:2 http://localhost:${APTHTTPPORT} Packages []
Reading package lists..." "empty archive Packages.$COMPRESS over http"
createemptyfile 'Packages'
#FIXME: we should response with a good error message instead
- testaptgetupdate "Get:2 http://localhost:8080 Packages
-Err:2 http://localhost:8080 Packages
+ testaptgetupdate "Get:2 http://localhost:${APTHTTPPORT} Packages
+Err:2 http://localhost:${APTHTTPPORT} Packages
Empty files can't be valid archives
Reading package lists...
-W: Failed to fetch ${COMPRESSOR}:$(readlink -f rootdir/var/lib/apt/lists/partial/localhost:8080_Packages.${COMPRESS}) Empty files can't be valid archives
+W: Failed to fetch ${COMPRESSOR}:$(readlink -f rootdir/var/lib/apt/lists/partial/localhost:${APTHTTPPORT}_Packages.${COMPRESS}) Empty files can't be valid archives
E: Some index files failed to download. They have been ignored, or old ones used instead." "empty file Packages.$COMPRESS over http"
}
diff --git a/test/integration/test-bug-602412-dequote-redirect b/test/integration/test-bug-602412-dequote-redirect
index b9d232f90..e90fd240b 100755
--- a/test/integration/test-bug-602412-dequote-redirect
+++ b/test/integration/test-bug-602412-dequote-redirect
@@ -28,9 +28,9 @@ Reading package lists..." aptget update
testsuccess --nomsg aptget install unrelated --download-only -y
}
-testrun 'http://localhost:8080'
+testrun "http://localhost:${APTHTTPPORT}"
rm -rf rootdir/var/lib/apt/lists rootdir/var/cache/apt/archives
changetohttpswebserver
-testrun 'https://localhost:4433'
+testrun "https://localhost:${APTHTTPSPORT}"
diff --git a/test/integration/test-bug-624218-Translation-file-handling b/test/integration/test-bug-624218-Translation-file-handling
index 3987abff1..af9134da3 100755
--- a/test/integration/test-bug-624218-Translation-file-handling
+++ b/test/integration/test-bug-624218-Translation-file-handling
@@ -89,7 +89,7 @@ testfailure grep -q -e 'Translation' rootdir/tmp/testwarning.output
rm -rf rootdir/var/lib/apt/lists
mkdir -p rootdir/var/lib/apt/lists
-touch rootdir/var/lib/apt/lists/localhost:8080_dists_unstable_main_i18n_Translation-ast_DE
+touch rootdir/var/lib/apt/lists/localhost:${APTHTTPPORT}_dists_unstable_main_i18n_Translation-ast_DE
msgtest 'Download of builtin files' 'without Index'
testwarning --nomsg aptget update
@@ -97,7 +97,7 @@ testsuccess grep -q -e 'Translation-ast_DE' rootdir/tmp/testwarning.output
rm -rf rootdir/var/lib/apt/lists
mkdir -p rootdir/var/lib/apt/lists
-touch rootdir/var/lib/apt/lists/localhost:8080_dists_unstable_main_i18n_Translation-ast_DE
+touch rootdir/var/lib/apt/lists/localhost:${APTHTTPPORT}_dists_unstable_main_i18n_Translation-ast_DE
msgtest 'Download of nothing (even builtin) if none is forced' 'without Index'
testwarning --nomsg aptget update -o Acquire::Languages=none
diff --git a/test/integration/test-bug-717891-abolute-uris-for-proxies b/test/integration/test-bug-717891-abolute-uris-for-proxies
index ef948c2d5..d30dd5d4e 100755
--- a/test/integration/test-bug-717891-abolute-uris-for-proxies
+++ b/test/integration/test-bug-717891-abolute-uris-for-proxies
@@ -14,7 +14,7 @@ changetowebserver --request-absolute='uri'
msgtest 'Check that absolute paths are' 'not accepted'
testfailure --nomsg aptget update --allow-insecure-repositories
-echo 'Acquire::http::Proxy "http://localhost:8080";' > rootdir/etc/apt/apt.conf.d/99proxy
+echo "Acquire::http::Proxy \"http://localhost:${APTHTTPPORT}\";" > rootdir/etc/apt/apt.conf.d/99proxy
msgtest 'Check that requests to proxies are' 'absolute uris'
testsuccess --nomsg aptget update
diff --git a/test/integration/test-bug-738785-switch-protocol b/test/integration/test-bug-738785-switch-protocol
index d925a70bb..23578d85a 100755
--- a/test/integration/test-bug-738785-switch-protocol
+++ b/test/integration/test-bug-738785-switch-protocol
@@ -12,19 +12,18 @@ buildsimplenativepackage 'apt' 'all' '1.0' 'stable'
# setup http redirecting to https
getlabelfromsuite() { echo 'Testcases'; }
setupaptarchive --no-update
-changetowebserver -o 'aptwebserver::redirect::replace::/redirectme/=https://localhost:4433/' \
- -o 'aptwebserver::redirect::replace::/downgrademe/=http://localhost:8080/' \
- -o 'aptwebserver::support::http=false'
-changetohttpswebserver
-sed -i -e 's#:4433/#:8080/redirectme#' -e 's# https:# http:#' rootdir/etc/apt/sources.list.d/*
+changetohttpswebserver -o 'aptwebserver::support::http=false'
+webserverconfig 'aptwebserver::redirect::replace::/downgrademe/' "http://localhost:${APTHTTPPORT}/"
+webserverconfig 'aptwebserver::redirect::replace::/redirectme/' "https://localhost:${APTHTTPSPORT}/"
+sed -i -e "s#:${APTHTTPSPORT}/#:${APTHTTPPORT}/redirectme#" -e 's# https:# http:#' rootdir/etc/apt/sources.list.d/*
testsuccess aptget update -o Debug::Acquire::http=1 -o Debug::Acquire::https=1 -o Debug::pkgAcquire::Worker=1
msgtest 'Test that the webserver does not answer' 'http requests'
-downloadfile 'http://localhost:8080/pool/main/a/apt/apt_1.0/changelog' changelog >/dev/null 2>&1 && msgfail || msgpass
+downloadfile "http://localhost:${APTHTTPPORT}/pool/main/a/apt/apt_1.0/changelog" changelog >/dev/null 2>&1 && msgfail || msgpass
-echo 'Acquire::Changelogs::URI::Label::Testcases "http://localhost:8080/redirectme/pool/CHANGEPATH/changelog";' > rootdir/etc/apt/apt.conf.d/changelog.conf
-testsuccessequal "'http://localhost:8080/redirectme/pool/main/a/apt/apt_1.0/changelog' apt.changelog" aptget changelog apt --print-uris
+echo "Acquire::Changelogs::URI::Label::Testcases \"http://localhost:${APTHTTPPORT}/redirectme/pool/CHANGEPATH/changelog\";" > rootdir/etc/apt/apt.conf.d/changelog.conf
+testsuccessequal "'http://localhost:${APTHTTPPORT}/redirectme/pool/main/a/apt/apt_1.0/changelog' apt.changelog" aptget changelog apt --print-uris
cd downloaded
testsuccess aptget changelog apt -d
@@ -63,5 +62,5 @@ ln -s "$OLDMETHODS/https" "$NEWMETHODS"
# check that downgrades from https to http are not allowed
webserverconfig 'aptwebserver::support::http' 'true'
-sed -i -e 's#:8080/redirectme#:4433/downgrademe#' -e 's# http:# https:#' rootdir/etc/apt/sources.list.d/*
+sed -i -e "s#:${APTHTTPPORT}/redirectme#:${APTHTTPSPORT}/downgrademe#" -e 's# http:# https:#' rootdir/etc/apt/sources.list.d/*
testfailure aptget update --allow-insecure-repositories
diff --git a/test/integration/test-bug-778375-server-has-no-reason-phrase b/test/integration/test-bug-778375-server-has-no-reason-phrase
index 23481ef88..a44920cbe 100755
--- a/test/integration/test-bug-778375-server-has-no-reason-phrase
+++ b/test/integration/test-bug-778375-server-has-no-reason-phrase
@@ -36,5 +36,5 @@ runtest() {
testdownload 'non-existent file via redirect fails' 'testfailure' "$1/redirectme/failing"
}
-runtest 'http://localhost:8080'
-runtest 'https://localhost:4433'
+runtest "http://localhost:${APTHTTPPORT}"
+runtest "https://localhost:${APTHTTPSPORT}"
diff --git a/test/integration/test-bug-lp1445239-download-loop b/test/integration/test-bug-lp1445239-download-loop
index 4e4de67bd..6629e823d 100755
--- a/test/integration/test-bug-lp1445239-download-loop
+++ b/test/integration/test-bug-lp1445239-download-loop
@@ -21,7 +21,7 @@ DOWNLOADLOG='rootdir/tmp/testdownloadfile.log'
TARGET=./downloaded/testfile-downloaded
dd if=/dev/zero of=$TARGET bs=99k count=1 2>/dev/null
-if ! downloadfile http://localhost:8080/testfile "$TARGET" > "$DOWNLOADLOG"; then
+if ! downloadfile http://localhost:${APTHTTPPORT}/testfile "$TARGET" > "$DOWNLOADLOG"; then
cat >&2 "$DOWNLOADLOG"
msgfail
else
diff --git a/test/integration/test-cve-2013-1051-InRelease-parsing b/test/integration/test-cve-2013-1051-InRelease-parsing
index a503ad0fe..7a3e5f156 100755
--- a/test/integration/test-cve-2013-1051-InRelease-parsing
+++ b/test/integration/test-cve-2013-1051-InRelease-parsing
@@ -12,7 +12,7 @@ insertpackage 'stable' 'good-pkg' 'all' '1.0'
setupaptarchive
changetowebserver
-ARCHIVE='http://localhost:8080'
+ARCHIVE="http://localhost:${APTHTTPPORT}"
msgtest 'Initial apt-get update should work with' 'InRelease'
testsuccess --nomsg aptget update
@@ -45,7 +45,7 @@ touch -d '+1hour' aptarchive/dists/stable/InRelease
# part of the InRelease
listcurrentlistsdirectory | sed '/_InRelease/ d' > listsdir.lst
msgtest 'apt-get update should ignore unsigned data in the' 'InRelease'
-testsuccessequal "Get:1 http://localhost:8080 stable InRelease [$(stat -c%s aptarchive/dists/stable/InRelease) B]
+testsuccessequal "Get:1 http://localhost:${APTHTTPPORT} stable InRelease [$(stat -c%s aptarchive/dists/stable/InRelease) B]
Reading package lists..." --nomsg aptget update
testfileequal './listsdir.lst' "$(listcurrentlistsdirectory | sed '/_InRelease/ d')"
diff --git a/test/integration/test-handle-redirect-as-used-mirror-change b/test/integration/test-handle-redirect-as-used-mirror-change
index 08a39a5e6..a1842462a 100755
--- a/test/integration/test-handle-redirect-as-used-mirror-change
+++ b/test/integration/test-handle-redirect-as-used-mirror-change
@@ -10,14 +10,15 @@ configcompression '.' 'gz'
buildsimplenativepackage 'unrelated' 'all' '0.5~squeeze1' 'unstable'
setupaptarchive --no-update
-changetowebserver -o 'aptwebserver::redirect::replace::/redirectme/=http://0.0.0.0:8080/'
-rewritesourceslist 'http://localhost:8080/redirectme'
+changetowebserver
+webserverconfig 'aptwebserver::redirect::replace::/redirectme/' "http://0.0.0.0:${APTHTTPPORT}/"
+rewritesourceslist "http://localhost:${APTHTTPPORT}/redirectme"
-testsuccessequal "Get:1 http://0.0.0.0:8080 unstable InRelease [$(stat -c %s aptarchive/dists/unstable/InRelease) B]
-Get:2 http://0.0.0.0:8080 unstable/main Sources [$(stat -c %s aptarchive/dists/unstable/main/source/Sources.gz) B]
-Get:3 http://0.0.0.0:8080 unstable/main amd64 Packages [$(stat -c %s aptarchive/dists/unstable/main/binary-amd64/Packages.gz) B]
-Get:4 http://0.0.0.0:8080 unstable/main Translation-en [$(stat -c %s aptarchive/dists/unstable/main/i18n/Translation-en.gz) B]
+testsuccessequal "Get:1 http://0.0.0.0:${APTHTTPPORT} unstable InRelease [$(stat -c %s aptarchive/dists/unstable/InRelease) B]
+Get:2 http://0.0.0.0:${APTHTTPPORT} unstable/main Sources [$(stat -c %s aptarchive/dists/unstable/main/source/Sources.gz) B]
+Get:3 http://0.0.0.0:${APTHTTPPORT} unstable/main amd64 Packages [$(stat -c %s aptarchive/dists/unstable/main/binary-amd64/Packages.gz) B]
+Get:4 http://0.0.0.0:${APTHTTPPORT} unstable/main Translation-en [$(stat -c %s aptarchive/dists/unstable/main/i18n/Translation-en.gz) B]
Reading package lists..." aptget update
-testsuccessequal 'Hit:1 http://0.0.0.0:8080 unstable InRelease
-Reading package lists...' aptget update
+testsuccessequal "Hit:1 http://0.0.0.0:${APTHTTPPORT} unstable InRelease
+Reading package lists..." aptget update
diff --git a/test/integration/test-partial-file-support b/test/integration/test-partial-file-support
index c07af7bd0..5b05b277e 100755
--- a/test/integration/test-partial-file-support
+++ b/test/integration/test-partial-file-support
@@ -141,8 +141,8 @@ serverconfigs() {
testrun "$1"
}
-serverconfigs 'http://localhost:8080'
+serverconfigs "http://localhost:${APTHTTPPORT}"
changetohttpswebserver
-serverconfigs 'https://localhost:4433'
+serverconfigs "https://localhost:${APTHTTPSPORT}"
diff --git a/test/integration/test-releasefile-verification b/test/integration/test-releasefile-verification
index c5b9f147f..ba1df1a01 100755
--- a/test/integration/test-releasefile-verification
+++ b/test/integration/test-releasefile-verification
@@ -33,7 +33,7 @@ prepare() {
}
installaptold() {
- testsuccessequal 'Reading package lists...
+ testsuccessequal "Reading package lists...
Building dependency tree...
Suggested packages:
aptitude | synaptic | wajig dpkg-dev apt-doc bzip2 lzma python-apt
@@ -41,12 +41,12 @@ The following NEW packages will be installed:
apt
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
After this operation, 5370 kB of additional disk space will be used.
-Get:1 http://localhost:8080 apt 0.7.25.3
-Download complete and in download only mode' aptget install apt -dy
+Get:1 http://localhost:${APTHTTPPORT} apt 0.7.25.3
+Download complete and in download only mode" aptget install apt -dy
}
installaptnew() {
- testsuccessequal 'Reading package lists...
+ testsuccessequal "Reading package lists...
Building dependency tree...
Suggested packages:
aptitude | synaptic | wajig dpkg-dev apt-doc bzip2 lzma python-apt
@@ -54,8 +54,8 @@ The following NEW packages will be installed:
apt
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
After this operation, 5808 kB of additional disk space will be used.
-Get:1 http://localhost:8080 apt 0.8.0~pre1
-Download complete and in download only mode' aptget install apt -dy
+Get:1 http://localhost:${APTHTTPPORT} apt 0.8.0~pre1
+Download complete and in download only mode" aptget install apt -dy
}
failaptold() {
diff --git a/test/integration/test-ubuntu-bug-1098738-apt-get-source-md5sum b/test/integration/test-ubuntu-bug-1098738-apt-get-source-md5sum
index f286f5650..f32d74ad7 100755
--- a/test/integration/test-ubuntu-bug-1098738-apt-get-source-md5sum
+++ b/test/integration/test-ubuntu-bug-1098738-apt-get-source-md5sum
@@ -158,8 +158,8 @@ testok() {
testsuccessequal "Reading package lists...
Building dependency tree...
Need to get 6 B of source archives.
-Get:1 http://localhost:8080 $1 1.0 (dsc) [3 B]
-Get:2 http://localhost:8080 $1 1.0 (tar) [3 B]
+Get:1 http://localhost:${APTHTTPPORT} $1 1.0 (dsc) [3 B]
+Get:2 http://localhost:${APTHTTPPORT} $1 1.0 (tar) [3 B]
Download complete and in download only mode" aptget source -d "$@"
msgtest 'Files were successfully downloaded for' "$1"
testsuccess --nomsg test -e ${1}_1.0.dsc -a -e ${1}_1.0.tar.gz
@@ -198,15 +198,15 @@ testmismatch() {
testfailureequal "Reading package lists...
Building dependency tree...
Need to get 6 B of source archives.
-Get:1 http://localhost:8080 $1 1.0 (dsc) [3 B]
-Err:1 http://localhost:8080 $1 1.0 (dsc)
+Get:1 http://localhost:${APTHTTPPORT} $1 1.0 (dsc) [3 B]
+Err:1 http://localhost:${APTHTTPPORT} $1 1.0 (dsc)
Hash Sum mismatch
-Get:2 http://localhost:8080 $1 1.0 (tar) [3 B]
-Err:2 http://localhost:8080 $1 1.0 (tar)
+Get:2 http://localhost:${APTHTTPPORT} $1 1.0 (tar) [3 B]
+Err:2 http://localhost:${APTHTTPPORT} $1 1.0 (tar)
Hash Sum mismatch
-E: Failed to fetch http://localhost:8080/${1}_1.0.dsc Hash Sum mismatch
+E: Failed to fetch http://localhost:${APTHTTPPORT}/${1}_1.0.dsc Hash Sum mismatch
-E: Failed to fetch http://localhost:8080/${1}_1.0.tar.gz Hash Sum mismatch
+E: Failed to fetch http://localhost:${APTHTTPPORT}/${1}_1.0.tar.gz Hash Sum mismatch
E: Failed to fetch some archives." aptget source -d "$@"
msgtest 'Files were not download as they have hashsum mismatches for' "$1"
@@ -228,8 +228,8 @@ Download complete and in download only mode" aptget source -d "$@" -o Acquire::F
testsuccessequal "Reading package lists...
Building dependency tree...
Need to get 6 B of source archives.
-Get:1 http://localhost:8080 $1 1.0 (dsc) [3 B]
-Get:2 http://localhost:8080 $1 1.0 (tar) [3 B]
+Get:1 http://localhost:${APTHTTPPORT} $1 1.0 (dsc) [3 B]
+Get:2 http://localhost:${APTHTTPPORT} $1 1.0 (tar) [3 B]
Download complete and in download only mode" aptget source --allow-unauthenticated -d "$@" -o Acquire::ForceHash=ROT26
msgtest 'Files were downloaded unauthenticated as user allowed it' "$1"
testsuccess --nomsg test -e ${1}_1.0.dsc -a -e ${1}_1.0.tar.gz
@@ -263,28 +263,28 @@ testfailure --nomsg test -e pkg-no-md5_1.0.dsc -a -e pkg-no-md5_1.0.tar.gz
# deal with cases in which we haven't for all files the same checksum type
# mostly pathologic as this shouldn't happen, but just to be sure
testok pkg-mixed-ok
-testfailureequal 'Reading package lists...
+testfailureequal "Reading package lists...
Building dependency tree...
Need to get 6 B of source archives.
-Get:1 http://localhost:8080 pkg-mixed-sha1-bad 1.0 (tar) [3 B]
-Get:2 http://localhost:8080 pkg-mixed-sha1-bad 1.0 (dsc) [3 B]
-Err:2 http://localhost:8080 pkg-mixed-sha1-bad 1.0 (dsc)
+Get:1 http://localhost:${APTHTTPPORT} pkg-mixed-sha1-bad 1.0 (tar) [3 B]
+Get:2 http://localhost:${APTHTTPPORT} pkg-mixed-sha1-bad 1.0 (dsc) [3 B]
+Err:2 http://localhost:${APTHTTPPORT} pkg-mixed-sha1-bad 1.0 (dsc)
Hash Sum mismatch
-E: Failed to fetch http://localhost:8080/pkg-mixed-sha1-bad_1.0.dsc Hash Sum mismatch
+E: Failed to fetch http://localhost:${APTHTTPPORT}/pkg-mixed-sha1-bad_1.0.dsc Hash Sum mismatch
-E: Failed to fetch some archives.' aptget source -d pkg-mixed-sha1-bad
+E: Failed to fetch some archives." aptget source -d pkg-mixed-sha1-bad
msgtest 'Only tar file is downloaded as the dsc has hashsum mismatch' 'pkg-mixed-sha1-bad'
testsuccess --nomsg test ! -e pkg-mixed-sha1-bad_1.0.dsc -a -e pkg-mixed-sha1-bad_1.0.tar.gz
-testfailureequal 'Reading package lists...
+testfailureequal "Reading package lists...
Building dependency tree...
Need to get 6 B of source archives.
-Get:1 http://localhost:8080 pkg-mixed-sha2-bad 1.0 (tar) [3 B]
-Err:1 http://localhost:8080 pkg-mixed-sha2-bad 1.0 (tar)
+Get:1 http://localhost:${APTHTTPPORT} pkg-mixed-sha2-bad 1.0 (tar) [3 B]
+Err:1 http://localhost:${APTHTTPPORT} pkg-mixed-sha2-bad 1.0 (tar)
Hash Sum mismatch
-Get:2 http://localhost:8080 pkg-mixed-sha2-bad 1.0 (dsc) [3 B]
-E: Failed to fetch http://localhost:8080/pkg-mixed-sha2-bad_1.0.tar.gz Hash Sum mismatch
+Get:2 http://localhost:${APTHTTPPORT} pkg-mixed-sha2-bad 1.0 (dsc) [3 B]
+E: Failed to fetch http://localhost:${APTHTTPPORT}/pkg-mixed-sha2-bad_1.0.tar.gz Hash Sum mismatch
-E: Failed to fetch some archives.' aptget source -d pkg-mixed-sha2-bad
+E: Failed to fetch some archives." aptget source -d pkg-mixed-sha2-bad
msgtest 'Only dsc file is downloaded as the tar has hashsum mismatch' 'pkg-mixed-sha2-bad'
testsuccess --nomsg test -e pkg-mixed-sha2-bad_1.0.dsc -a ! -e pkg-mixed-sha2-bad_1.0.tar.gz
diff --git a/test/integration/test-ubuntu-bug-346386-apt-get-update-paywall b/test/integration/test-ubuntu-bug-346386-apt-get-update-paywall
index 6ce6b5216..983889f92 100755
--- a/test/integration/test-ubuntu-bug-346386-apt-get-update-paywall
+++ b/test/integration/test-ubuntu-bug-346386-apt-get-update-paywall
@@ -16,7 +16,7 @@ setupaptarchive
changetowebserver -o 'aptwebserver::overwrite::.*::filename=/knights'
msgtest 'Acquire test file from the webserver to check' 'overwrite'
-if downloadfile http://localhost:8080/holygrail ./knights-talking >/dev/null; then
+if downloadfile http://localhost:${APTHTTPPORT}/holygrail ./knights-talking >/dev/null; then
msgpass
else
msgfail
@@ -45,8 +45,8 @@ partial' ls "$LISTS"
# and again with pre-existing files with "valid data" which should remain
for f in Release Release.gpg main_binary-amd64_Packages main_source_Sources; do
- echo 'peng neee-wom' > "$LISTS/localhost:8080_dists_stable_${f}"
- chmod 644 "$LISTS/localhost:8080_dists_stable_${f}"
+ echo 'peng neee-wom' > "$LISTS/localhost:${APTHTTPPORT}_dists_stable_${f}"
+ chmod 644 "$LISTS/localhost:${APTHTTPPORT}_dists_stable_${f}"
done
testfailure aptget update
@@ -56,9 +56,9 @@ ensure_n_canary_strings_in_dir "$LISTS" 'peng neee-wom' 4
ensure_n_canary_strings_in_dir "$LISTS" 'ni ni ni' 0
# and now with a pre-existing InRelease file
-echo 'peng neee-wom' > "$LISTS/localhost:8080_dists_stable_InRelease"
-chmod 644 "$LISTS/localhost:8080_dists_stable_InRelease"
-rm -f "$LISTS/localhost:8080_dists_stable_Release" "$LISTS/localhost:8080_dists_stable_Release.gpg"
+echo 'peng neee-wom' > "$LISTS/localhost:${APTHTTPPORT}_dists_stable_InRelease"
+chmod 644 "$LISTS/localhost:${APTHTTPPORT}_dists_stable_InRelease"
+rm -f "$LISTS/localhost:${APTHTTPPORT}_dists_stable_Release" "$LISTS/localhost:${APTHTTPPORT}_dists_stable_Release.gpg"
msgtest 'excpected failure of' 'apt-get update'
testfailure aptget update
testsuccess grep '^W:.*Clearsigned file .*NOSPLIT.*' rootdir/tmp/testfailure.output
diff --git a/test/interactive-helper/aptwebserver.cc b/test/interactive-helper/aptwebserver.cc
index 411da0e8f..849323cc0 100644
--- a/test/interactive-helper/aptwebserver.cc
+++ b/test/interactive-helper/aptwebserver.cc
@@ -256,7 +256,10 @@ static void sendRedirect(int const client, int const httpcode, std::string const
if (strncmp(uri.c_str(), "http://", 7) != 0 && strncmp(uri.c_str(), "https://", 8) != 0)
{
std::string const host = LookupTag(request, "Host");
- if (host.find(":4433") != std::string::npos)
+ unsigned int const httpsport = _config->FindI("aptwebserver::port::https", 4433);
+ std::string hosthttpsport;
+ strprintf(hosthttpsport, ":%u", httpsport);
+ if (host.find(hosthttpsport) != std::string::npos)
location.append("https://");
else
location.append("http://");
@@ -681,8 +684,11 @@ static void * handleClient(void * voidclient) /*{{{*/
}
// deal with the request
+ unsigned int const httpsport = _config->FindI("aptwebserver::port::https", 4433);
+ std::string hosthttpsport;
+ strprintf(hosthttpsport, ":%u", httpsport);
if (_config->FindB("aptwebserver::support::http", true) == false &&
- LookupTag(*m, "Host").find(":4433") == std::string::npos)
+ LookupTag(*m, "Host").find(hosthttpsport) == std::string::npos)
{
sendError(client, 400, *m, sendContent, "HTTP disabled, all requests must be HTTPS", headers);
continue;
@@ -824,7 +830,7 @@ int main(int const argc, const char * argv[])
return 1;
}
- int const port = _config->FindI("aptwebserver::port", 8080);
+ int port = _config->FindI("aptwebserver::port", 8080);
// ensure that we accept all connections: v4 or v6
int const iponly = 0;
@@ -846,6 +852,26 @@ int main(int const argc, const char * argv[])
return 2;
}
+ if (port == 0)
+ {
+ struct sockaddr_in6 addr;
+ socklen_t addrlen = sizeof(sockaddr_in6);
+ if (getsockname(sock, (struct sockaddr*) &addr, &addrlen) != 0)
+ _error->Errno("getsockname", "Could not get chosen port number");
+ else
+ port = ntohs(addr.sin6_port);
+ }
+ std::string const portfilename = _config->Find("aptwebserver::portfile", "");
+ if (portfilename.empty() == false)
+ {
+ FileFd portfile(portfilename, FileFd::WriteOnly | FileFd::Create | FileFd::Empty);
+ std::string portcontent;
+ strprintf(portcontent, "%d", port);
+ portfile.Write(portcontent.c_str(), portcontent.size());
+ portfile.Sync();
+ }
+ _config->Set("aptwebserver::port::http", port);
+
FileFd pidfile;
if (_config->FindB("aptwebserver::fork", false) == true)
{
@@ -871,6 +897,7 @@ int main(int const argc, const char * argv[])
std::string pidcontent;
strprintf(pidcontent, "%d", child);
pidfile.Write(pidcontent.c_str(), pidcontent.size());
+ pidfile.Sync();
if (_error->PendingError() == true)
{
_error->DumpErrors(std::cerr);