]> git.saurik.com Git - apt.git/commitdiff
tests: use SHA1 checksum only by default in tests
authorDavid Kalnischkies <david@kalnischkies.de>
Sun, 13 Sep 2015 15:25:23 +0000 (17:25 +0200)
committerDavid Kalnischkies <david@kalnischkies.de>
Mon, 14 Sep 2015 13:22:19 +0000 (15:22 +0200)
This is mostly a small speedup for the testcases, but it is also handy
to document which tests actually deal with a specific hash compared to
those which 'just' need some hash which can be important while adding
new hashes.

Git-Dch: Ignore

test/integration/framework
test/integration/test-apt-by-hash-update
test/integration/test-apt-ftparchive-by-hash
test/integration/test-apt-ftparchive-cachedb-lp1274466
test/integration/test-apt-ftparchive-src-cachedb
test/integration/test-apt-get-download
test/integration/test-apt-update-file
test/integration/test-pdiff-usage
test/integration/test-ubuntu-bug-1078697-missing-source-hashes

index 322c74a211923c374a4d9a52dc0b56e91994bb41..c830d852b1cc8602e24413adbd12c2d81d8a979e 100644 (file)
@@ -368,6 +368,7 @@ EOF
        echo "Acquire::https::CaInfo \"${TMPWORKINGDIRECTORY}/rootdir/etc/webserver.pem\";" > rootdir/etc/apt/apt.conf.d/99https
        echo "Apt::Cmd::Disable-Script-Warning \"1\";" > rootdir/etc/apt/apt.conf.d/apt-binary
        configcompression '.' 'gz' #'bz2' 'lzma' 'xz'
        echo "Acquire::https::CaInfo \"${TMPWORKINGDIRECTORY}/rootdir/etc/webserver.pem\";" > rootdir/etc/apt/apt.conf.d/99https
        echo "Apt::Cmd::Disable-Script-Warning \"1\";" > rootdir/etc/apt/apt.conf.d/apt-binary
        configcompression '.' 'gz' #'bz2' 'lzma' 'xz'
+       confighashes 'SHA1' # these are tests, not security best-practices
 
        # create some files in /tmp and look at user/group to get what this means
        TEST_DEFAULT_USER="$USER"
 
        # create some files in /tmp and look at user/group to get what this means
        TEST_DEFAULT_USER="$USER"
@@ -513,7 +514,22 @@ configcompression() {
                shift
        done > ${TMPWORKINGDIRECTORY}/rootdir/etc/testcase-compressor.conf
 }
                shift
        done > ${TMPWORKINGDIRECTORY}/rootdir/etc/testcase-compressor.conf
 }
-
+confighashes() {
+       {
+               echo 'APT::FTPArchive {'
+               {
+                       while [ -n "$1" ]; do
+                               printf "$1" | tr 'a-z' 'A-Z'
+                               printf "\t\"true\";\n"
+                               shift
+                       done
+                       for h in 'MD5' 'SHA1' 'SHA256' 'SHA512'; do
+                               printf "$h\t\"false\";\n"
+                       done
+               } | awk '!x[$1]++'
+               echo '};'
+       } >> "${TMPWORKINGDIRECTORY}/rootdir/etc/apt/apt.conf.d/ftparchive-hashes.conf"
+}
 forcecompressor() {
        COMPRESSOR="$1"
        COMPRESSOR_CMD="$1"
 forcecompressor() {
        COMPRESSOR="$1"
        COMPRESSOR_CMD="$1"
@@ -734,41 +750,24 @@ createaptftparchiveconfig() {
        local COMPRESSORS="$(cut -d'    ' -f 1 ${TMPWORKINGDIRECTORY}/rootdir/etc/testcase-compressor.conf | tr '\n' ' ')"
        local COMPRESSORS="${COMPRESSORS%* }"
        local ARCHS="$(getarchitectures)"
        local COMPRESSORS="$(cut -d'    ' -f 1 ${TMPWORKINGDIRECTORY}/rootdir/etc/testcase-compressor.conf | tr '\n' ' ')"
        local COMPRESSORS="${COMPRESSORS%* }"
        local ARCHS="$(getarchitectures)"
-       echo -n 'Dir {
-       ArchiveDir "' >> ftparchive.conf
-       echo -n $(readlink -f .) >> ftparchive.conf
-       echo -n '";
-       CacheDir "' >> ftparchive.conf
-       echo -n $(readlink -f ..) >> ftparchive.conf
-       echo -n '";
-       FileListDir "' >> ftparchive.conf
-       echo -n $(readlink -f pool/) >> ftparchive.conf
-       echo -n '";
+       cat > ftparchive.conf <<EOF
+Dir {
+       ArchiveDir "$(readlink -f .)";
+       CacheDir "$(readlink -f ..)";
+       FileListDir "$(readlink -f pool/)";
 };
 Default {
 };
 Default {
-       Packages::Compress "'"$COMPRESSORS"'";
-       Sources::Compress "'"$COMPRESSORS"'";
-       Contents::Compress "'"$COMPRESSORS"'";
-       Translation::Compress "'"$COMPRESSORS"'";
+       Packages::Compress "$COMPRESSORS";
+       Sources::Compress "$COMPRESSORS";
+       Contents::Compress "$COMPRESSORS";
+       Translation::Compress "$COMPRESSORS";
        LongDescription "false";
 };
 TreeDefault {
        Directory "pool/";
        SrcDirectory "pool/";
 };
        LongDescription "false";
 };
 TreeDefault {
        Directory "pool/";
        SrcDirectory "pool/";
 };
-APT {
-       FTPArchive {
-               Release {
-                       Origin "joesixpack";
-                       Label "apttestcases";
-                       Suite "unstable";
-                       Description "repository with dummy packages";
-                       Architectures "' >> ftparchive.conf
-       echo -n "$ARCHS" >> ftparchive.conf
-       echo 'source";
-               };
-       };
-};' >> ftparchive.conf
+EOF
        for DIST in $(find ./pool/ -maxdepth 1 -name '*.pkglist' -type f | cut -d'/' -f 3 | cut -d'.' -f 1 | sort | uniq); do
                echo -n 'tree "dists/' >> ftparchive.conf
                echo -n "$DIST" >> ftparchive.conf
        for DIST in $(find ./pool/ -maxdepth 1 -name '*.pkglist' -type f | cut -d'/' -f 3 | cut -d'.' -f 1 | sort | uniq); do
                echo -n 'tree "dists/' >> ftparchive.conf
                echo -n "$DIST" >> ftparchive.conf
@@ -968,6 +967,9 @@ getreleaseversionfromsuite() { true; }
 getlabelfromsuite() { true; }
 getoriginfromsuite() { true; }
 
 getlabelfromsuite() { true; }
 getoriginfromsuite() { true; }
 
+aptftparchiverelease() {
+       aptftparchive -qq release "$@" | sed -e '/0 Release$/ d' # remove the self reference
+}
 generatereleasefiles() {
        # $1 is the Date header and $2 is the ValidUntil header to be set
        # both should be given in notation date/touch can understand
 generatereleasefiles() {
        # $1 is the Date header and $2 is the ValidUntil header to be set
        # both should be given in notation date/touch can understand
@@ -988,33 +990,31 @@ generatereleasefiles() {
                        if [ -n "$ORIGIN" ]; then
                                ORIGIN="-o APT::FTPArchive::Release::Origin=${ORIGIN}"
                        fi
                        if [ -n "$ORIGIN" ]; then
                                ORIGIN="-o APT::FTPArchive::Release::Origin=${ORIGIN}"
                        fi
-                       aptftparchive -qq release $dir \
+                       aptftparchiverelease $dir \
                                -o APT::FTPArchive::Release::Suite="${SUITE}" \
                                -o APT::FTPArchive::Release::Codename="${CODENAME}" \
                                ${LABEL} \
                                ${ORIGIN} \
                                ${VERSION} \
                                -o APT::FTPArchive::Release::Suite="${SUITE}" \
                                -o APT::FTPArchive::Release::Codename="${CODENAME}" \
                                ${LABEL} \
                                ${ORIGIN} \
                                ${VERSION} \
-                                       | sed -e '/0 Release$/ d' > $dir/Release # remove the self reference
+                               > $dir/Release
                        if [ "$SUITE" = "experimental" -o "$SUITE" = "experimental2" ]; then
                                sed -i '/^Date: / a\
 NotAutomatic: yes' $dir/Release
                        fi
                        if [ "$SUITE" = "experimental" -o "$SUITE" = "experimental2" ]; then
                                sed -i '/^Date: / a\
 NotAutomatic: yes' $dir/Release
                        fi
-                       if [ -n "$1" -a "$1" != "now" ]; then
-                               sed -i "s/^Date: .*$/Date: $(date -d "$1" '+%a, %d %b %Y %H:%M:%S %Z')/" $dir/Release
-                       fi
-                       if [ -n "$2" ]; then
-                               sed -i "/^Date: / a\
-Valid-Until: $(date -d "$2" '+%a, %d %b %Y %H:%M:%S %Z')" $dir/Release
-                       fi
                done
        else
                done
        else
-               aptftparchive -qq release ./aptarchive | sed -e '/0 Release$/ d' > aptarchive/Release # remove the self reference
+               aptftparchiverelease ./aptarchive > aptarchive/Release
        fi
        if [ -n "$1" -a "$1" != "now" ]; then
                for release in $(find ./aptarchive -name 'Release'); do
        fi
        if [ -n "$1" -a "$1" != "now" ]; then
                for release in $(find ./aptarchive -name 'Release'); do
+                       sed -i "s/^Date: .*$/Date: $(date -d "$1" '+%a, %d %b %Y %H:%M:%S %Z')/" $release
                        touch -d "$1" $release
                done
        fi
                        touch -d "$1" $release
                done
        fi
+       if [ -n "$2" ]; then
+               sed -i "/^Date: / a\
+Valid-Until: $(date -d "$2" '+%a, %d %b %Y %H:%M:%S %Z')" $(find ./aptarchive -name 'Release')
+       fi
        msgdone "info"
 }
 
        msgdone "info"
 }
 
index cef46a1b81ae249dc3ea459525b26897bd4b71ae..29383686114e3ff8e1b3d0c2429df8ad725cfd41 100755 (executable)
@@ -6,6 +6,7 @@ TESTDIR=$(readlink -f $(dirname $0))
 
 setupenvironment
 configarchitecture "i386"
 
 setupenvironment
 configarchitecture "i386"
+confighashes 'SHA512'
 
 insertpackage 'unstable' 'foo' 'all' '1.0'
 
 
 insertpackage 'unstable' 'foo' 'all' '1.0'
 
index f00e2a24c23fd0b0d606e9b45d38ccb64b810c30..ca881ed81484348c48c828a99b4cf92959979891 100755 (executable)
@@ -18,6 +18,7 @@ TESTDIR=$(readlink -f $(dirname $0))
 setupenvironment
 configarchitecture 'i386'
 configcompression 'gz' '.'
 setupenvironment
 configarchitecture 'i386'
 configcompression 'gz' '.'
+confighashes 'SHA1' 'SHA256' 'SHA512'
 
 # enable by-hash in apt-ftparchive
 echo 'APT::FTPArchive::DoByHash "1";' >> aptconfig.conf
 
 # enable by-hash in apt-ftparchive
 echo 'APT::FTPArchive::DoByHash "1";' >> aptconfig.conf
index 8b768441a230e528f842574079a95bbd3b0c2a4f..44bc85fea2f0dc13f798db267c2c4ab613abb045 100755 (executable)
@@ -9,6 +9,7 @@ TESTDIR=$(readlink -f $(dirname $0))
 . $TESTDIR/framework
 setupenvironment
 configarchitecture "i386"
 . $TESTDIR/framework
 setupenvironment
 configarchitecture "i386"
+confighashes 'MD5' 'SHA1' 'SHA256' 'SHA512'
 
 # gather the db and the deb, ensure mtime is not modfied as its saved in the DB
 cp -p $TESTDIR/deb-lp1274466-cachedb.deb  foo_1_i386.deb
 
 # gather the db and the deb, ensure mtime is not modfied as its saved in the DB
 cp -p $TESTDIR/deb-lp1274466-cachedb.deb  foo_1_i386.deb
index 66a3b7845e52da9e0854cdf0f9981c4b2c1ae209..06f5bdd9dfb31bdfeb04d877163252af46479c77 100755 (executable)
@@ -93,6 +93,7 @@ TESTDIR=$(readlink -f $(dirname $0))
 . $TESTDIR/framework
 setupenvironment
 configarchitecture "i386"
 . $TESTDIR/framework
 setupenvironment
 configarchitecture "i386"
+confighashes 'MD5' 'SHA1' 'SHA256' 'SHA512'
 
 msgtest 'Test apt-ftparchive source with missing hashes in .dsc'
 
 
 msgtest 'Test apt-ftparchive source with missing hashes in .dsc'
 
index fa0b65672ae741cbfb77166902f022bcdef05be2..c4ebd03bbaf267b7be3e26c55d8cc6246004e903 100755 (executable)
@@ -6,6 +6,7 @@ TESTDIR=$(readlink -f $(dirname $0))
 
 setupenvironment
 configarchitecture "i386"
 
 setupenvironment
 configarchitecture "i386"
+confighashes 'SHA512'
 
 buildsimplenativepackage 'apt' 'all' '1.0' 'stable'
 buildsimplenativepackage 'apt' 'all' '2.0' 'unstable'
 
 buildsimplenativepackage 'apt' 'all' '1.0' 'stable'
 buildsimplenativepackage 'apt' 'all' '2.0' 'unstable'
index 94b604f0e7dc9b88cf991e2984f05e85054061a6..f976993ca5e6dc1930c0aa10f3323eebaa051425 100755 (executable)
@@ -11,6 +11,7 @@ TESTDIR=$(readlink -f $(dirname $0))
 setupenvironment
 configarchitecture "amd64"
 configcompression 'bz2' 'gz'
 setupenvironment
 configarchitecture "amd64"
 configcompression 'bz2' 'gz'
+confighashes 'SHA512'
 
 insertpackage 'unstable' 'foo' 'all' '1'
 insertsource 'unstable' 'foo' 'all' '1'
 
 insertpackage 'unstable' 'foo' 'all' '1'
 insertsource 'unstable' 'foo' 'all' '1'
index f6a94ba67747f99b222d470d8a2bfcc7bfcb6aba..62c87fe08b70f376688bdec5d5c77702636d183b 100755 (executable)
@@ -6,6 +6,7 @@ TESTDIR=$(readlink -f $(dirname $0))
 
 setupenvironment
 configarchitecture 'i386'
 
 setupenvironment
 configarchitecture 'i386'
+confighashes 'SHA1' 'SHA256'
 
 buildaptarchive
 setupflataptarchive
 
 buildaptarchive
 setupflataptarchive
index 6fcb856b5ce8572de437f0849824a504c78924bc..badc097b3f9bc815d5a47cf705cd887fd01b35eb 100755 (executable)
@@ -5,6 +5,7 @@ TESTDIR=$(readlink -f $(dirname $0))
 . $TESTDIR/framework
 setupenvironment
 configarchitecture "i386"
 . $TESTDIR/framework
 setupenvironment
 configarchitecture "i386"
+confighashes 'MD5' 'SHA1' 'SHA256' 'SHA512'
 
 msgtest 'Test apt-ftparchive source with missing hashes in .dsc'
 
 
 msgtest 'Test apt-ftparchive source with missing hashes in .dsc'
 
@@ -22,14 +23,16 @@ Files:
 EOF
 
 # check for the SHA hashes
 EOF
 
 # check for the SHA hashes
-aptftparchive sources aptarchive/ > aptarchive/Sources  2>/dev/null || msgfail
-test -n "$(grep Checksums-Sha512 aptarchive/Sources)" && msgpass || msgfail
+testsuccess aptftparchive sources aptarchive/
+cp rootdir/tmp/testsuccess.output aptarchive/Sources
+testsuccess grep Checksums-Sha512 aptarchive/Sources
 
 for hash in sha512sum sha256sum sha1sum; do
     for f in foo_1.0.tar.gz foo_1.0.dsc; do
         SUM=$($hash aptarchive/$f | cut -d' ' -f1)
 
 for hash in sha512sum sha256sum sha1sum; do
     for f in foo_1.0.tar.gz foo_1.0.dsc; do
         SUM=$($hash aptarchive/$f | cut -d' ' -f1)
-        msgtest "Test $hash hash matches for $f"
         NEEDLE="$SUM $(stat -c%s aptarchive/$f) $f"
         NEEDLE="$SUM $(stat -c%s aptarchive/$f) $f"
-        test -n "$SUM" &&  test -n "$(grep "$NEEDLE" aptarchive/Sources)" && msgpass || msgfail 
+       testsuccess test -n "$SUM"
+       msgtest "Test $hash hash matches for $f"
+       testsuccess --nomsg grep "$NEEDLE" aptarchive/Sources
     done
 done
     done
 done