]> git.saurik.com Git - apt.git/blame - test/integration/test-bug-738785-switch-protocol
deprecate confusing Pkg.CandVersion() method
[apt.git] / test / integration / test-bug-738785-switch-protocol
CommitLineData
9082a1fc
DK
1#!/bin/sh
2set -e
3
3abb6a6a
DK
4TESTDIR="$(readlink -f "$(dirname "$0")")"
5. "$TESTDIR/framework"
9082a1fc
DK
6
7setupenvironment
8configarchitecture "i386"
9
10buildsimplenativepackage 'apt' 'all' '1.0' 'stable'
11
12# setup http redirecting to https
d56e2917 13getlabelfromsuite() { echo 'Testcases'; }
9082a1fc 14setupaptarchive --no-update
6c0765c0
DK
15changetohttpswebserver -o 'aptwebserver::support::http=false'
16webserverconfig 'aptwebserver::redirect::replace::/downgrademe/' "http://localhost:${APTHTTPPORT}/"
17webserverconfig 'aptwebserver::redirect::replace::/redirectme/' "https://localhost:${APTHTTPSPORT}/"
18sed -i -e "s#:${APTHTTPSPORT}/#:${APTHTTPPORT}/redirectme#" -e 's# https:# http:#' rootdir/etc/apt/sources.list.d/*
9082a1fc
DK
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'
6c0765c0 23downloadfile "http://localhost:${APTHTTPPORT}/pool/main/a/apt/apt_1.0/changelog" changelog >/dev/null 2>&1 && msgfail || msgpass
9082a1fc 24
430481e7 25echo "Acquire::Changelogs::URI::Label::Testcases \"http://localhost:${APTHTTPPORT}/redirectme/pool/@CHANGEPATH@/changelog\";" > rootdir/etc/apt/apt.conf.d/changelog.conf
6c0765c0 26testsuccessequal "'http://localhost:${APTHTTPPORT}/redirectme/pool/main/a/apt/apt_1.0/changelog' apt.changelog" aptget changelog apt --print-uris
9082a1fc 27
03aa0847 28cd downloaded
9082a1fc
DK
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
03aa0847 36cd - >/dev/null
9082a1fc
DK
37
38testsuccess aptget install apt -y
39testdpkginstalled 'apt'
40
9d2a8a73
DK
41# install a slowed down file: otherwise its to fast to reproduce combining
42NEWMETHODS="$(readlink -f rootdir)/usr/lib/apt/methods"
43OLDMETHODS="$(readlink -f rootdir/usr/lib/apt/methods)"
63c71412
DK
44rm "$NEWMETHODS"
45mkdir "$NEWMETHODS"
46backupIFS="$IFS"
47IFS="$(printf "\n\b")"
48for METH in $(find "$OLDMETHODS" ! -type d); do
49 ln -s "$OLDMETHODS/$(basename "$METH")" "$NEWMETHODS"
9082a1fc 50done
63c71412
DK
51IFS="$backupIFS"
52rm "$NEWMETHODS/https"
9082a1fc 53
03aa0847 54cd downloaded
25b86db1 55testfailureequal "E: The method driver $(readlink -f './../')/rootdir/usr/lib/apt/methods/https could not be found.
87d6947d 56N: Is the package apt-transport-https installed?" aptget download apt
e52aad52 57testfailure test -e apt_1.0_all.deb
03aa0847 58cd - >/dev/null
889b0072
DK
59
60# revert to all methods
63c71412 61ln -s "$OLDMETHODS/https" "$NEWMETHODS"
889b0072
DK
62
63# check that downgrades from https to http are not allowed
64webserverconfig 'aptwebserver::support::http' 'true'
6c0765c0 65sed -i -e "s#:${APTHTTPPORT}/redirectme#:${APTHTTPSPORT}/downgrademe#" -e 's# http:# https:#' rootdir/etc/apt/sources.list.d/*
c99fe2e1 66testfailure aptget update --allow-insecure-repositories