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