summaryrefslogtreecommitdiff
path: root/test/integration/test-bug-617690-allow-unauthenticated-makes-all-untrusted
blob: 276e10564fcfbfcc54721859dc09ac5c16ed160f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/sh
set -e

TESTDIR=$(readlink -f $(dirname $0))
. $TESTDIR/framework
setupenvironment
configarchitecture 'i386'

buildsimplenativepackage 'cool' 'i386' '1.0' 'unstable'

setupaptarchive --no-update

testfileexists() {
	msgtest 'Test for existence of file' "$1"
	test -e "$1" && msgpass || msgfail
	rm -f "$1"
}

testfilemissing() {
	msgtest 'Test for non-existance of file' "$1"
	test -e "$1" && msgfail || msgpass
	rm -f "$1"
}

testrun() {
	rm -rf rootdir/var/lib/apt

	if [ "$1" = 'trusted' ]; then
	    testsuccess aptget update

		testsuccess aptget download cool
		testfileexists 'cool_1.0_i386.deb'

		testsuccess aptget download cool --allow-unauthenticated
		testfileexists 'cool_1.0_i386.deb'
	else
	    testsuccess aptget update --allow-unauthenticated

		testfailure aptget download cool
		testfilemissing 'cool_1.0_i386.deb'

		testsuccess aptget download cool --allow-unauthenticated
		testfileexists 'cool_1.0_i386.deb'
	fi

	mv aptarchive/pool/cool_1.0_i386.deb aptarchive/pool/cool_1.0_i386.deb.bak
	echo 'this is not a good package' > aptarchive/pool/cool_1.0_i386.deb
	testfailure aptget download cool
	testfilemissing cool_1.0_i386.deb

	testfailure aptget download cool --allow-unauthenticated  # unauthenticated doesn't mean unchecked
	testfilemissing cool_1.0_i386.deb

	rm -f aptarchive/pool/cool_1.0_i386.deb
	mv aptarchive/pool/cool_1.0_i386.deb.bak aptarchive/pool/cool_1.0_i386.deb
	testsuccess aptget download cool --allow-unauthenticated
	testfileexists 'cool_1.0_i386.deb'
}

testrun 'trusted'

find aptarchive/ \( -name 'Release.gpg' -o -name 'InRelease' \) -delete
testrun 'untrusted'

changetowebserver
testrun 'untrusted'