]> git.saurik.com Git - apt.git/blame - test/integration/test-hashsum-verification
* apt-pkg/packagemanager.cc, apt-pkg/pkgcache.cc:
[apt.git] / test / integration / test-hashsum-verification
CommitLineData
515d18c9
MV
1#!/bin/sh
2set -e
3
4TESTDIR=$(readlink -f $(dirname $0))
5. $TESTDIR/framework
6
7setupenvironment
8configarchitecture "i386"
9
10buildaptarchive
11setupflataptarchive
12changetowebserver
13
14prepare() {
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 # create Release file with incorret checksums
30 cat > aptarchive/Release <<EOF
31Date: Fri, 05 Aug 2011 09:22:08 UTC
32MD5Sum:
33 x15c483ac486f5dbe95095c7ec08626f 760 Packages
34 x0579797df4792164a17305fb0b317e9 546 Packages.bz2
35 xc532a82873d2206b4e4503e92d167bd 489 Packages.gz
36 x4d1d25661377dd4bb95a1736e2624d3 527 Packages.lzma
37 xf1cc221194edbaa943d2375d6f44a88 572 Packages.xz
38SHA1:
39 x0d3317839cf68cd40c28f0bddca8d2ce5a29cad 760 Packages
40 xffddf046ad8dfd8338a355d76fb08d143c8b636 546 Packages.bz2
41 xa27a3df51ca4474b880a6594c4811957079b613 489 Packages.gz
42 x9d7bba4e6fa927a34dcd797694c2893c21f1004 527 Packages.lzma
43 x7d988fe59cf67298828e5299a15d329c0f00f1b 572 Packages.xz
44SHA256:
45 x5a47d72f6b97bfa164b23326b6ad3cb019b5c6cc73769f8c0187616933d1b2b 760 Packages
46 x617252f5bfe3e9126352c7c2f8122d9c3b2c5e1a6c8a9616d62adc0ed164172 546 Packages.bz2
47 xc6abc6fe9a4fcf0758ec5366dfd19bcba90af026a7017c3f6198c59eccd8ef5 489 Packages.gz
48 xb306e66e5e6a7169c8d281a888539d1fdca9cecc99ae605717df579d5b9c166 527 Packages.lzma
49 x9585d0e66b74c9385727fbea11fea9ab33c716b18a32f3036f037a2b9b57120 572 Packages.xz
50EOF
51 cp aptarchive/Release aptarchive/InRelease
52}
53
54# fake our downloadable file
55touch aptarchive/apt.deb
56
57PKGFILE="${TESTDIR}/$(echo "$(basename $0)" | sed 's#^test-#Packages-#')"
58
59runtest() {
60 prepare ${PKGFILE}
61 rm -rf rootdir/var/lib/apt/lists
62 signreleasefiles 'Joe Sixpack'
63 find aptarchive/ -name "$DELETEFILE" -delete
64
65 # test signed release file
66 msgtest 'apt-get update gets the expected hashsum mismatch'
67 aptget update 2>&1 | grep "Hash Sum mismatch" > /dev/null && msgpass || msgfail
68 msgtest 'No package from the source available'
69 [ "$(aptcache show apt 2>&1)" = "E: No packages found" ] && msgpass || msgfail
70 msgtest 'No Packages file in /var/lib/apt/lists'
71 [ "$(ls rootdir/var/lib/apt/lists/*Package* 2>/dev/null)" = "" ] && msgpass || msgfail
72
3568a640
MV
73 # now with the unsigned Release file
74 rm -rf rootdir/var/lib/apt/lists
75 rm aptarchive/InRelease aptarchive/Release.gpg
76 msgtest 'unsigned apt-get update gets the expected hashsum mismatch'
77 aptget update 2>&1 | grep "Hash Sum mismatch" > /dev/null && msgpass || msgfail
78
79
515d18c9
MV
80}
81
82runtest
83