diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/integration/Packages-hashsum-verification | 18 | ||||
-rwxr-xr-x | test/integration/test-hashsum-verification | 83 | ||||
-rw-r--r-- | test/libapt/assert.h | 8 | ||||
-rw-r--r-- | test/libapt/getarchitectures_test.cc | 7 | ||||
-rw-r--r-- | test/libapt/getlanguages_test.cc | 7 | ||||
-rw-r--r-- | test/libapt/getlistoffilesindir_test.cc | 7 | ||||
-rw-r--r-- | test/test_udevcdrom.cc | 2 |
7 files changed, 110 insertions, 22 deletions
diff --git a/test/integration/Packages-hashsum-verification b/test/integration/Packages-hashsum-verification new file mode 100644 index 000000000..29a385f4f --- /dev/null +++ b/test/integration/Packages-hashsum-verification @@ -0,0 +1,18 @@ +Package: apt +Version: 0.7.25.3 +Architecture: i386 +Maintainer: APT Development Team <deity@lists.debian.org> +Installed-Size: 5244 +Replaces: libapt-pkg-dev (<< 0.3.7), libapt-pkg-doc (<< 0.3.7) +Provides: libapt-pkg-libc6.9-6-4.8 +Suggests: aptitude | synaptic | wajig, dpkg-dev, apt-doc, bzip2, lzma, python-apt +Filename: apt.deb +Size: 0 +MD5sum: d41d8cd98f00b204e9800998ecf8427e +Description: Advanced front-end for dpkg + This is Debian's next generation front-end for the dpkg package manager. + It provides the apt-get utility and APT dselect method that provides a + simpler, safer way to install and upgrade packages. + . + APT features complete installation ordering, multiple source capability + and several other unique features, see the Users Guide in apt-doc. diff --git a/test/integration/test-hashsum-verification b/test/integration/test-hashsum-verification new file mode 100755 index 000000000..033096ee8 --- /dev/null +++ b/test/integration/test-hashsum-verification @@ -0,0 +1,83 @@ +#!/bin/sh +set -e + +TESTDIR=$(readlink -f $(dirname $0)) +. $TESTDIR/framework + +setupenvironment +configarchitecture "i386" + +buildaptarchive +setupflataptarchive +changetowebserver + +prepare() { + local DATE="${2:-now}" + if [ "$DATE" = 'now' -a "$1" = "${PKGFILE}-new" ]; then + DATE='now + 6 days' + fi + for release in $(find rootdir/var/lib/apt/lists 2> /dev/null); do + touch -d 'now - 6 hours' $release + done + rm -rf rootdir/var/cache/apt/archives + rm -f rootdir/var/cache/apt/*.bin + cp $1 aptarchive/Packages + find aptarchive -name 'Release' -delete + cat aptarchive/Packages | gzip > aptarchive/Packages.gz + cat aptarchive/Packages | bzip2 > aptarchive/Packages.bz2 + cat aptarchive/Packages | lzma > aptarchive/Packages.lzma + # create Release file with incorret checksums + cat > aptarchive/Release <<EOF +Date: Fri, 05 Aug 2011 09:22:08 UTC +MD5Sum: + x15c483ac486f5dbe95095c7ec08626f 760 Packages + x0579797df4792164a17305fb0b317e9 546 Packages.bz2 + xc532a82873d2206b4e4503e92d167bd 489 Packages.gz + x4d1d25661377dd4bb95a1736e2624d3 527 Packages.lzma + xf1cc221194edbaa943d2375d6f44a88 572 Packages.xz +SHA1: + x0d3317839cf68cd40c28f0bddca8d2ce5a29cad 760 Packages + xffddf046ad8dfd8338a355d76fb08d143c8b636 546 Packages.bz2 + xa27a3df51ca4474b880a6594c4811957079b613 489 Packages.gz + x9d7bba4e6fa927a34dcd797694c2893c21f1004 527 Packages.lzma + x7d988fe59cf67298828e5299a15d329c0f00f1b 572 Packages.xz +SHA256: + x5a47d72f6b97bfa164b23326b6ad3cb019b5c6cc73769f8c0187616933d1b2b 760 Packages + x617252f5bfe3e9126352c7c2f8122d9c3b2c5e1a6c8a9616d62adc0ed164172 546 Packages.bz2 + xc6abc6fe9a4fcf0758ec5366dfd19bcba90af026a7017c3f6198c59eccd8ef5 489 Packages.gz + xb306e66e5e6a7169c8d281a888539d1fdca9cecc99ae605717df579d5b9c166 527 Packages.lzma + x9585d0e66b74c9385727fbea11fea9ab33c716b18a32f3036f037a2b9b57120 572 Packages.xz +EOF + cp aptarchive/Release aptarchive/InRelease +} + +# fake our downloadable file +touch aptarchive/apt.deb + +PKGFILE="${TESTDIR}/$(echo "$(basename $0)" | sed 's#^test-#Packages-#')" + +runtest() { + prepare ${PKGFILE} + rm -rf rootdir/var/lib/apt/lists + signreleasefiles 'Joe Sixpack' + find aptarchive/ -name "$DELETEFILE" -delete + + # test signed release file + msgtest 'apt-get update gets the expected hashsum mismatch' + aptget update 2>&1 | grep "Hash Sum mismatch" > /dev/null && msgpass || msgfail + msgtest 'No package from the source available' + [ "$(aptcache show apt 2>&1)" = "E: No packages found" ] && msgpass || msgfail + msgtest 'No Packages file in /var/lib/apt/lists' + [ "$(ls rootdir/var/lib/apt/lists/*Package* 2>/dev/null)" = "" ] && msgpass || msgfail + + # now with the unsigned Release file + rm -rf rootdir/var/lib/apt/lists + rm aptarchive/InRelease aptarchive/Release.gpg + msgtest 'unsigned apt-get update gets the expected hashsum mismatch' + aptget update 2>&1 | grep "Hash Sum mismatch" > /dev/null && msgpass || msgfail + + +} + +runtest + diff --git a/test/libapt/assert.h b/test/libapt/assert.h index 92b662dfa..fae9b6c64 100644 --- a/test/libapt/assert.h +++ b/test/libapt/assert.h @@ -53,3 +53,11 @@ void assertEqualsOr2(int const &expect1, int const &expect2, unsigned int const assertEqualsOr2<unsigned int const&, unsigned int const&>(expect1, expect2, get, line); } + +// simple helper to quickly output a vectors +template < typename X > +void dumpVector(X vec) { + for (typename X::const_iterator v = vec.begin(); + v != vec.end(); ++v) + std::cout << *v << std::endl; +} diff --git a/test/libapt/getarchitectures_test.cc b/test/libapt/getarchitectures_test.cc index e3ca7bbc2..807469263 100644 --- a/test/libapt/getarchitectures_test.cc +++ b/test/libapt/getarchitectures_test.cc @@ -7,13 +7,6 @@ #include <iostream> -// simple helper to quickly output a vector of strings -void dumpVector(std::vector<std::string> vec) { - for (std::vector<std::string>::const_iterator v = vec.begin(); - v != vec.end(); v++) - std::cout << *v << std::endl; -} - int main(int argc,char *argv[]) { std::vector<std::string> vec; diff --git a/test/libapt/getlanguages_test.cc b/test/libapt/getlanguages_test.cc index 3d63e0e74..f6aa7a697 100644 --- a/test/libapt/getlanguages_test.cc +++ b/test/libapt/getlanguages_test.cc @@ -7,13 +7,6 @@ #include <iostream> -// simple helper to quickly output a vector of strings -void dumpVector(std::vector<std::string> vec) { - for (std::vector<std::string>::const_iterator v = vec.begin(); - v != vec.end(); v++) - std::cout << *v << std::endl; -} - int main(int argc,char *argv[]) { if (argc != 2) { diff --git a/test/libapt/getlistoffilesindir_test.cc b/test/libapt/getlistoffilesindir_test.cc index ed8d2dad6..5ee014cca 100644 --- a/test/libapt/getlistoffilesindir_test.cc +++ b/test/libapt/getlistoffilesindir_test.cc @@ -7,13 +7,6 @@ #include <stdio.h> #include <iostream> -// simple helper to quickly output a vector of strings -void dumpVector(std::vector<std::string> vec) { - for (std::vector<std::string>::const_iterator v = vec.begin(); - v != vec.end(); v++) - std::cout << *v << std::endl; -} - #define P(x) string(argv[1]).append("/").append(x) int main(int argc,char *argv[]) diff --git a/test/test_udevcdrom.cc b/test/test_udevcdrom.cc index e65c7a297..577e2d013 100644 --- a/test/test_udevcdrom.cc +++ b/test/test_udevcdrom.cc @@ -10,7 +10,7 @@ int main() vector<CdromDevice> l; l = c.Scan(); - assert(l.size() > 0); + assert(l.empty() == false); for (i=0;i<l.size();i++) std::cerr << l[i].DeviceName << " " << l[i].Mounted << " " |