summaryrefslogtreecommitdiff
path: root/test/integration/test-apt-update-not-modified
blob: bac33d5318c0b533ed6ffe2c3ed49e3e5800599a (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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/bin/sh
set -e

TESTDIR=$(readlink -f $(dirname $0))
. $TESTDIR/framework

setupenvironment
configarchitecture 'amd64' 'i386'

insertpackage 'unstable' 'apt' 'all' '1.0'

setupaptarchive --no-update

methodtest() {
	msgmsg 'Test InRelease with' "$1"
	rm -rf rootdir/var/lib/apt/lists
	cp -a aptarchive/dists  aptarchive/dists.good
	# get our cache populated
	testsuccess aptget update
	listcurrentlistsdirectory > listsdir.lst

	# hit again with a good cache
	testsuccessequal "Hit $1 unstable InRelease
Reading package lists..." aptget update
	testfileequal 'listsdir.lst' "$(listcurrentlistsdirectory)"

	# drop an architecture, which means the file should be gone now
	configarchitecture 'i386'
	sed '/_binary-amd64_Packages/ d' listsdir.lst > listsdir-without-amd64.lst
	testsuccessequal "Hit $1 unstable InRelease
Reading package lists..." aptget update
	testfileequal 'listsdir-without-amd64.lst' "$(listcurrentlistsdirectory)"

	# readd arch so its downloaded again…
	configarchitecture 'amd64' 'i386'
	# … but oh noes, hashsum mismatch!
	find aptarchive/dists/unstable/main/binary-amd64/ -type f -delete
	cat >> aptarchive/dists/unstable/main/binary-amd64/Packages <<EOF

Package: thisisbad
Architecture: amd64
Version: 1
EOF
	compressfile aptarchive/dists/unstable/main/binary-amd64/Packages
	testfailureequal "Hit $1 unstable InRelease
Get:1 $1 unstable/main amd64 Packages [$(stat -c '%s' 'aptarchive/dists.good/unstable/main/binary-amd64/Packages.gz') B]
W: Failed to fetch $1/dists/unstable/main/binary-amd64/Packages.gz  Hash Sum mismatch

E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update
	testfileequal 'listsdir-without-amd64.lst' "$(listcurrentlistsdirectory)"
	rm -rf aptarchive/dists
	cp -a aptarchive/dists.good aptarchive/dists

	# … now everything is fine again
	testsuccessequal "Hit $1 unstable InRelease
Get:1 $1 unstable/main amd64 Packages [$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz') B]
Reading package lists..." aptget update
	testfileequal 'listsdir.lst' "$(listcurrentlistsdirectory)"

	webserverconfig 'aptwebserver::support::modified-since' 'false'
	webserverconfig 'aptwebserver::support::last-modified' 'false'
	testsuccessequal "Get:1 $1 unstable InRelease [$(stat -c '%s' 'aptarchive/dists/unstable/InRelease') B]
Reading package lists..." aptget update
	webserverconfig 'aptwebserver::support::modified-since' 'true'
	webserverconfig 'aptwebserver::support::last-modified' 'true'

	msgmsg 'Test Release.gpg with' "$1"
	rm -rf rootdir/var/lib/apt/lists
	find aptarchive/dists -name 'InRelease' -delete
	# get our cache populated
	testsuccess aptget update
	listcurrentlistsdirectory > listsdir.lst

	# hit again with a good cache
	testsuccessequal "Ign $1 unstable InRelease
  404  Not Found
Hit $1 unstable Release
Reading package lists..." aptget update
	testfileequal 'listsdir.lst' "$(listcurrentlistsdirectory)"

	# drop an architecture, which means the file should be gone now
	configarchitecture 'i386'
	sed '/_binary-amd64_Packages/ d' listsdir.lst > listsdir-without-amd64.lst
	testsuccessequal "Ign $1 unstable InRelease
  404  Not Found
Hit $1 unstable Release
Reading package lists..." aptget update
	testfileequal 'listsdir-without-amd64.lst' "$(listcurrentlistsdirectory)"

	# readd arch so its downloaded again
	configarchitecture 'amd64' 'i386'
	testsuccessequal "Ign $1 unstable InRelease
  404  Not Found
Hit $1 unstable Release
Get:1 $1 unstable/main amd64 Packages [$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz') B]
Reading package lists..." aptget update
	testfileequal 'listsdir.lst' "$(listcurrentlistsdirectory)"

	webserverconfig 'aptwebserver::support::modified-since' 'false'
	webserverconfig 'aptwebserver::support::last-modified' 'false'
	testsuccessequal "Ign $1 unstable InRelease
  404  Not Found
Get:1 $1 unstable Release [$(stat -c '%s' 'aptarchive/dists/unstable/Release') B]
Reading package lists..." aptget update
	webserverconfig 'aptwebserver::support::modified-since' 'true'
	webserverconfig 'aptwebserver::support::last-modified' 'true'

	rm -rf aptarchive/dists
	cp -a aptarchive/dists.good aptarchive/dists
}

changetowebserver
methodtest 'http://localhost:8080'

changetohttpswebserver
methodtest 'https://localhost:4433'