Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unit tests fail for python3 #19

Open
williamgibb opened this issue Nov 2, 2015 · 2 comments · May be fixed by #20
Open

unit tests fail for python3 #19

williamgibb opened this issue Nov 2, 2015 · 2 comments · May be fixed by #20

Comments

@williamgibb
Copy link

The constant time function from django source code fails on python3

D:\TEMP\python-jws>python3 -m unittest --verbose jws.tests.TestJWS_hmac
test_invalid_hmac (jws.tests.TestJWS_hmac) ... ok
test_valid_hmac256 (jws.tests.TestJWS_hmac) ... ERROR
test_valid_hmac384 (jws.tests.TestJWS_hmac) ... ERROR
test_valid_hmac512 (jws.tests.TestJWS_hmac) ... ERROR

======================================================================
ERROR: test_valid_hmac256 (jws.tests.TestJWS_hmac)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\TEMP\python-jws\jws\tests.py", line 128, in test_valid_hmac256
    self.assertTrue(jws.verify(header, self.payload, sig, 'secret'))
  File "C:\TEMP\python-jws\jws\__init__.py", line 48, in verify
    return verifier(_signing_input(head, payload, is_json), signature, key)
  File "C:\TEMP\python-jws\jws\algos.py", line 46, in verify
    if not constant_time_compare(self.sign(msg, key), crypto):
  File "C:\TEMP\python-jws\jws\utils.py", line 54, in constant_time_compare
    result |= ord(x) ^ ord(y)
TypeError: ord() expected string of length 1, but int found

======================================================================
ERROR: test_valid_hmac384 (jws.tests.TestJWS_hmac)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\TEMP\python-jws\jws\tests.py", line 134, in test_valid_hmac384
    self.assertTrue(jws.verify(header, self.payload, sig, 'secret'))
  File "C:\TEMP\python-jws\jws\__init__.py", line 48, in verify
    return verifier(_signing_input(head, payload, is_json), signature, key)
  File "C:\TEMP\python-jws\jws\algos.py", line 46, in verify
    if not constant_time_compare(self.sign(msg, key), crypto):
  File "C:\TEMP\python-jws\jws\utils.py", line 54, in constant_time_compare
    result |= ord(x) ^ ord(y)
TypeError: ord() expected string of length 1, but int found

======================================================================
ERROR: test_valid_hmac512 (jws.tests.TestJWS_hmac)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\TEMP\python-jws\jws\tests.py", line 140, in test_valid_hmac512
    self.assertTrue(jws.verify(header, self.payload, sig, 'secret'))
  File "C:\TEMP\python-jws\jws\__init__.py", line 48, in verify
    return verifier(_signing_input(head, payload, is_json), signature, key)
  File "C:\TEMP\python-jws\jws\algos.py", line 46, in verify
    if not constant_time_compare(self.sign(msg, key), crypto):
  File "C:\TEMP\python-jws\jws\utils.py", line 54, in constant_time_compare
    result |= ord(x) ^ ord(y)
TypeError: ord() expected string of length 1, but int found

----------------------------------------------------------------------
Ran 4 tests in 0.031s
@williamgibb williamgibb linked a pull request Nov 2, 2015 that will close this issue
@williamgibb
Copy link
Author

If this is fixed can a new version of python-jws please be published on pypi?

@gwendoline-goetz
Copy link

Fix available here:
gwendoline-goetz/python-jws@a8ae98b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants