]> git.saurik.com Git - apt.git/blob - test/integration/test-bug-738785-switch-protocol
allow http protocol to switch to https
[apt.git] / test / integration / test-bug-738785-switch-protocol
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
13 setupaptarchive --no-update
14 changetowebserver -o 'aptwebserver::redirect::replace::/redirectme/=https://localhost:4433/' \
15 -o 'aptwebserver::support::http=false'
16 changetohttpswebserver
17 sed -i -e 's#:4433/#:8080/redirectme#' -e 's# https:# http:#' rootdir/etc/apt/sources.list.d/*
18
19 testsuccess aptget update -o Debug::Acquire::http=1 -o Debug::Acquire::https=1 -o Debug::pkgAcquire::Worker=1
20
21 msgtest 'Test that the webserver does not answer' 'http requests'
22 downloadfile 'http://localhost:8080//pool/apt_1.0/changelog' >/dev/null 2>&1 && msgfail || msgpass
23
24 echo 'Apt::Changelogs::Server "http://localhost:8080/redirectme";' > rootdir/etc/apt/apt.conf.d/changelog.conf
25 testequal "'http://localhost:8080/redirectme/pool/apt_1.0/changelog'" aptget changelog apt --print-uris
26
27 testsuccess aptget changelog apt -d
28 testsuccess test -s apt.changelog
29 rm -f apt.changelog
30
31 testsuccess aptget download apt
32 testsuccess test -s apt_1.0_all.deb
33 rm apt_1.0_all.deb
34
35 testsuccess aptget install apt -y
36 testdpkginstalled 'apt'
37
38 # create a copy of all methods, expect https
39 eval `aptconfig shell METHODS Dir::Bin::Methods/d`
40 COPYMETHODS='usr/lib/apt/methods'
41 rm rootdir/$COPYMETHODS
42 mkdir -p rootdir/$COPYMETHODS
43 cd rootdir/$COPYMETHODS
44 find $METHODS \! -type d | while read meth; do
45 ln -s $meth
46 done
47 rm https
48 cd - >/dev/null
49 echo "Dir::Bin::Methods \"${COPYMETHODS}\";" >> aptconfig.conf
50
51 aptget download apt
52 testsuccess test ! -e apt_1.0_all.deb