[gnome-keysign: 69/75] tests: gpgmeh: Use secret keys only when necessary



commit c19a9cace628214deead9aea0c3432302357bc9c
Author: Tobias Mueller <muelli cryptobitch de>
Date:   Thu Sep 21 23:21:47 2017 +0200

    tests: gpgmeh: Use secret keys only when necessary
    
    While we need private keys for both parties in order to
    have a full end-to-end scenario, we require public keys only for certain
    parts.  This change tries to make assumptions we make more explicit.

 tests/test_gpgmeh.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/tests/test_gpgmeh.py b/tests/test_gpgmeh.py
index 12c7444..9e9697c 100644
--- a/tests/test_gpgmeh.py
+++ b/tests/test_gpgmeh.py
@@ -413,10 +413,12 @@ class TestSignAndEncrypt:
         pass
 
     def test_sign_and_encrypt(self):
-        secret_keydata = open(self.key_sender_key, "rb").read()
+        # This might be a secret key, too, so we import and export to
+        # get hold of the public portion.
+        keydata = open(self.key_sender_key, "rb").read()
         # We get the public portion of the key
         sender = TempContext()
-        sender.op_import(secret_keydata)
+        sender.op_import(keydata)
         result = sender.op_import_result()
         fpr = result.imports[0].fpr
         sink = gpg.Data()
@@ -425,7 +427,7 @@ class TestSignAndEncrypt:
         # This is the key that we will sign
         public_sender_key = sink.read()
 
-        keys = get_usable_secret_keys(homedir=self.key_sender_homedir)
+        keys = get_usable_keys(homedir=self.key_sender_homedir)
         assert_equals(1, len(keys))
         key = keys[0]
         uids = key.uidslist


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]