diff options
author | Michael Vogt <michael.vogt@ubuntu.com> | 2013-01-31 06:27:20 +0100 |
---|---|---|
committer | Michael Vogt <michael.vogt@ubuntu.com> | 2013-01-31 06:27:20 +0100 |
commit | 30c54ac89ce01b93b42a9a37d3edd9837d0f34bb (patch) | |
tree | 6b30bbb4addefc0061c5a74593ae3b2332a3001a /test | |
parent | 64680d3bf12db6599e93f950546e380e0bd5ddf4 (diff) |
test/integration/test-debsrc-hashes: add integration test, thanks to Daniel Hartwig
Diffstat (limited to 'test')
-rwxr-xr-x | test/integration/test-debsrc-hashes | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/test/integration/test-debsrc-hashes b/test/integration/test-debsrc-hashes new file mode 100755 index 000000000..5e917232b --- /dev/null +++ b/test/integration/test-debsrc-hashes @@ -0,0 +1,77 @@ +#!/bin/sh +set -e + +TESTDIR=$(readlink -f $(dirname $0)) +. $TESTDIR/framework + +setupenvironment +configarchitecture "i386" + +# pkg-sha256-bad has a bad SHA sum, but good MD5 sum. If apt is +# checking the best available hash (as it should), this will trigger +# a hash mismatch. + +cat > aptarchive/Sources <<EOF +Package: pkg-md5-ok +Binary: pkg-md5-ok +Version: 1.0 +Maintainer: Joe Sixpack <joe@example.org> +Architecture: i386 +Files: + d41d8cd98f00b204e9800998ecf8427e 0 pkg-md5-ok_1.0.dsc + d41d8cd98f00b204e9800998ecf8427e 0 pkg-md5-ok_1.0.tar.gz + +Package: pkg-sha256-ok +Binary: pkg-sha256-ok +Version: 1.0 +Maintainer: Joe Sixpack <joe@example.org> +Architecture: i386 +Files: + d41d8cd98f00b204e9800998ecf8427e 0 pkg-sha256-ok_1.0.dsc + d41d8cd98f00b204e9800998ecf8427e 0 pkg-sha256-ok_1.0.tar.gz +Checksums-Sha1: + da39a3ee5e6b4b0d3255bfef95601890afd80709 0 pkg-sha256-ok_1.0.dsc + da39a3ee5e6b4b0d3255bfef95601890afd80709 0 pkg-sha256-ok_1.0.tar.gz +Checksums-Sha256: + e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 0 pkg-sha256-ok_1.0.dsc + e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 0 pkg-sha256-ok_1.0.tar.gz + +Package: pkg-sha256-bad +Binary: pkg-sha256-bad +Version: 1.0 +Maintainer: Joe Sixpack <joe@example.org> +Architecture: i386 +Files: + d41d8cd98f00b204e9800998ecf8427e 0 pkg-sha256-bad_1.0.dsc + d41d8cd98f00b204e9800998ecf8427e 0 pkg-sha256-bad_1.0.tar.gz +Checksums-Sha1: + da39a3ee5e6b4b0d3255bfef95601890afd80709 0 pkg-sha256-bad_1.0.dsc + da39a3ee5e6b4b0d3255bfef95601890afd80709 0 pkg-sha256-bad_1.0.tar.gz +Checksums-Sha256: + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 0 pkg-sha256-bad_1.0.dsc + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 0 pkg-sha256-bad_1.0.tar.gz +EOF + +# create fetchable files +for x in "pkg-md5-ok" "pkg-sha256-ok" "pkg-sha256-bad"; do + touch aptarchive/${x}_1.0.dsc + touch aptarchive/${x}_1.0.tar.gz +done + +testok() { + msgtest "Test for hash ok of" "$*" + $* 2>&1 | grep "Download complete" > /dev/null && msgpass || msgfail +} + +testmismatch() { + msgtest "Test for hash mismatch of" "$*" + $* 2>&1 | grep "Hash Sum mismatch" > /dev/null && msgpass || msgfail +} + +setupaptarchive +changetowebserver +aptget update -qq + +testok aptget source -d pkg-md5-ok +testok aptget source -d pkg-sha256-ok +testmismatch aptget source -d pkg-sha256-bad |