]> git.saurik.com Git - apt.git/blob - test/integration/test-releasefile-verification
* apt-pkg/packagemanager.cc, apt-pkg/pkgcache.cc:
[apt.git] / test / integration / test-releasefile-verification
1 #!/bin/sh
2 set -e
3
4 TESTDIR=$(readlink -f $(dirname $0))
5 . $TESTDIR/framework
6
7 setupenvironment
8 configarchitecture "i386"
9
10 buildaptarchive
11 setupflataptarchive
12 changetowebserver
13
14 prepare() {
15 local DATE="${2:-now}"
16 if [ "$DATE" = 'now' -a "$1" = "${PKGFILE}-new" ]; then
17 DATE='now + 6 days'
18 fi
19 for release in $(find rootdir/var/lib/apt/lists 2> /dev/null); do
20 touch -d 'now - 6 hours' $release
21 done
22 rm -rf rootdir/var/cache/apt/archives
23 rm -f rootdir/var/cache/apt/*.bin
24 cp $1 aptarchive/Packages
25 find aptarchive -name 'Release' -delete
26 cat aptarchive/Packages | gzip > aptarchive/Packages.gz
27 cat aptarchive/Packages | bzip2 > aptarchive/Packages.bz2
28 cat aptarchive/Packages | lzma > aptarchive/Packages.lzma
29 generatereleasefiles "$DATE"
30 }
31
32 installaptold() {
33 testequal 'Reading package lists...
34 Building dependency tree...
35 Suggested packages:
36 aptitude synaptic wajig dpkg-dev apt-doc bzip2 lzma python-apt
37 The following NEW packages will be installed:
38 apt
39 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
40 After this operation, 5370 kB of additional disk space will be used.
41 Get:1 http://localhost/ apt 0.7.25.3
42 Download complete and in download only mode' aptget install apt -dy
43 }
44
45 installaptnew() {
46 testequal 'Reading package lists...
47 Building dependency tree...
48 Suggested packages:
49 aptitude synaptic wajig dpkg-dev apt-doc bzip2 lzma python-apt
50 The following NEW packages will be installed:
51 apt
52 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
53 After this operation, 5808 kB of additional disk space will be used.
54 Get:1 http://localhost/ apt 0.8.0~pre1
55 Download complete and in download only mode' aptget install apt -dy
56 }
57
58 failaptold() {
59 testequal 'Reading package lists...
60 Building dependency tree...
61 Suggested packages:
62 aptitude synaptic wajig dpkg-dev apt-doc bzip2 lzma python-apt
63 The following NEW packages will be installed:
64 apt
65 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
66 After this operation, 5370 kB of additional disk space will be used.
67 WARNING: The following packages cannot be authenticated!
68 apt
69 E: There are problems and -y was used without --force-yes' aptget install apt -dy
70 }
71
72 failaptnew() {
73 testequal 'Reading package lists...
74 Building dependency tree...
75 Suggested packages:
76 aptitude synaptic wajig dpkg-dev apt-doc bzip2 lzma python-apt
77 The following NEW packages will be installed:
78 apt
79 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
80 After this operation, 5808 kB of additional disk space will be used.
81 WARNING: The following packages cannot be authenticated!
82 apt
83 E: There are problems and -y was used without --force-yes' aptget install apt -dy
84 }
85
86 # fake our downloadable file
87 touch aptarchive/apt.deb
88
89 PKGFILE="${TESTDIR}/$(echo "$(basename $0)" | sed 's#^test-#Packages-#')"
90
91 runtest() {
92 prepare ${PKGFILE}
93 rm -rf rootdir/var/lib/apt/lists
94 signreleasefiles 'Joe Sixpack'
95 find aptarchive/ -name "$DELETEFILE" -delete
96 msgtest 'Cold archive signed by' 'Joe Sixpack'
97 aptget update 2>&1 | grep -E '^(W|E): ' > /dev/null && msgfail || msgpass
98 testequal "$(cat ${PKGFILE})
99 " aptcache show apt
100 installaptold
101
102 prepare ${PKGFILE}-new
103 signreleasefiles 'Joe Sixpack'
104 find aptarchive/ -name "$DELETEFILE" -delete
105 msgtest 'Good warm archive signed by' 'Joe Sixpack'
106 aptget update 2>&1 | grep -E '^(W|E): ' > /dev/null && msgfail || msgpass
107 testequal "$(cat ${PKGFILE}-new)
108 " aptcache show apt
109 installaptnew
110
111
112 prepare ${PKGFILE}
113 rm -rf rootdir/var/lib/apt/lists
114 signreleasefiles 'Marvin Paranoid'
115 find aptarchive/ -name "$DELETEFILE" -delete
116 msgtest 'Cold archive signed by' 'Marvin Paranoid'
117 aptget update 2>&1 | grep -E '^(W|E): ' > /dev/null && msgpass || msgfail
118 testequal "$(cat ${PKGFILE})
119 " aptcache show apt
120 failaptold
121
122 prepare ${PKGFILE}-new
123 # weborf doesn't support If-Range
124 for release in $(find rootdir/var/lib/apt/lists/partial/ -name '*Release'); do
125 rm $release
126 touch $release
127 done
128 signreleasefiles 'Joe Sixpack'
129 find aptarchive/ -name "$DELETEFILE" -delete
130 msgtest 'Bad warm archive signed by' 'Joe Sixpack'
131 aptget update 2>&1 | grep -E '^(W|E): ' > /dev/null && msgfail || msgpass
132 testequal "$(cat ${PKGFILE}-new)
133 " aptcache show apt
134 installaptnew
135
136
137 prepare ${PKGFILE}
138 rm -rf rootdir/var/lib/apt/lists
139 signreleasefiles 'Joe Sixpack'
140 find aptarchive/ -name "$DELETEFILE" -delete
141 msgtest 'Cold archive signed by' 'Joe Sixpack'
142 aptget update 2>&1 | grep -E '^(W|E): ' > /dev/null && msgfail || msgpass
143 testequal "$(cat ${PKGFILE})
144 " aptcache show apt
145 installaptold
146
147 prepare ${PKGFILE}-new
148 signreleasefiles 'Marvin Paranoid'
149 find aptarchive/ -name "$DELETEFILE" -delete
150 msgtest 'Good warm archive signed by' 'Marvin Paranoid'
151 aptget update 2>&1 | grep -E '^(W|E): ' > /dev/null && msgpass || msgfail
152 testequal "$(cat ${PKGFILE})
153 " aptcache show apt
154 installaptold
155 }
156
157 DELETEFILE="InRelease"
158 runtest
159 DELETEFILE="Release.gpg"
160 runtest