commit 6e0fe68321cb88f83c7e9d37f4458e10551a33b9 Author: Damian Johnson atagar@torproject.org Date: Sat Jan 18 16:55:11 2020 -0800
Fix crypto tests
This corrects the following...
Traceback (most recent call last): File "/home/atagar/Desktop/tor/bridgedb/bridgedb/test/test_crypto.py", line 226, in test_crypto_initializeGnuPG_nonexistent_default_key gpg, signfunc = crypto.initializeGnuPG(self.config) File "/home/atagar/Desktop/tor/bridgedb/bridgedb/crypto.py", line 318, in initializeGnuPG for sub in list(primaryPK)[0]['subkeys']: builtins.IndexError: list index out of range
Traceback (most recent call last): File "/home/atagar/Desktop/tor/bridgedb/bridgedb/test/test_crypto.py", line 218, in test_crypto_initializeGnuPG_signingFunc self.assertTrue(sig.startswith('-----BEGIN PGP SIGNED MESSAGE-----')) builtins.TypeError: startswith first arg must be bytes or a tuple of bytes, not str
Test results changed as follows...
before: FAILED (skips=114, failures=21, errors=55, successes=794) after: FAILED (skips=114, failures=21, errors=52, successes=797) --- bridgedb/crypto.py | 7 ++++--- bridgedb/test/test_crypto.py | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/bridgedb/crypto.py b/bridgedb/crypto.py index 1aee089..db3d083 100644 --- a/bridgedb/crypto.py +++ b/bridgedb/crypto.py @@ -310,12 +310,13 @@ def initializeGnuPG(config): logging.warn("No secret keys found in %s!" % gpg.secring) return ret
- primarySK = filter(lambda key: key['fingerprint'] == primary, secrets) - primaryPK = filter(lambda key: key['fingerprint'] == primary, publics) + primarySK = list(filter(lambda key: key['fingerprint'] == primary, secrets)) + primaryPK = list(filter(lambda key: key['fingerprint'] == primary, publics))
if primarySK and primaryPK: logging.info("Found GnuPG primary key with fingerprint: %s" % primary) - for sub in list(primaryPK)[0]['subkeys']: + + for sub in primaryPK[0]['subkeys']: logging.info(" Subkey: %s Usage: %s" % (sub[0], sub[1].upper())) else: logging.warn("GnuPG key %s could not be found in %s!" % (primary, gpg.secring)) diff --git a/bridgedb/test/test_crypto.py b/bridgedb/test/test_crypto.py index 9255c30..9911686 100644 --- a/bridgedb/test/test_crypto.py +++ b/bridgedb/test/test_crypto.py @@ -215,7 +215,7 @@ class InitializeGnuPGTests(unittest.TestCase): sig = signfunc("This is a test of the public broadcasting system.") print(sig) self.assertIsNotNone(sig) - self.assertTrue(sig.startswith('-----BEGIN PGP SIGNED MESSAGE-----')) + self.assertTrue(sig.startswith(b'-----BEGIN PGP SIGNED MESSAGE-----'))
def test_crypto_initializeGnuPG_nonexistent_default_key(self): """When the key specified by EMAIL_GPG_PRIMARY_KEY_FINGERPRINT doesn't