]> git.saurik.com Git - apt.git/commitdiff
tests: don't use hardcoded port for http and https
authorDavid Kalnischkies <david@kalnischkies.de>
Mon, 14 Sep 2015 22:33:12 +0000 (00:33 +0200)
committerDavid Kalnischkies <david@kalnischkies.de>
Tue, 15 Sep 2015 08:16:09 +0000 (10:16 +0200)
This allows running tests in parallel.

Git-Dch: Ignore

29 files changed:
debian/tests/control
test/integration/framework
test/integration/test-acquire-same-file-multiple-times
test/integration/test-acquire-same-repository-multiple-times
test/integration/test-apt-acquire-additional-files
test/integration/test-apt-download-progress
test/integration/test-apt-get-changelog
test/integration/test-apt-helper
test/integration/test-apt-https-no-redirect
test/integration/test-apt-key-net-update
test/integration/test-apt-update-expected-size
test/integration/test-apt-update-ims
test/integration/test-apt-update-not-modified
test/integration/test-apt-update-stale
test/integration/test-authentication-basic
test/integration/test-bug-595691-empty-and-broken-archive-files
test/integration/test-bug-602412-dequote-redirect
test/integration/test-bug-624218-Translation-file-handling
test/integration/test-bug-717891-abolute-uris-for-proxies
test/integration/test-bug-738785-switch-protocol
test/integration/test-bug-778375-server-has-no-reason-phrase
test/integration/test-bug-lp1445239-download-loop
test/integration/test-cve-2013-1051-InRelease-parsing
test/integration/test-handle-redirect-as-used-mirror-change
test/integration/test-partial-file-support
test/integration/test-releasefile-verification
test/integration/test-ubuntu-bug-1098738-apt-get-source-md5sum
test/integration/test-ubuntu-bug-346386-apt-get-update-paywall
test/interactive-helper/aptwebserver.cc

index 0e774d4cac716bf5d2ef5c99bc247c6ef3b2c034..1042d93a8c635eac93777579d3f26d36b49589f3 100644 (file)
@@ -1,3 +1,3 @@
 Tests: run-tests
 Restrictions: allow-stderr
-Depends: @, @builddeps@, fakeroot, wget, stunnel4, db-util, gnupg, gnupg2
+Depends: @, @builddeps@, fakeroot, wget, stunnel4, lsof, db-util, gnupg, gnupg2
index 83f93217fb6cf813469a74af1167e3342601fd57..2fb924802ce8ab2f51cad548f1b303a778fe9624 100644 (file)
@@ -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"
index 255a71a33dd3389b2fcc7e938353aba2dfa9ce0e..354c683f2395bcef1d82bee13c2faec470837b7e 100755 (executable)
@@ -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
index 19a18cb63ca7de1603dd4c87f265f0564e2f25c5..b99496e354ddc96f0a0750bd92fe61e46a7e055e 100755 (executable)
@@ -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
index 6008c06957a0beda172a91ccf9fa23173107e9d0..4ba3c5bd969ee663339e863b14da7420475a044c 100755 (executable)
@@ -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*'
index bf6a412ad63d9240077197e3bd7e98748dfc71f9..64a122a06ab4397d3c7bdd51f79569ff2ed66bf7 100755 (executable)
@@ -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
index 502920617a7cac0a803f6f523b7258841b39dba7..1c0c45c61b266c2a8e2e475192294ec88a03fd9b 100755 (executable)
@@ -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
index 9444065801f78b6d41604f3c04d9e9ab29995091..b78201ef0fcb4f0454d335093eedef4102fb97a7 100755 (executable)
@@ -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}"
index c91c78916ee965eedad706df2f90d1800ad66fba..a29c0dacf8760d4a2397209783c801ea77f9a61b 100755 (executable)
@@ -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
index 2a0823becc4486c3532e4272d73152b6b12c6ce3..93c72dd5b36123c8d580d21a9ae51184b00fcce2 100755 (executable)
@@ -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
index 24ca8513325f2149425757d2ac079a9fe4e7b795..21568e9c28ef323218ad2d03007b8b44c57953e7 100755 (executable)
@@ -71,7 +71,7 @@ methodtest() {
 }
 
 changetowebserver
-methodtest 'http://localhost:8080'
+methodtest "http://localhost:${APTHTTPPORT}"
 
 changetohttpswebserver
-methodtest 'https://localhost:4433'
+methodtest "https://localhost:${APTHTTPSPORT}"
index 80ef28093bc1d9b71c559818bf303af48949808b..bc7a2b1bfa55582631147f260f074e9dc151b467 100755 (executable)
@@ -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
index 8c580245a41d9a28aaba9c411443fb9f799a8571..8cfc766d38bd0ca15f3e43bb323c081cea44fb32 100755 (executable)
@@ -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}"
index 8a2703fd1a4ef22223811af15dc3e865576a3dbf..dd4799d95fcf8a969f24433e62b647fa736fa06b 100755 (executable)
@@ -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)"
index 3a6897b5927b1e63b349176b265d2e19d4615c2f..e6dfc0272ecb4f01db3352e732561f3430ec8307 100755 (executable)
@@ -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}"
index f73dfdd688f3ff725e04706874d44ab4dbbd77e4..57e3c3dcf93b84c4170c70254987ff2aab5d205d 100755 (executable)
@@ -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"
 }
 
index b9d232f90bd608668ab40df84bd24e8c23b12e0d..e90fd240b6b90548e679681a0ef432e1aebd01b9 100755 (executable)
@@ -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}"
index 3987abff197c8f36b70972e632999903afb25aed..af9134da3eced55b07fbe561ed557aa7ea10f568 100755 (executable)
@@ -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
index ef948c2d5ee1f7cf97200a668fefbd8411eb8451..d30dd5d4ec66d9d822e30e43ac67ce2ef071f5a7 100755 (executable)
@@ -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
index d925a70bbe32b504e8eab1fd717e0e4c87978662..23578d85a7fa41f82435a1272e9f66b9b4e505fe 100755 (executable)
@@ -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
index 23481ef881a3df62624460395536e1d2fb965998..a44920cbeed90cc5c7e9a3431a37b6dfc6a3ce56 100755 (executable)
@@ -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}"
index 4e4de67bd34497d8fc4c347b685e7ca4a24181ee..6629e823d3b2d0baa1451384180e1b7a9c62ac40 100755 (executable)
@@ -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
index a503ad0fea82734e7ea8af0a99dad6f99ad94c4d..7a3e5f1569d5bd91cd1cc24f9d297061fe618394 100755 (executable)
@@ -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')"
 
index 08a39a5e63722b2d600debfff16fe8d99c24113c..a1842462a7c55f2a154c13ae2b58551ad153009e 100755 (executable)
@@ -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
index c07af7bd0f39484371cb14f513abdbd18b53a534..5b05b277e42dabce83070dbdcfff1c00a4687866 100755 (executable)
@@ -141,8 +141,8 @@ serverconfigs() {
        testrun "$1"
 }
 
-serverconfigs 'http://localhost:8080'
+serverconfigs "http://localhost:${APTHTTPPORT}"
 
 changetohttpswebserver
 
-serverconfigs 'https://localhost:4433'
+serverconfigs "https://localhost:${APTHTTPSPORT}"
index c5b9f147f58590dcda5a9ca4c0271a6fd1df0415..ba1df1a01119a6b52b7798347aa9ade3ce7a4ef9 100755 (executable)
@@ -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() {
index f286f5650434360d312541e74db0beb5806e282a..f32d74ad77aa8561b3a46099aacd2f9d0419ea87 100755 (executable)
@@ -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
 
index 6ce6b5216bd4b2007ed844fa156b6d26ac2ee539..983889f92651d90de824696e23bb29076e847dd6 100755 (executable)
@@ -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
index 411da0e8f93784fa4a3f39215c15aaa40980470b..849323cc0960ab6ba22956ba2ebf3a5184edecef 100644 (file)
@@ -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);