summaryrefslogtreecommitdiff
path: root/test/integration/test-debsrc-hashes
blob: 5e917232b3b8097847395e6228a6e27c1f1f7c98 (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
#!/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