]>
Commit | Line | Data |
---|---|---|
9082a1fc DK |
1 | #!/bin/sh |
2 | set -e | |
3 | ||
4 | TESTDIR=$(readlink -f $(dirname $0)) | |
5 | . $TESTDIR/framework | |
6 | ||
7 | setupenvironment | |
8 | configarchitecture "i386" | |
9 | ||
10 | buildsimplenativepackage 'apt' 'all' '1.0' 'stable' | |
11 | ||
12 | # setup http redirecting to https | |
d56e2917 | 13 | getlabelfromsuite() { echo 'Testcases'; } |
9082a1fc DK |
14 | setupaptarchive --no-update |
15 | changetowebserver -o 'aptwebserver::redirect::replace::/redirectme/=https://localhost:4433/' \ | |
889b0072 | 16 | -o 'aptwebserver::redirect::replace::/downgrademe/=http://localhost:8080/' \ |
9082a1fc DK |
17 | -o 'aptwebserver::support::http=false' |
18 | changetohttpswebserver | |
19 | sed -i -e 's#:4433/#:8080/redirectme#' -e 's# https:# http:#' rootdir/etc/apt/sources.list.d/* | |
20 | ||
21 | testsuccess aptget update -o Debug::Acquire::http=1 -o Debug::Acquire::https=1 -o Debug::pkgAcquire::Worker=1 | |
22 | ||
23 | msgtest 'Test that the webserver does not answer' 'http requests' | |
d56e2917 | 24 | downloadfile 'http://localhost:8080/pool/main/a/apt/apt_1.0/changelog' changelog >/dev/null 2>&1 && msgfail || msgpass |
9082a1fc | 25 | |
d56e2917 DK |
26 | echo 'Acquire::Changelogs::URI::Label::Testcases "http://localhost:8080/redirectme/pool/CHANGEPATH/changelog";' > rootdir/etc/apt/apt.conf.d/changelog.conf |
27 | testsuccessequal "'http://localhost:8080/redirectme/pool/main/a/apt/apt_1.0/changelog' apt.changelog" aptget changelog apt --print-uris | |
9082a1fc | 28 | |
03aa0847 | 29 | cd downloaded |
9082a1fc DK |
30 | testsuccess aptget changelog apt -d |
31 | testsuccess test -s apt.changelog | |
32 | rm -f apt.changelog | |
33 | ||
34 | testsuccess aptget download apt | |
35 | testsuccess test -s apt_1.0_all.deb | |
36 | rm apt_1.0_all.deb | |
03aa0847 | 37 | cd - >/dev/null |
9082a1fc DK |
38 | |
39 | testsuccess aptget install apt -y | |
40 | testdpkginstalled 'apt' | |
41 | ||
42 | # create a copy of all methods, expect https | |
43 | eval `aptconfig shell METHODS Dir::Bin::Methods/d` | |
44 | COPYMETHODS='usr/lib/apt/methods' | |
889b0072 | 45 | mv rootdir/${COPYMETHODS} rootdir/${COPYMETHODS}.bak |
9082a1fc DK |
46 | mkdir -p rootdir/$COPYMETHODS |
47 | cd rootdir/$COPYMETHODS | |
48 | find $METHODS \! -type d | while read meth; do | |
49 | ln -s $meth | |
50 | done | |
51 | rm https | |
52 | cd - >/dev/null | |
53 | echo "Dir::Bin::Methods \"${COPYMETHODS}\";" >> aptconfig.conf | |
54 | ||
03aa0847 | 55 | cd downloaded |
25b86db1 | 56 | testfailureequal "E: The method driver $(readlink -f './../')/rootdir/usr/lib/apt/methods/https could not be found. |
68ba0b7f | 57 | N: Is the package apt-transport-https installed?" aptget download apt -q=0 |
e52aad52 | 58 | testfailure test -e apt_1.0_all.deb |
03aa0847 | 59 | cd - >/dev/null |
889b0072 DK |
60 | |
61 | # revert to all methods | |
62 | rm -rf rootdir/$COPYMETHODS | |
63 | mv rootdir/${COPYMETHODS}.bak rootdir/${COPYMETHODS} | |
64 | ||
65 | # check that downgrades from https to http are not allowed | |
66 | webserverconfig 'aptwebserver::support::http' 'true' | |
67 | sed -i -e 's#:8080/redirectme#:4433/downgrademe#' -e 's# http:# https:#' rootdir/etc/apt/sources.list.d/* | |
c99fe2e1 | 68 | testfailure aptget update --allow-insecure-repositories |