litl / rauth

A Python library for OAuth 1.0/a, 2.0, and Ofly.
http://readthedocs.org/docs/rauth/en/latest/
MIT License
1.6k stars 175 forks source link

test_oauth.OAuthTestRsaSha1Case throws errors with PyCryptodome #210

Open neirbowj opened 3 years ago

neirbowj commented 3 years ago

When the Crypto package dependency is met with PyCryptodome instead of PyCrypto, rauth.oauth.RsaSha1Signature raises AttributeError because the internal implementation details differ in Crypto.PublicKey.RSA.

======================================================================
======================================================================
ERROR: test_rsasha1_badargument (test_oauth.OAuthTestRsaSha1Case)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/neirbowj/src/github/rauth/tests/test_oauth.py", line 214, in test_rsasha1_badargument
    self.req_kwargs)
  File "/usr/local/lib/python2.7/unittest/case.py", line 473, in assertRaises
    callableObj(*args, **kwargs)
  File "/home/neirbowj/src/github/rauth/rauth/oauth.py", line 211, in sign
    if not isinstance(consumer_secret, self.RSA._RSAobj):
AttributeError: 'module' object has no attribute '_RSAobj'

======================================================================
ERROR: test_rsasha1_signature (test_oauth.OAuthTestRsaSha1Case)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/neirbowj/src/github/rauth/tests/test_oauth.py", line 199, in test_rsasha1_signature
    self.req_kwargs)
  File "/home/neirbowj/src/github/rauth/rauth/oauth.py", line 211, in sign
    if not isinstance(consumer_secret, self.RSA._RSAobj):
AttributeError: 'module' object has no attribute '_RSAobj'
neirbowj commented 3 years ago

Based on source code analysis, it should also be fine to remove the isinstance check entirely, because both implementations either return a valid object or raise an exception.