]> git.saurik.com Git - apt.git/blame - test/integration/test-bug-617690-allow-unauthenticated-makes-all-untrusted
generalize secure->insecure downgrade protection
[apt.git] / test / integration / test-bug-617690-allow-unauthenticated-makes-all-untrusted
CommitLineData
6c34ccca
DK
1#!/bin/sh
2set -e
3
3abb6a6a
DK
4TESTDIR="$(readlink -f "$(dirname "$0")")"
5. "$TESTDIR/framework"
6c34ccca
DK
6setupenvironment
7configarchitecture 'i386'
8
9buildsimplenativepackage 'cool' 'i386' '1.0' 'unstable'
10
11setupaptarchive --no-update
12
13testfileexists() {
1e3f4083 14 msgtest 'Test for existence of file' "$1"
6c34ccca
DK
15 test -e "$1" && msgpass || msgfail
16 rm -f "$1"
17}
18
19testfilemissing() {
8d89cda7 20 msgtest 'Test for non-existence of file' "$1"
6c34ccca
DK
21 test -e "$1" && msgfail || msgpass
22 rm -f "$1"
23}
24
25testrun() {
26 rm -rf rootdir/var/lib/apt
03aa0847 27 cd downloaded
6c34ccca 28
d57f6084 29 if [ "$1" = 'trusted' ]; then
c99fe2e1 30 testsuccess aptget update
e1bd768b 31
d57f6084
DK
32 testsuccess aptget download cool
33 testfileexists 'cool_1.0_i386.deb'
34
35 testsuccess aptget download cool --allow-unauthenticated
36 testfileexists 'cool_1.0_i386.deb'
37 else
4fa34122 38 testwarning aptget update --allow-insecure-repositories
e1bd768b 39
d57f6084
DK
40 testfailure aptget download cool
41 testfilemissing 'cool_1.0_i386.deb'
42
43 testsuccess aptget download cool --allow-unauthenticated
44 testfileexists 'cool_1.0_i386.deb'
45 fi
6c34ccca 46
03aa0847
DK
47 mv ../aptarchive/pool/cool_1.0_i386.deb ../aptarchive/pool/cool_1.0_i386.deb.bak
48 echo 'this is not a good package' > ../aptarchive/pool/cool_1.0_i386.deb
d57f6084 49 testfailure aptget download cool
6c34ccca
DK
50 testfilemissing cool_1.0_i386.deb
51
d57f6084 52 testfailure aptget download cool --allow-unauthenticated # unauthenticated doesn't mean unchecked
6c34ccca
DK
53 testfilemissing cool_1.0_i386.deb
54
03aa0847
DK
55 rm -f ../aptarchive/pool/cool_1.0_i386.deb
56 mv ../aptarchive/pool/cool_1.0_i386.deb.bak ../aptarchive/pool/cool_1.0_i386.deb
6c34ccca
DK
57 testsuccess aptget download cool --allow-unauthenticated
58 testfileexists 'cool_1.0_i386.deb'
03aa0847 59 cd - >/dev/null
6c34ccca
DK
60}
61
d57f6084 62testrun 'trusted'
6c34ccca
DK
63
64find aptarchive/ \( -name 'Release.gpg' -o -name 'InRelease' \) -delete
d57f6084
DK
65testrun 'untrusted'
66
67changetowebserver
68testrun 'untrusted'