summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCédric Krier <cedk@gentoo.org>2021-07-11 10:50:10 +0200
committerCédric Krier <cedk@gentoo.org>2021-07-11 10:51:00 +0200
commit70253d13d429a7610dfff8fac39afd8561429a06 (patch)
treecf6ab04547d0d76112166bd0f411e3c0e40f977a /www-apps/roundup
parentwww-apps/nanoc: add 4.12.2 (diff)
downloadgentoo-70253d13d429a7610dfff8fac39afd8561429a06.tar.gz
gentoo-70253d13d429a7610dfff8fac39afd8561429a06.tar.bz2
gentoo-70253d13d429a7610dfff8fac39afd8561429a06.zip
www-apps/roundup: Fix test with pyjwt 2
Closes: https://bugs.gentoo.org/793431 Package-Manager: Portage-3.0.20, Repoman-3.0.2 Signed-off-by: Cédric Krier <cedk@gentoo.org>
Diffstat (limited to 'www-apps/roundup')
-rw-r--r--www-apps/roundup/files/roundup-2.0.0-test-pyjwt.patch91
-rw-r--r--www-apps/roundup/roundup-2.0.0.ebuild3
2 files changed, 94 insertions, 0 deletions
diff --git a/www-apps/roundup/files/roundup-2.0.0-test-pyjwt.patch b/www-apps/roundup/files/roundup-2.0.0-test-pyjwt.patch
new file mode 100644
index 000000000000..74f71dab57ff
--- /dev/null
+++ b/www-apps/roundup/files/roundup-2.0.0-test-pyjwt.patch
@@ -0,0 +1,91 @@
+# HG changeset patch
+# User John Rouillard <rouilj@ieee.org>
+# Date 1609557405 18000
+# Fri Jan 01 22:16:45 2021 -0500
+# Node ID a2fbd3592322379f0c54a75446d2a282c6f40075
+# Parent e3edb0b44d94df71f46094cdda9ed4e51e6c1de4
+pyjwt 2.00 changed return type of jwt.encode from byte to str
+
+Need to change tests to only do b2s conversion if using version before
+2.0.0. Note 2.0.0 drops support for python 2. Also it is not
+installed for the python 3.4 ci test by pip install.
+
+diff --git a/test/rest_common.py b/test/rest_common.py
+--- a/test/rest_common.py
++++ b/test/rest_common.py
+@@ -68,6 +68,8 @@ class TestCase():
+ url_pfx = 'http://tracker.example/cgi-bin/roundup.cgi/bugs/rest/data/'
+
+ def setUp(self):
++ from packaging import version
++
+ self.dirname = '_test_rest'
+ # set up and open a tracker
+ # Set optimize=True as code under test (Client.main()::determine_user)
+@@ -162,50 +164,58 @@ class TestCase():
+ 'iat': now_ts,
+ 'exp': plus1min_ts,
+ }
++
++ # in version 2.0.0 and newer jwt.encode returns string
++ # not bytestring. So we have to skip b2s conversion
+
++ if version.parse(jwt.__version__) >= version.parse('2.0.0'):
++ tostr = lambda x: x
++ else:
++ tostr = b2s
++
+ self.jwt = {}
+ self.claim = {}
+ # generate invalid claim with expired timestamp
+ self.claim['expired'] = copy(claim)
+ self.claim['expired']['exp'] = expired_ts
+- self.jwt['expired'] = b2s(jwt.encode(self.claim['expired'], secret,
++ self.jwt['expired'] = tostr(jwt.encode(self.claim['expired'], secret,
+ algorithm='HS256'))
+
+ # generate valid claim with user role
+ self.claim['user'] = copy(claim)
+ self.claim['user']['exp'] = plus1min_ts
+- self.jwt['user'] = b2s(jwt.encode(self.claim['user'], secret,
++ self.jwt['user'] = tostr(jwt.encode(self.claim['user'], secret,
+ algorithm='HS256'))
+ # generate invalid claim bad issuer
+ self.claim['badiss'] = copy(claim)
+ self.claim['badiss']['iss'] = "http://someissuer/bugs"
+- self.jwt['badiss'] = b2s(jwt.encode(self.claim['badiss'], secret,
++ self.jwt['badiss'] = tostr(jwt.encode(self.claim['badiss'], secret,
+ algorithm='HS256'))
+ # generate invalid claim bad aud(ience)
+ self.claim['badaud'] = copy(claim)
+ self.claim['badaud']['aud'] = "http://someaudience/bugs"
+- self.jwt['badaud'] = b2s(jwt.encode(self.claim['badaud'], secret,
++ self.jwt['badaud'] = tostr(jwt.encode(self.claim['badaud'], secret,
+ algorithm='HS256'))
+ # generate invalid claim bad sub(ject)
+ self.claim['badsub'] = copy(claim)
+ self.claim['badsub']['sub'] = str("99")
+- self.jwt['badsub'] = b2s(jwt.encode(self.claim['badsub'], secret,
++ self.jwt['badsub'] = tostr(jwt.encode(self.claim['badsub'], secret,
+ algorithm='HS256'))
+ # generate invalid claim bad roles
+ self.claim['badroles'] = copy(claim)
+ self.claim['badroles']['roles'] = [ "badrole1", "badrole2" ]
+- self.jwt['badroles'] = b2s(jwt.encode(self.claim['badroles'], secret,
++ self.jwt['badroles'] = tostr(jwt.encode(self.claim['badroles'], secret,
+ algorithm='HS256'))
+ # generate valid claim with limited user:email role
+ self.claim['user:email'] = copy(claim)
+ self.claim['user:email']['roles'] = [ "user:email" ]
+- self.jwt['user:email'] = b2s(jwt.encode(self.claim['user:email'], secret,
++ self.jwt['user:email'] = tostr(jwt.encode(self.claim['user:email'], secret,
+ algorithm='HS256'))
+
+ # generate valid claim with limited user:emailnorest role
+ self.claim['user:emailnorest'] = copy(claim)
+ self.claim['user:emailnorest']['roles'] = [ "user:emailnorest" ]
+- self.jwt['user:emailnorest'] = b2s(jwt.encode(self.claim['user:emailnorest'], secret,
++ self.jwt['user:emailnorest'] = tostr(jwt.encode(self.claim['user:emailnorest'], secret,
+ algorithm='HS256'))
+
+ self.db.tx_Source = 'web'
diff --git a/www-apps/roundup/roundup-2.0.0.ebuild b/www-apps/roundup/roundup-2.0.0.ebuild
index 335af1be6ac9..a66c26f72f10 100644
--- a/www-apps/roundup/roundup-2.0.0.ebuild
+++ b/www-apps/roundup/roundup-2.0.0.ebuild
@@ -36,6 +36,9 @@ RDEPEND="${DEPEND}
)"
DOCS="CHANGES.txt doc/*.txt"
+PATCHES=(
+ "${FILESDIR}/${P}-test-pyjwt.patch"
+)
distutils_enable_tests pytest