From 1957c811e8274933c671b1d380f141f150c9afd1 Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Fri, 6 Jun 2014 02:09:13 +0400 Subject: [PATCH] Tests for multi-component and aptly publish list/snapshot/repo, aptly serve. #36 --- system/t06_publish/PublishList2Test_gold | 1 + system/t06_publish/PublishRepo17Test_gold | 13 ++ system/t06_publish/PublishRepo17Test_release | 9 + system/t06_publish/PublishRepo18Test_gold | 13 ++ system/t06_publish/PublishRepo19Test_gold | 1 + system/t06_publish/PublishRepo20Test_gold | 2 + system/t06_publish/PublishRepo21Test_gold | 2 + system/t06_publish/PublishRepo22Test_gold | 1 + system/t06_publish/PublishRepo23Test_gold | 1 + system/t06_publish/PublishSnapshot26Test_gold | 13 ++ .../t06_publish/PublishSnapshot26Test_release | 9 + system/t06_publish/PublishSnapshot27Test_gold | 13 ++ system/t06_publish/PublishSnapshot28Test_gold | 1 + system/t06_publish/PublishSnapshot29Test_gold | 2 + system/t06_publish/PublishSnapshot30Test_gold | 1 + system/t06_publish/PublishSnapshot31Test_gold | 1 + system/t06_publish/PublishSnapshot32Test_gold | 1 + system/t06_publish/list.py | 1 + system/t06_publish/repo.py | 163 ++++++++++++++++ system/t06_publish/snapshot.py | 175 ++++++++++++++++++ system/t07_serve/Serve1Test_gold | 3 + system/t07_serve/Serve1Test_http | 1 + system/t07_serve/__init__.py | 1 + 23 files changed, 428 insertions(+) create mode 100644 system/t06_publish/PublishRepo17Test_gold create mode 100644 system/t06_publish/PublishRepo17Test_release create mode 100644 system/t06_publish/PublishRepo18Test_gold create mode 100644 system/t06_publish/PublishRepo19Test_gold create mode 100644 system/t06_publish/PublishRepo20Test_gold create mode 100644 system/t06_publish/PublishRepo21Test_gold create mode 100644 system/t06_publish/PublishRepo22Test_gold create mode 100644 system/t06_publish/PublishRepo23Test_gold create mode 100644 system/t06_publish/PublishSnapshot26Test_gold create mode 100644 system/t06_publish/PublishSnapshot26Test_release create mode 100644 system/t06_publish/PublishSnapshot27Test_gold create mode 100644 system/t06_publish/PublishSnapshot28Test_gold create mode 100644 system/t06_publish/PublishSnapshot29Test_gold create mode 100644 system/t06_publish/PublishSnapshot30Test_gold create mode 100644 system/t06_publish/PublishSnapshot31Test_gold create mode 100644 system/t06_publish/PublishSnapshot32Test_gold diff --git a/system/t06_publish/PublishList2Test_gold b/system/t06_publish/PublishList2Test_gold index 94c54a30..17532b9f 100644 --- a/system/t06_publish/PublishList2Test_gold +++ b/system/t06_publish/PublishList2Test_gold @@ -1,5 +1,6 @@ Published repositories: * ./maverick [amd64, i386] publishes {main: [snap1]: Snapshot from mirror [gnuplot-maverick]: http://ppa.launchpad.net/gladky-anton/gnuplot/ubuntu/ maverick} + * ppa/maverick [amd64, i386] publishes {main: [snap1]: Snapshot from mirror [gnuplot-maverick]: http://ppa.launchpad.net/gladky-anton/gnuplot/ubuntu/ maverick}, {contrib: [snap2]: Merged from sources: 'snap1'} * ppa/smira/wheezy [amd64] publishes {contrib: [snap2]: Merged from sources: 'snap1'} * ppa/tr1/maverick (origin: origin1) [amd64, i386] publishes {main: [snap2]: Merged from sources: 'snap1'} * ppa/tr2/maverick (label: label1) [amd64, i386] publishes {main: [snap2]: Merged from sources: 'snap1'} diff --git a/system/t06_publish/PublishRepo17Test_gold b/system/t06_publish/PublishRepo17Test_gold new file mode 100644 index 00000000..cfa69b57 --- /dev/null +++ b/system/t06_publish/PublishRepo17Test_gold @@ -0,0 +1,13 @@ +Loading packages... +Generating metadata files and linking package files... +Signing file '${HOME}/.aptly/public/dists/maverick/Release' with gpg, please enter your passphrase when prompted: +Clearsigning file '${HOME}/.aptly/public/dists/maverick/Release' with gpg, please enter your passphrase when prompted: + +Local repos repo1, repo2 have been successfully published. +Please setup your webserver to serve directory '${HOME}/.aptly/public' with autoindexing. +Now you can add following line to apt sources: + deb http://your-server/ maverick contrib main + deb-src http://your-server/ maverick contrib main +Don't forget to add your GPG key to apt with apt-key. + +You can also use `aptly serve` to publish your repositories over HTTP quickly. diff --git a/system/t06_publish/PublishRepo17Test_release b/system/t06_publish/PublishRepo17Test_release new file mode 100644 index 00000000..2fbbc84f --- /dev/null +++ b/system/t06_publish/PublishRepo17Test_release @@ -0,0 +1,9 @@ +Origin: . maverick +Label: . maverick +Codename: maverick +Architectures: i386 source +Components: contrib main +Description: Generated by aptly +MD5Sum: +SHA1: +SHA256: diff --git a/system/t06_publish/PublishRepo18Test_gold b/system/t06_publish/PublishRepo18Test_gold new file mode 100644 index 00000000..fb87b209 --- /dev/null +++ b/system/t06_publish/PublishRepo18Test_gold @@ -0,0 +1,13 @@ +Loading packages... +Generating metadata files and linking package files... +Signing file '${HOME}/.aptly/public/dists/squeeze/Release' with gpg, please enter your passphrase when prompted: +Clearsigning file '${HOME}/.aptly/public/dists/squeeze/Release' with gpg, please enter your passphrase when prompted: + +Local repos repo1, repo2 have been successfully published. +Please setup your webserver to serve directory '${HOME}/.aptly/public' with autoindexing. +Now you can add following line to apt sources: + deb http://your-server/ squeeze contrib main + deb-src http://your-server/ squeeze contrib main +Don't forget to add your GPG key to apt with apt-key. + +You can also use `aptly serve` to publish your repositories over HTTP quickly. diff --git a/system/t06_publish/PublishRepo19Test_gold b/system/t06_publish/PublishRepo19Test_gold new file mode 100644 index 00000000..06eb3d3c --- /dev/null +++ b/system/t06_publish/PublishRepo19Test_gold @@ -0,0 +1 @@ +ERROR: unable to publish: duplicate component name: contrib diff --git a/system/t06_publish/PublishRepo20Test_gold b/system/t06_publish/PublishRepo20Test_gold new file mode 100644 index 00000000..684a265e --- /dev/null +++ b/system/t06_publish/PublishRepo20Test_gold @@ -0,0 +1,2 @@ +Warning: publishing from empty source, architectures list should be complete, it can't be changed after publishing (use -architectures flag) +ERROR: unable to publish: duplicate component name: b diff --git a/system/t06_publish/PublishRepo21Test_gold b/system/t06_publish/PublishRepo21Test_gold new file mode 100644 index 00000000..9037e5ed --- /dev/null +++ b/system/t06_publish/PublishRepo21Test_gold @@ -0,0 +1,2 @@ +Warning: publishing from empty source, architectures list should be complete, it can't be changed after publishing (use -architectures flag) +ERROR: unable to publish: unable to guess distribution name, please specify explicitly diff --git a/system/t06_publish/PublishRepo22Test_gold b/system/t06_publish/PublishRepo22Test_gold new file mode 100644 index 00000000..b5c0a034 --- /dev/null +++ b/system/t06_publish/PublishRepo22Test_gold @@ -0,0 +1 @@ +ERROR: unable to publish: local repo with name repo2 not found diff --git a/system/t06_publish/PublishRepo23Test_gold b/system/t06_publish/PublishRepo23Test_gold new file mode 100644 index 00000000..3e534999 --- /dev/null +++ b/system/t06_publish/PublishRepo23Test_gold @@ -0,0 +1 @@ +ERROR: unable to parse command diff --git a/system/t06_publish/PublishSnapshot26Test_gold b/system/t06_publish/PublishSnapshot26Test_gold new file mode 100644 index 00000000..ab374eac --- /dev/null +++ b/system/t06_publish/PublishSnapshot26Test_gold @@ -0,0 +1,13 @@ +Loading packages... +Generating metadata files and linking package files... +Signing file '${HOME}/.aptly/public/dists/maverick/Release' with gpg, please enter your passphrase when prompted: +Clearsigning file '${HOME}/.aptly/public/dists/maverick/Release' with gpg, please enter your passphrase when prompted: + +Snapshots snap26.1, snap26.2 have been successfully published. +Please setup your webserver to serve directory '${HOME}/.aptly/public' with autoindexing. +Now you can add following line to apt sources: + deb http://your-server/ maverick contrib main + deb-src http://your-server/ maverick contrib main +Don't forget to add your GPG key to apt with apt-key. + +You can also use `aptly serve` to publish your repositories over HTTP quickly. diff --git a/system/t06_publish/PublishSnapshot26Test_release b/system/t06_publish/PublishSnapshot26Test_release new file mode 100644 index 00000000..bd303d2e --- /dev/null +++ b/system/t06_publish/PublishSnapshot26Test_release @@ -0,0 +1,9 @@ +Origin: . maverick +Label: . maverick +Codename: maverick +Architectures: amd64 i386 i386 +Components: contrib main +Description: Generated by aptly +MD5Sum: +SHA1: +SHA256: diff --git a/system/t06_publish/PublishSnapshot27Test_gold b/system/t06_publish/PublishSnapshot27Test_gold new file mode 100644 index 00000000..b1277d1b --- /dev/null +++ b/system/t06_publish/PublishSnapshot27Test_gold @@ -0,0 +1,13 @@ +Loading packages... +Generating metadata files and linking package files... +Signing file '${HOME}/.aptly/public/dists/maverick/Release' with gpg, please enter your passphrase when prompted: +Clearsigning file '${HOME}/.aptly/public/dists/maverick/Release' with gpg, please enter your passphrase when prompted: + +Snapshots snap27.1, snap27.2 have been successfully published. +Please setup your webserver to serve directory '${HOME}/.aptly/public' with autoindexing. +Now you can add following line to apt sources: + deb http://your-server/ maverick contrib main + deb-src http://your-server/ maverick contrib main +Don't forget to add your GPG key to apt with apt-key. + +You can also use `aptly serve` to publish your repositories over HTTP quickly. diff --git a/system/t06_publish/PublishSnapshot28Test_gold b/system/t06_publish/PublishSnapshot28Test_gold new file mode 100644 index 00000000..d25767f7 --- /dev/null +++ b/system/t06_publish/PublishSnapshot28Test_gold @@ -0,0 +1 @@ +ERROR: unable to publish: duplicate component name: main diff --git a/system/t06_publish/PublishSnapshot29Test_gold b/system/t06_publish/PublishSnapshot29Test_gold new file mode 100644 index 00000000..684a265e --- /dev/null +++ b/system/t06_publish/PublishSnapshot29Test_gold @@ -0,0 +1,2 @@ +Warning: publishing from empty source, architectures list should be complete, it can't be changed after publishing (use -architectures flag) +ERROR: unable to publish: duplicate component name: b diff --git a/system/t06_publish/PublishSnapshot30Test_gold b/system/t06_publish/PublishSnapshot30Test_gold new file mode 100644 index 00000000..f6e05973 --- /dev/null +++ b/system/t06_publish/PublishSnapshot30Test_gold @@ -0,0 +1 @@ +ERROR: unable to publish: unable to guess distribution name, please specify explicitly diff --git a/system/t06_publish/PublishSnapshot31Test_gold b/system/t06_publish/PublishSnapshot31Test_gold new file mode 100644 index 00000000..18249d9c --- /dev/null +++ b/system/t06_publish/PublishSnapshot31Test_gold @@ -0,0 +1 @@ +ERROR: unable to publish: snapshot with name snap31.2 not found diff --git a/system/t06_publish/PublishSnapshot32Test_gold b/system/t06_publish/PublishSnapshot32Test_gold new file mode 100644 index 00000000..3e534999 --- /dev/null +++ b/system/t06_publish/PublishSnapshot32Test_gold @@ -0,0 +1 @@ +ERROR: unable to parse command diff --git a/system/t06_publish/list.py b/system/t06_publish/list.py index 6c173132..c44a8a1d 100644 --- a/system/t06_publish/list.py +++ b/system/t06_publish/list.py @@ -21,6 +21,7 @@ class PublishList2Test(BaseTest): "aptly -architectures=amd64 publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=wheezy -component=contrib snap2 ppa/smira", "aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -origin=origin1 snap2 ppa/tr1", "aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -label=label1 snap2 ppa/tr2", + "aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -component=main,contrib snap1 snap2 ppa", ] runCmd = "aptly publish list" diff --git a/system/t06_publish/repo.py b/system/t06_publish/repo.py index 7232d57e..a11924fa 100644 --- a/system/t06_publish/repo.py +++ b/system/t06_publish/repo.py @@ -382,3 +382,166 @@ class PublishRepo16Test(BaseTest): self.check_exists('public/dists/maverick/main/source/Sources') self.check_exists('public/dists/maverick/main/source/Sources.gz') self.check_exists('public/dists/maverick/main/source/Sources.bz2') + + +class PublishRepo17Test(BaseTest): + """ + publish repo: multiple component + """ + fixtureCmds = [ + "aptly repo create repo1", + "aptly repo create repo2", + "aptly repo add repo1 ${files}/libboost-program-options-dev_1.49.0.1_i386.deb ${files}/pyspi_0.6.1-1.3.dsc", + "aptly repo add repo2 ${files}/pyspi-0.6.1-1.3.stripped.dsc", + ] + runCmd = "aptly publish repo -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -component=main,contrib -distribution=maverick repo1 repo2" + gold_processor = BaseTest.expand_environ + + def check(self): + super(PublishRepo17Test, self).check() + + self.check_exists('public/dists/maverick/InRelease') + self.check_exists('public/dists/maverick/Release') + self.check_exists('public/dists/maverick/Release.gpg') + + self.check_exists('public/dists/maverick/main/binary-i386/Packages') + self.check_exists('public/dists/maverick/main/binary-i386/Packages.gz') + self.check_exists('public/dists/maverick/main/binary-i386/Packages.bz2') + self.check_exists('public/dists/maverick/main/source/Sources') + self.check_exists('public/dists/maverick/main/source/Sources.gz') + self.check_exists('public/dists/maverick/main/source/Sources.bz2') + + self.check_exists('public/dists/maverick/contrib/binary-i386/Packages') + self.check_exists('public/dists/maverick/contrib/binary-i386/Packages.gz') + self.check_exists('public/dists/maverick/contrib/binary-i386/Packages.bz2') + self.check_exists('public/dists/maverick/contrib/source/Sources') + self.check_exists('public/dists/maverick/contrib/source/Sources.gz') + self.check_exists('public/dists/maverick/contrib/source/Sources.bz2') + + self.check_exists('public/pool/main/p/pyspi/pyspi_0.6.1-1.3.dsc') + self.check_exists('public/pool/main/p/pyspi/pyspi_0.6.1-1.3.diff.gz') + self.check_exists('public/pool/main/p/pyspi/pyspi_0.6.1.orig.tar.gz') + self.check_exists('public/pool/main/b/boost-defaults/libboost-program-options-dev_1.49.0.1_i386.deb') + + self.check_exists('public/pool/contrib/p/pyspi/pyspi_0.6.1-1.3.diff.gz') + self.check_exists('public/pool/contrib/p/pyspi/pyspi_0.6.1.orig.tar.gz') + self.check_exists('public/pool/contrib/p/pyspi/pyspi-0.6.1-1.3.stripped.dsc') + + # verify contents except of sums + self.check_file_contents('public/dists/maverick/Release', 'release', match_prepare=strip_processor) + + # verify signatures + self.run_cmd(["gpg", "--no-auto-check-trustdb", "--keyring", os.path.join(os.path.dirname(inspect.getsourcefile(BaseTest)), "files", "aptly.pub"), + "--verify", os.path.join(os.environ["HOME"], ".aptly", 'public/dists/maverick/InRelease')]) + self.run_cmd(["gpg", "--no-auto-check-trustdb", "--keyring", os.path.join(os.path.dirname(inspect.getsourcefile(BaseTest)), "files", "aptly.pub"), + "--verify", os.path.join(os.environ["HOME"], ".aptly", 'public/dists/maverick/Release.gpg'), + os.path.join(os.environ["HOME"], ".aptly", 'public/dists/maverick/Release')]) + + # verify sums + release = self.read_file('public/dists/maverick/Release').split("\n") + release = [l for l in release if l.startswith(" ")] + pathsSeen = set() + for l in release: + fileHash, fileSize, path = l.split() + pathsSeen.add(path) + + fileSize = int(fileSize) + + st = os.stat(os.path.join(os.environ["HOME"], ".aptly", 'public/dists/maverick/', path)) + if fileSize != st.st_size: + raise Exception("file size doesn't match for %s: %d != %d" % (path, fileSize, st.st_size)) + + if len(fileHash) == 32: + h = hashlib.md5() + elif len(fileHash) == 40: + h = hashlib.sha1() + else: + h = hashlib.sha256() + + h.update(self.read_file(os.path.join('public/dists/maverick', path))) + + if h.hexdigest() != fileHash: + raise Exception("file hash doesn't match for %s: %s != %s" % (path, fileHash, h.hexdigest())) + + if pathsSeen != set(['main/binary-i386/Packages', 'main/binary-i386/Packages.gz', + 'main/binary-i386/Packages.bz2', + 'main/source/Sources', 'main/source/Sources.gz', 'main/source/Sources.bz2', + 'contrib/binary-i386/Packages', 'contrib/binary-i386/Packages.gz', + 'contrib/binary-i386/Packages.bz2', + 'contrib/source/Sources', 'contrib/source/Sources.gz', 'contrib/source/Sources.bz2']): + raise Exception("path seen wrong: %r" % (pathsSeen, )) + + +class PublishRepo18Test(BaseTest): + """ + publish repo: multiple component, guessing component names + """ + fixtureCmds = [ + "aptly repo create -distribution=squeeze -component=main repo1", + "aptly repo create -distribution=squeeze -component=contrib repo2", + "aptly repo add repo1 ${files}/libboost-program-options-dev_1.49.0.1_i386.deb ${files}/pyspi_0.6.1-1.3.dsc", + "aptly repo add repo2 ${files}/pyspi-0.6.1-1.3.stripped.dsc", + ] + runCmd = "aptly publish repo -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -component=, repo1 repo2" + gold_processor = BaseTest.expand_environ + + +class PublishRepo19Test(BaseTest): + """ + publish repo: duplicate component name (guessed) + """ + fixtureCmds = [ + "aptly repo create -distribution=squeeze -component=contrib repo1", + "aptly repo create -distribution=squeeze -component=contrib repo2", + "aptly repo add repo1 ${files}/libboost-program-options-dev_1.49.0.1_i386.deb ${files}/pyspi_0.6.1-1.3.dsc", + "aptly repo add repo2 ${files}/pyspi-0.6.1-1.3.stripped.dsc", + ] + runCmd = "aptly publish repo -component=, repo1 repo2" + expectedCode = 1 + + +class PublishRepo20Test(BaseTest): + """ + publish repo: duplicate component name (manual) + """ + fixtureCmds = [ + "aptly repo create -distribution=squeeze -component=main repo1", + "aptly repo create -distribution=squeeze -component=contrib repo2", + ] + runCmd = "aptly publish repo -component=b,b repo1 repo2" + expectedCode = 1 + + +class PublishRepo21Test(BaseTest): + """ + publish repo: distribution conflict + """ + fixtureCmds = [ + "aptly repo create -distribution=squeeze -component=main repo1", + "aptly repo create -distribution=wheezy -component=contrib repo2", + ] + runCmd = "aptly publish repo -component=, repo1 repo2" + expectedCode = 1 + + +class PublishRepo22Test(BaseTest): + """ + publish reop: no such repo + """ + fixtureCmds = [ + "aptly repo create -distribution=squeeze -component=main repo1", + ] + runCmd = "aptly publish repo -component=, repo1 repo2" + expectedCode = 1 + + +class PublishRepo23Test(BaseTest): + """ + publish repo: mismatch in count + """ + fixtureCmds = [ + "aptly repo create -distribution=squeeze -component=main repo1", + ] + runCmd = "aptly publish repo -component=main,contrib repo1" + expectedCode = 2 + outputMatchPrepare = lambda _, s: "\n".join([l for l in s.split("\n") if l.startswith("ERROR")]) diff --git a/system/t06_publish/snapshot.py b/system/t06_publish/snapshot.py index dd33b20a..f830ddd0 100644 --- a/system/t06_publish/snapshot.py +++ b/system/t06_publish/snapshot.py @@ -601,3 +601,178 @@ class PublishSnapshot25Test(BaseTest): self.check_exists('public/dists/maverick/main/binary-amd64/Packages') self.check_exists('public/dists/maverick/main/binary-amd64/Packages.gz') self.check_exists('public/dists/maverick/main/binary-amd64/Packages.bz2') + + +class PublishSnapshot26Test(BaseTest): + """ + publish snapshot: multiple component + """ + fixtureDB = True + fixturePool = True + fixtureCmds = [ + "aptly snapshot create snap26.1 from mirror gnuplot-maverick", + "aptly repo create local-repo", + "aptly repo add local-repo ${files}", + "aptly snapshot create snap26.2 from repo local-repo", + ] + runCmd = "aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -component=main,contrib snap26.1 snap26.2" + gold_processor = BaseTest.expand_environ + + def check(self): + super(PublishSnapshot26Test, self).check() + + self.check_exists('public/dists/maverick/InRelease') + self.check_exists('public/dists/maverick/Release') + self.check_exists('public/dists/maverick/Release.gpg') + + self.check_exists('public/dists/maverick/main/binary-i386/Packages') + self.check_exists('public/dists/maverick/main/binary-i386/Packages.gz') + self.check_exists('public/dists/maverick/main/binary-i386/Packages.bz2') + self.check_exists('public/dists/maverick/main/binary-amd64/Packages') + self.check_exists('public/dists/maverick/main/binary-amd64/Packages.gz') + self.check_exists('public/dists/maverick/main/binary-amd64/Packages.bz2') + self.check_exists('public/dists/maverick/main/source/Sources') + self.check_exists('public/dists/maverick/main/source/Sources.gz') + self.check_exists('public/dists/maverick/main/source/Sources.bz2') + + self.check_exists('public/dists/maverick/contrib/binary-i386/Packages') + self.check_exists('public/dists/maverick/contrib/binary-i386/Packages.gz') + self.check_exists('public/dists/maverick/contrib/binary-i386/Packages.bz2') + self.check_exists('public/dists/maverick/contrib/binary-amd64/Packages') + self.check_exists('public/dists/maverick/contrib/binary-amd64/Packages.gz') + self.check_exists('public/dists/maverick/contrib/binary-amd64/Packages.bz2') + self.check_exists('public/dists/maverick/contrib/source/Sources') + self.check_exists('public/dists/maverick/contrib/source/Sources.gz') + self.check_exists('public/dists/maverick/contrib/source/Sources.bz2') + + self.check_exists('public/pool/main/g/gnuplot/gnuplot-doc_4.6.1-1~maverick2_all.deb') + self.check_exists('public/pool/contrib/p/pyspi/pyspi_0.6.1-1.3.dsc') + self.check_exists('public/pool/contrib/p/pyspi/pyspi_0.6.1-1.3.diff.gz') + self.check_exists('public/pool/contrib/p/pyspi/pyspi_0.6.1.orig.tar.gz') + self.check_exists('public/pool/contrib/p/pyspi/pyspi-0.6.1-1.3.stripped.dsc') + self.check_exists('public/pool/contrib/b/boost-defaults/libboost-program-options-dev_1.49.0.1_i386.deb') + + # verify contents except of sums + self.check_file_contents('public/dists/maverick/Release', 'release', match_prepare=strip_processor) + + # verify signatures + self.run_cmd(["gpg", "--no-auto-check-trustdb", "--keyring", os.path.join(os.path.dirname(inspect.getsourcefile(BaseTest)), "files", "aptly.pub"), + "--verify", os.path.join(os.environ["HOME"], ".aptly", 'public/dists/maverick/InRelease')]) + self.run_cmd(["gpg", "--no-auto-check-trustdb", "--keyring", os.path.join(os.path.dirname(inspect.getsourcefile(BaseTest)), "files", "aptly.pub"), + "--verify", os.path.join(os.environ["HOME"], ".aptly", 'public/dists/maverick/Release.gpg'), + os.path.join(os.environ["HOME"], ".aptly", 'public/dists/maverick/Release')]) + + # verify sums + release = self.read_file('public/dists/maverick/Release').split("\n") + release = [l for l in release if l.startswith(" ")] + pathsSeen = set() + for l in release: + fileHash, fileSize, path = l.split() + pathsSeen.add(path) + + fileSize = int(fileSize) + + st = os.stat(os.path.join(os.environ["HOME"], ".aptly", 'public/dists/maverick/', path)) + if fileSize != st.st_size: + raise Exception("file size doesn't match for %s: %d != %d" % (path, fileSize, st.st_size)) + + if len(fileHash) == 32: + h = hashlib.md5() + elif len(fileHash) == 40: + h = hashlib.sha1() + else: + h = hashlib.sha256() + + h.update(self.read_file(os.path.join('public/dists/maverick', path))) + + if h.hexdigest() != fileHash: + raise Exception("file hash doesn't match for %s: %s != %s" % (path, fileHash, h.hexdigest())) + + if pathsSeen != set(['main/binary-amd64/Packages', 'main/binary-i386/Packages', 'main/binary-i386/Packages.gz', + 'main/binary-amd64/Packages.gz', 'main/binary-amd64/Packages.bz2', 'main/binary-i386/Packages.bz2', + 'main/source/Sources', 'main/source/Sources.gz', 'main/source/Sources.bz2', + 'contrib/binary-amd64/Packages', 'contrib/binary-i386/Packages', 'contrib/binary-i386/Packages.gz', + 'contrib/binary-amd64/Packages.gz', 'contrib/binary-amd64/Packages.bz2', 'contrib/binary-i386/Packages.bz2', + 'contrib/source/Sources', 'contrib/source/Sources.gz', 'contrib/source/Sources.bz2',]): + raise Exception("path seen wrong: %r" % (pathsSeen, )) + + +class PublishSnapshot27Test(BaseTest): + """ + publish snapshot: multiple component, guessing component names + """ + fixtureDB = True + fixturePool = True + fixtureCmds = [ + "aptly snapshot create snap27.1 from mirror gnuplot-maverick", + "aptly repo create -component=contrib local-repo", + "aptly repo add local-repo ${files}", + "aptly snapshot create snap27.2 from repo local-repo", + ] + runCmd = "aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -component=, snap27.1 snap27.2" + gold_processor = BaseTest.expand_environ + + +class PublishSnapshot28Test(BaseTest): + """ + publish snapshot: duplicate component name (guessed) + """ + fixtureDB = True + fixtureCmds = [ + "aptly snapshot create snap28.1 from mirror gnuplot-maverick", + "aptly repo create local-repo", + "aptly repo add local-repo ${files}", + "aptly snapshot create snap28.2 from repo local-repo", + ] + runCmd = "aptly publish snapshot -component=, snap28.1 snap28.2" + expectedCode = 1 + + +class PublishSnapshot29Test(BaseTest): + """ + publish snapshot: duplicate component name (manual) + """ + fixtureCmds = [ + "aptly snapshot create snap29.1 empty", + "aptly snapshot create snap29.2 empty", + ] + runCmd = "aptly publish snapshot -component=b,b snap29.1 snap29.2" + expectedCode = 1 + + +class PublishSnapshot30Test(BaseTest): + """ + publish snapshot: distribution conflict + """ + fixtureDB = True + fixtureCmds = [ + "aptly snapshot create snap30.1 from mirror gnuplot-maverick", + "aptly repo create -distribution=squeeze local-repo", + "aptly repo add local-repo ${files}", + "aptly snapshot create snap30.2 from repo local-repo", + ] + runCmd = "aptly publish snapshot -component=main,contrib snap30.1 snap30.2" + expectedCode = 1 + + +class PublishSnapshot31Test(BaseTest): + """ + publish snapshot: no such snapshot + """ + fixtureCmds = [ + "aptly snapshot create snap31.1 empty", + ] + runCmd = "aptly publish snapshot -component=main,contrib snap31.1 snap31.2" + expectedCode = 1 + + +class PublishSnapshot32Test(BaseTest): + """ + publish snapshot: mismatch in count + """ + fixtureCmds = [ + "aptly snapshot create snap32.1 empty", + ] + runCmd = "aptly publish snapshot -component=main,contrib snap32.1" + expectedCode = 2 + outputMatchPrepare = lambda _, s: "\n".join([l for l in s.split("\n") if l.startswith("ERROR")]) diff --git a/system/t07_serve/Serve1Test_gold b/system/t07_serve/Serve1Test_gold index d6abfd59..58a1893f 100644 --- a/system/t07_serve/Serve1Test_gold +++ b/system/t07_serve/Serve1Test_gold @@ -5,5 +5,8 @@ deb http://127.0.0.1:8765/ maverick main # debian/maverick [amd64, i386, source] publishes {main: [snap2]: Snapshot from mirror [gnuplot-maverick-src]: http://ppa.launchpad.net/gladky-anton/gnuplot/ubuntu/ maverick [src]} deb http://127.0.0.1:8765/debian/ maverick main deb-src http://127.0.0.1:8765/debian/ maverick main +# multi/maverick [amd64, i386, source] publishes {main: [snap1]: Snapshot from mirror [gnuplot-maverick]: http://ppa.launchpad.net/gladky-anton/gnuplot/ubuntu/ maverick}, {contrib: [snap2]: Snapshot from mirror [gnuplot-maverick-src]: http://ppa.launchpad.net/gladky-anton/gnuplot/ubuntu/ maverick [src]} +deb http://127.0.0.1:8765/multi/ maverick contrib main +deb-src http://127.0.0.1:8765/multi/ maverick contrib main Starting web server at: 127.0.0.1:8765 (press Ctrl+C to quit)... diff --git a/system/t07_serve/Serve1Test_http b/system/t07_serve/Serve1Test_http index ebe82606..0b6d4468 100644 --- a/system/t07_serve/Serve1Test_http +++ b/system/t07_serve/Serve1Test_http @@ -1,5 +1,6 @@
 debian/
 dists/
+multi/
 pool/
 
diff --git a/system/t07_serve/__init__.py b/system/t07_serve/__init__.py index f986a710..f06f99c4 100644 --- a/system/t07_serve/__init__.py +++ b/system/t07_serve/__init__.py @@ -23,6 +23,7 @@ class Serve1Test(BaseTest): "aptly snapshot create snap2 from mirror gnuplot-maverick-src", "aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec snap1", "aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec snap2 debian", + "aptly publish snapshot -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -component=main,contrib snap1 snap2 multi", ] runCmd = "aptly serve -listen=127.0.0.1:8765"