]> git.saurik.com Git - apt.git/blame - test/integration/test-bug-738785-switch-protocol
fallback to well-known URI if by-hash fails
[apt.git] / test / integration / test-bug-738785-switch-protocol
CommitLineData
9082a1fc
DK
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
d56e2917 13getlabelfromsuite() { echo 'Testcases'; }
9082a1fc
DK
14setupaptarchive --no-update
15changetowebserver -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'
18changetohttpswebserver
19sed -i -e 's#:4433/#:8080/redirectme#' -e 's# https:# http:#' rootdir/etc/apt/sources.list.d/*
20
21testsuccess aptget update -o Debug::Acquire::http=1 -o Debug::Acquire::https=1 -o Debug::pkgAcquire::Worker=1
22
23msgtest 'Test that the webserver does not answer' 'http requests'
d56e2917 24downloadfile 'http://localhost:8080/pool/main/a/apt/apt_1.0/changelog' changelog >/dev/null 2>&1 && msgfail || msgpass
9082a1fc 25
d56e2917
DK
26echo 'Acquire::Changelogs::URI::Label::Testcases "http://localhost:8080/redirectme/pool/CHANGEPATH/changelog";' > rootdir/etc/apt/apt.conf.d/changelog.conf
27testsuccessequal "'http://localhost:8080/redirectme/pool/main/a/apt/apt_1.0/changelog' apt.changelog" aptget changelog apt --print-uris
9082a1fc 28
03aa0847 29cd downloaded
9082a1fc
DK
30testsuccess aptget changelog apt -d
31testsuccess test -s apt.changelog
32rm -f apt.changelog
33
34testsuccess aptget download apt
35testsuccess test -s apt_1.0_all.deb
36rm apt_1.0_all.deb
03aa0847 37cd - >/dev/null
9082a1fc
DK
38
39testsuccess aptget install apt -y
40testdpkginstalled 'apt'
41
9d2a8a73
DK
42# install a slowed down file: otherwise its to fast to reproduce combining
43NEWMETHODS="$(readlink -f rootdir)/usr/lib/apt/methods"
44OLDMETHODS="$(readlink -f rootdir/usr/lib/apt/methods)"
63c71412
DK
45rm "$NEWMETHODS"
46mkdir "$NEWMETHODS"
47backupIFS="$IFS"
48IFS="$(printf "\n\b")"
49for METH in $(find "$OLDMETHODS" ! -type d); do
50 ln -s "$OLDMETHODS/$(basename "$METH")" "$NEWMETHODS"
9082a1fc 51done
63c71412
DK
52IFS="$backupIFS"
53rm "$NEWMETHODS/https"
9082a1fc 54
03aa0847 55cd downloaded
25b86db1 56testfailureequal "E: The method driver $(readlink -f './../')/rootdir/usr/lib/apt/methods/https could not be found.
68ba0b7f 57N: Is the package apt-transport-https installed?" aptget download apt -q=0
e52aad52 58testfailure test -e apt_1.0_all.deb
03aa0847 59cd - >/dev/null
889b0072
DK
60
61# revert to all methods
63c71412 62ln -s "$OLDMETHODS/https" "$NEWMETHODS"
889b0072
DK
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/*
c99fe2e1 67testfailure aptget update --allow-insecure-repositories