Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAndrew Gregory <andrew.gregory.8@gmail.com>2021-01-19 10:30:10 -0800
committerAllan McRae <allan@archlinux.org>2021-01-21 17:19:26 +1000
commitb40c5553b43633f4b9bd01310e0ae8ff56147723 (patch)
tree3f2a03fd03ae2c4ba4a936f1c096c20586105937 /test
parentb82a975e7640853fe0fde5c164ad4ad5bf64fbf7 (diff)
add --upgrade download tests
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'test')
-rw-r--r--test/pacman/meson.build3
-rw-r--r--test/pacman/tests/upgrade-download-404.py10
-rw-r--r--test/pacman/tests/upgrade-download-pkg-and-sig-with-filename.py61
-rw-r--r--test/pacman/tests/upgrade-download-pkg-and-sig-without-filename.py63
4 files changed, 137 insertions, 0 deletions
diff --git a/test/pacman/meson.build b/test/pacman/meson.build
index fd0dbf90..52ff9b9a 100644
--- a/test/pacman/meson.build
+++ b/test/pacman/meson.build
@@ -328,6 +328,9 @@ pacman_tests = [
'tests/upgrade090.py',
'tests/upgrade100.py',
'tests/xfercommand001.py',
+ 'tests/upgrade-download-404.py',
+ 'tests/upgrade-download-pkg-and-sig-with-filename.py',
+ 'tests/upgrade-download-pkg-and-sig-without-filename.py',
]
xfail_tests = {
diff --git a/test/pacman/tests/upgrade-download-404.py b/test/pacman/tests/upgrade-download-404.py
new file mode 100644
index 00000000..ed5ad2b4
--- /dev/null
+++ b/test/pacman/tests/upgrade-download-404.py
@@ -0,0 +1,10 @@
+self.description = 'download a remote package with -U'
+self.require_capability("curl")
+
+url = self.add_simple_http_server({})
+
+self.args = '-Uw {url}/foo.pkg'.format(url=url)
+
+self.addrule('!PACMAN_RETCODE=0')
+self.addrule('!CACHE_FEXISTS=foo.pkg')
+self.addrule('!CACHE_FEXISTS=foo.pkg.sig')
diff --git a/test/pacman/tests/upgrade-download-pkg-and-sig-with-filename.py b/test/pacman/tests/upgrade-download-pkg-and-sig-with-filename.py
new file mode 100644
index 00000000..ac5072c9
--- /dev/null
+++ b/test/pacman/tests/upgrade-download-pkg-and-sig-with-filename.py
@@ -0,0 +1,61 @@
+self.description = 'download remote packages with -U with a URL filename'
+self.require_capability("gpg")
+self.require_capability("curl")
+
+url = self.add_simple_http_server({
+ # simple
+ '/simple.pkg': 'simple',
+ '/simple.pkg.sig': {
+ 'headers': { 'Content-Disposition': 'attachment; filename="simple.sig-alt' },
+ 'body': 'simple.sig',
+ },
+
+ # content-disposition filename
+ '/cd.pkg': {
+ 'headers': { 'Content-Disposition': 'attachment; filename="cd-alt.pkg"' },
+ 'body': 'cd'
+ },
+ '/cd.pkg.sig': 'cd.sig',
+
+ # redirect
+ '/redir.pkg': { 'code': 303, 'headers': { 'Location': '/redir-dest.pkg' } },
+ '/redir-dest.pkg': 'redir-dest',
+ '/redir-dest.pkg.sig': 'redir-dest.sig',
+
+ # content-disposition and redirect
+ '/cd-redir.pkg': { 'code': 303, 'headers': { 'Location': '/cd-redir-dest.pkg' } },
+ '/cd-redir-dest.pkg': {
+ 'headers': { 'Content-Disposition': 'attachment; filename="cd-redir-dest-alt.pkg"' },
+ 'body': 'cd-redir-dest'
+ },
+ '/cd-redir-dest.pkg.sig': 'cd-redir-dest.sig',
+
+ # TODO: absolutely terrible hack to prevent pacman from attempting to
+ # validate packages, which causes failure under --valgrind thanks to
+ # a memory leak in gpgme that is too general for inclusion in valgrind.supp
+ '/404': { 'code': 404 },
+
+ '': 'fallback',
+})
+
+self.args = '-Uw {url}/simple.pkg {url}/cd.pkg {url}/redir.pkg {url}/cd-redir.pkg {url}/404'.format(url=url)
+
+# packages/sigs are not valid, error is expected
+self.addrule('!PACMAN_RETCODE=0')
+
+self.addrule('CACHE_FCONTENTS=simple.pkg|simple')
+self.addrule('CACHE_FCONTENTS=simple.pkg.sig|simple.sig')
+
+self.addrule('!CACHE_FEXISTS=cd.pkg')
+self.addrule('!CACHE_FEXISTS=cd.pkg.sig')
+self.addrule('CACHE_FCONTENTS=cd-alt.pkg|cd')
+self.addrule('CACHE_FCONTENTS=cd-alt.pkg.sig|cd.sig')
+
+self.addrule('!CACHE_FEXISTS=redir.pkg')
+self.addrule('CACHE_FCONTENTS=redir-dest.pkg|redir-dest')
+self.addrule('CACHE_FCONTENTS=redir-dest.pkg.sig|redir-dest.sig')
+
+self.addrule('!CACHE_FEXISTS=cd-redir.pkg')
+self.addrule('!CACHE_FEXISTS=cd-redir-dest.pkg')
+self.addrule('CACHE_FCONTENTS=cd-redir-dest-alt.pkg|cd-redir-dest')
+self.addrule('CACHE_FCONTENTS=cd-redir-dest-alt.pkg.sig|cd-redir-dest.sig')
diff --git a/test/pacman/tests/upgrade-download-pkg-and-sig-without-filename.py b/test/pacman/tests/upgrade-download-pkg-and-sig-without-filename.py
new file mode 100644
index 00000000..651fb3f5
--- /dev/null
+++ b/test/pacman/tests/upgrade-download-pkg-and-sig-without-filename.py
@@ -0,0 +1,63 @@
+self.description = 'download remote packages with -U without a URL filename'
+self.require_capability("gpg")
+self.require_capability("curl")
+
+url = self.add_simple_http_server({
+ # simple
+ '/simple.pkg/': 'simple',
+ '/simple.pkg/.sig': 'simple.sig',
+
+ # content-disposition filename
+ '/cd.pkg/': {
+ 'headers': { 'Content-Disposition': 'attachment; filename="cd-alt.pkg"' },
+ 'body': 'cd'
+ },
+ '/cd.pkg/.sig': {
+ 'headers': { 'Content-Disposition': 'attachment; filename="cd-alt-bad.pkg.sig"' },
+ 'body': 'cd.sig'
+ },
+
+ # redirect
+ '/redir.pkg/': { 'code': 303, 'headers': { 'Location': '/redir-dest.pkg' } },
+ '/redir-dest.pkg': 'redir-dest',
+ '/redir-dest.pkg.sig': 'redir-dest.sig',
+
+ # content-disposition and redirect
+ '/cd-redir.pkg/': { 'code': 303, 'headers': { 'Location': '/cd-redir-dest.pkg' } },
+ '/cd-redir-dest.pkg': {
+ 'headers': { 'Content-Disposition': 'attachment; filename="cd-redir-dest-alt.pkg"' },
+ 'body': 'cd-redir-dest'
+ },
+ '/cd-redir-dest.pkg.sig': 'cd-redir-dest.sig',
+
+ # TODO: absolutely terrible hack to prevent pacman from attempting to
+ # validate packages, which causes failure under --valgrind thanks to
+ # a memory leak in gpgme that is too general for inclusion in valgrind.supp
+ '/404': { 'code': 404 },
+
+ '': 'fallback',
+})
+
+self.args = '-Uw {url}/simple.pkg/ {url}/cd.pkg/ {url}/redir.pkg/ {url}/cd-redir.pkg/ {url}/404'.format(url=url)
+
+# packages/sigs are not valid, error is expected
+self.addrule('!PACMAN_RETCODE=0')
+
+# TODO: use a predictable file name
+#self.addrule('CACHE_FCONTENTS=simple.pkg|simple')
+#self.addrule('CACHE_FCONTENTS=simple.pkg.sig|simple.sig')
+
+self.addrule('!CACHE_FEXISTS=cd.pkg')
+self.addrule('CACHE_FCONTENTS=cd-alt.pkg|cd')
+self.addrule('CACHE_FCONTENTS=cd-alt.pkg.sig|cd.sig')
+
+self.addrule('!CACHE_FEXISTS=redir.pkg')
+self.addrule('CACHE_FCONTENTS=redir-dest.pkg|redir-dest')
+self.addrule('CACHE_FCONTENTS=redir-dest.pkg.sig|redir-dest.sig')
+
+self.addrule('!CACHE_FEXISTS=cd-redir.pkg')
+self.addrule('!CACHE_FEXISTS=cd-redir-dest.pkg')
+self.addrule('CACHE_FCONTENTS=cd-redir-dest-alt.pkg|cd-redir-dest')
+self.addrule('CACHE_FCONTENTS=cd-redir-dest-alt.pkg.sig|cd-redir-dest.sig')
+
+self.addrule('!CACHE_FEXISTS=.sig')