From c3bcc9f7cb629c36d502cbf04ae3d453ec65a4b7 Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Mon, 3 Feb 2014 23:16:41 +0400 Subject: [PATCH] Tests for downloading from broken mirror (checksums). --- system/t04_mirror/UpdateMirror3Test_gold | 6 ++ system/t04_mirror/UpdateMirror4Test_gold | 7 +++ system/t04_mirror/UpdateMirror5Test_gold | 12 ++++ system/t04_mirror/UpdateMirror6Test_gold | 12 ++++ .../test_release/dists/hardy/Release | 15 +++++ .../dists/hardy/main/binary-amd64/Packages | 1 + .../test_release2/dists/hardy/Release | 11 ++++ .../dists/hardy/main/binary-amd64/Packages | 19 ++++++ .../amanda-client_3.3.1-3~bpo60+1_amd64.deb | 1 + system/t04_mirror/update.py | 60 +++++++++++++++++++ 10 files changed, 144 insertions(+) create mode 100644 system/t04_mirror/UpdateMirror3Test_gold create mode 100644 system/t04_mirror/UpdateMirror4Test_gold create mode 100644 system/t04_mirror/UpdateMirror5Test_gold create mode 100644 system/t04_mirror/UpdateMirror6Test_gold create mode 100644 system/t04_mirror/test_release/dists/hardy/Release create mode 100644 system/t04_mirror/test_release/dists/hardy/main/binary-amd64/Packages create mode 100644 system/t04_mirror/test_release2/dists/hardy/Release create mode 100644 system/t04_mirror/test_release2/dists/hardy/main/binary-amd64/Packages create mode 100644 system/t04_mirror/test_release2/pool/main/a/amanda/amanda-client_3.3.1-3~bpo60+1_amd64.deb diff --git a/system/t04_mirror/UpdateMirror3Test_gold b/system/t04_mirror/UpdateMirror3Test_gold new file mode 100644 index 00000000..87b1b576 --- /dev/null +++ b/system/t04_mirror/UpdateMirror3Test_gold @@ -0,0 +1,6 @@ +Downloading ${url}dists/hardy/Release... +Downloading & parsing package files... +Downloading ${url}dists/hardy/main/binary-amd64/Packages.bz2... +Downloading ${url}dists/hardy/main/binary-amd64/Packages.gz... +Downloading ${url}dists/hardy/main/binary-amd64/Packages... +ERROR: unable to update: ${url}dists/hardy/main/binary-amd64/Packages: sha256 hash mismatch "494414ded24da13c451b13b424928821351c78fce49f93d9e1b55f102790c206" != "8a21688ae769f2b4ffcaa366409f679d" diff --git a/system/t04_mirror/UpdateMirror4Test_gold b/system/t04_mirror/UpdateMirror4Test_gold new file mode 100644 index 00000000..87d17f2a --- /dev/null +++ b/system/t04_mirror/UpdateMirror4Test_gold @@ -0,0 +1,7 @@ +Downloading ${url}dists/hardy/Release... +Downloading & parsing package files... +Downloading ${url}dists/hardy/main/binary-amd64/Packages.bz2... +Downloading ${url}dists/hardy/main/binary-amd64/Packages.gz... +Downloading ${url}dists/hardy/main/binary-amd64/Packages... +WARNING: ${url}dists/hardy/main/binary-amd64/Packages: sha256 hash mismatch "494414ded24da13c451b13b424928821351c78fce49f93d9e1b55f102790c206" != "8a21688ae769f2b4ffcaa366409f679d" +ERROR: unable to update: malformed stanza syntax diff --git a/system/t04_mirror/UpdateMirror5Test_gold b/system/t04_mirror/UpdateMirror5Test_gold new file mode 100644 index 00000000..7155f520 --- /dev/null +++ b/system/t04_mirror/UpdateMirror5Test_gold @@ -0,0 +1,12 @@ +Downloading ${url}dists/hardy/Release... +Downloading & parsing package files... +Downloading ${url}dists/hardy/main/binary-amd64/Packages.bz2... +Downloading ${url}dists/hardy/main/binary-amd64/Packages.gz... +Downloading ${url}dists/hardy/main/binary-amd64/Packages... +Saving packages to database... +Building download queue... +Download queue: 1 items, 0.00 GiB size +Downloading ${url}pool/main/a/amanda/amanda-client_3.3.1-3~bpo60+1_amd64.deb... +ERROR: unable to update: download errors: + ${url}pool/main/a/amanda/amanda-client_3.3.1-3~bpo60+1_amd64.deb: sha1 hash mismatch "8d3a014000038725d6daf8771b42a0784253688f" != "66b27417d37e024c46526c2f6d358a754fc552f3" + diff --git a/system/t04_mirror/UpdateMirror6Test_gold b/system/t04_mirror/UpdateMirror6Test_gold new file mode 100644 index 00000000..3327cf78 --- /dev/null +++ b/system/t04_mirror/UpdateMirror6Test_gold @@ -0,0 +1,12 @@ +Downloading ${url}dists/hardy/Release... +Downloading & parsing package files... +Downloading ${url}dists/hardy/main/binary-amd64/Packages.bz2... +Downloading ${url}dists/hardy/main/binary-amd64/Packages.gz... +Downloading ${url}dists/hardy/main/binary-amd64/Packages... +Saving packages to database... +Building download queue... +Download queue: 1 items, 0.00 GiB size +Downloading ${url}pool/main/a/amanda/amanda-client_3.3.1-3~bpo60+1_amd64.deb... +WARNING: ${url}pool/main/a/amanda/amanda-client_3.3.1-3~bpo60+1_amd64.deb: sha1 hash mismatch "8d3a014000038725d6daf8771b42a0784253688f" != "66b27417d37e024c46526c2f6d358a754fc552f3" + +Mirror `failure` has been successfully updated. diff --git a/system/t04_mirror/test_release/dists/hardy/Release b/system/t04_mirror/test_release/dists/hardy/Release new file mode 100644 index 00000000..b9465c15 --- /dev/null +++ b/system/t04_mirror/test_release/dists/hardy/Release @@ -0,0 +1,15 @@ +Origin: test +Label: failure +Suite: test +Version: 6.0.8 +Codename: hardy +Date: Sat, 19 Oct 2013 13:54:21 UTC +Architectures: amd64 +Components: main +Description: Debian 6.0.8 Released 19 October 2013 +MD5Sum: + 2e3817293fc275dbee74bd71ce6eb056 4 main/binary-amd64/Packages +SHA1: + 4d13fcc6eda389d4d679602171e11593eadae9b9 4 main/binary-amd64/Packages +SHA256: + 8a21688ae769f2b4ffcaa366409f679d 4 main/binary-amd64/Packages diff --git a/system/t04_mirror/test_release/dists/hardy/main/binary-amd64/Packages b/system/t04_mirror/test_release/dists/hardy/main/binary-amd64/Packages new file mode 100644 index 00000000..533805db --- /dev/null +++ b/system/t04_mirror/test_release/dists/hardy/main/binary-amd64/Packages @@ -0,0 +1 @@ +lala \ No newline at end of file diff --git a/system/t04_mirror/test_release2/dists/hardy/Release b/system/t04_mirror/test_release2/dists/hardy/Release new file mode 100644 index 00000000..a0c428a5 --- /dev/null +++ b/system/t04_mirror/test_release2/dists/hardy/Release @@ -0,0 +1,11 @@ +Origin: test +Label: failure +Suite: test +Version: 6.0.8 +Codename: hardy +Date: Sat, 19 Oct 2013 13:54:21 UTC +Architectures: amd64 +Components: main +Description: Debian 6.0.8 Released 19 October 2013 +MD5Sum: + 846549680001f5c632b6ee8e0f183825 827 main/binary-amd64/Packages diff --git a/system/t04_mirror/test_release2/dists/hardy/main/binary-amd64/Packages b/system/t04_mirror/test_release2/dists/hardy/main/binary-amd64/Packages new file mode 100644 index 00000000..787e64f3 --- /dev/null +++ b/system/t04_mirror/test_release2/dists/hardy/main/binary-amd64/Packages @@ -0,0 +1,19 @@ +Package: amanda-client +Source: amanda +Version: 1:3.3.1-3~bpo60+1 +Installed-Size: 880 +Maintainer: Bdale Garbee +Architecture: amd64 +Replaces: amanda-common (<< 1:2.5.2p1-3) +Depends: libc6 (>= 2.3), libcurl3 (>= 7.16.2-1), libglib2.0-0 (>= 2.12.0), libreadline6 (>= 6.0), libssl0.9.8 (>= 0.9.8m-1), amanda-common (= 1:3.3.1-3~bpo60+1) +Suggests: gnuplot, dump, smbclient +Conflicts: amanda, amanda-common (<< 1:2.5.2p1-3) +Description: Advanced Maryland Automatic Network Disk Archiver (Client) +Description-md5: 21af3684379a64cacc51c39152ab1062 +Section: utils +Priority: optional +Filename: pool/main/a/amanda/amanda-client_3.3.1-3~bpo60+1_amd64.deb +Size: 30 +MD5sum: 4f7223ebadee9fb57b6796570d60638f +SHA1: 66b27417d37e024c46526c2f6d358a754fc552f3 +SHA256: 3608bca1e44ea6c4d268eb6db02260269892c0b42b86bbf1e77a6fa16c3c9282 \ No newline at end of file diff --git a/system/t04_mirror/test_release2/pool/main/a/amanda/amanda-client_3.3.1-3~bpo60+1_amd64.deb b/system/t04_mirror/test_release2/pool/main/a/amanda/amanda-client_3.3.1-3~bpo60+1_amd64.deb new file mode 100644 index 00000000..6e6e144a --- /dev/null +++ b/system/t04_mirror/test_release2/pool/main/a/amanda/amanda-client_3.3.1-3~bpo60+1_amd64.deb @@ -0,0 +1 @@ +012345678901234567890123456789 \ No newline at end of file diff --git a/system/t04_mirror/update.py b/system/t04_mirror/update.py index 0eca25ec..7d9a5822 100644 --- a/system/t04_mirror/update.py +++ b/system/t04_mirror/update.py @@ -1,3 +1,4 @@ +import string from lib import BaseTest @@ -21,3 +22,62 @@ class UpdateMirror2Test(BaseTest): """ runCmd = "aptly mirror update mirror-xyz" expectedCode = 1 + + +class UpdateMirror3Test(BaseTest): + """ + update mirrors: wrong checksum in release file + """ + fixtureCmds = [ + "aptly mirror create failure ${url} hardy main", + ] + fixtureWebServer = "test_release" + runCmd = "aptly mirror update failure" + expectedCode = 1 + + def gold_processor(self, gold): + return string.Template(gold).substitute({'url': self.webServerUrl}) + + +class UpdateMirror4Test(BaseTest): + """ + update mirrors: wrong checksum in release file, but ignore + """ + fixtureCmds = [ + "aptly mirror create failure ${url} hardy main", + ] + fixtureWebServer = "test_release" + runCmd = "aptly mirror update -ignore-checksums failure" + expectedCode = 1 + + def gold_processor(self, gold): + return string.Template(gold).substitute({'url': self.webServerUrl}) + + +class UpdateMirror5Test(BaseTest): + """ + update mirrors: wrong checksum in package + """ + fixtureCmds = [ + "aptly mirror create failure ${url} hardy main", + ] + fixtureWebServer = "test_release2" + runCmd = "aptly mirror update failure" + expectedCode = 1 + + def gold_processor(self, gold): + return string.Template(gold).substitute({'url': self.webServerUrl}) + + +class UpdateMirror6Test(BaseTest): + """ + update mirrors: wrong checksum in package, but ignore + """ + fixtureCmds = [ + "aptly mirror create failure ${url} hardy main", + ] + fixtureWebServer = "test_release2" + runCmd = "aptly mirror update -ignore-checksums failure" + + def gold_processor(self, gold): + return string.Template(gold).substitute({'url': self.webServerUrl})