1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
|
From 41a28f1b127ac7503dfebacc8130d14a314ce4d9 Mon Sep 17 00:00:00 2001
From: RyuzakiKK <aasonykk@gmail.com>
Date: Mon, 21 Jan 2019 16:15:29 +0100
Subject: [PATCH] tests: Fix key import error
Apparently we had another problem with these tests.
Calling get_public_key_data with the required temporary homedir worked
as expected.
The problem was that in wormholeoffer, bluetoothoffer and avahioffer we
also call get_public_key_data, but without the temporary homedir that
has the private key we were trying to use.
With a "GNUPGHOME" environment variable we solve this problem.
---
tests/test_bluetooth.py | 7 +++++--
tests/test_wormhole.py | 14 ++++++++++----
2 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/tests/test_bluetooth.py b/tests/test_bluetooth.py
index b6c200a..8000f25 100644
--- a/tests/test_bluetooth.py
+++ b/tests/test_bluetooth.py
@@ -58,8 +58,9 @@ def test_bt():
"""This test requires two working Bluetooth devices"""
# This should be a new, empty directory
homedir = tempfile.mkdtemp()
+ os.environ["GNUPGHOME"] = homedir
key = import_key_from_file("seckey-no-pw-1.asc", homedir)
- file_key_data = get_public_key_data(key.fingerprint, homedir=homedir)
+ file_key_data = get_public_key_data(key.fingerprint)
log.info("Running with key %r", key)
hmac = mac_generate(key.fingerprint.encode('ascii'), file_key_data)
# Start offering the key
@@ -85,6 +86,7 @@ def test_bt_wrong_hmac():
"""This test requires two working Bluetooth devices"""
# This should be a new, empty directory
homedir = tempfile.mkdtemp()
+ os.environ["GNUPGHOME"] = homedir
key = import_key_from_file("seckey-no-pw-1.asc", homedir)
log.info("Running with key %r", key)
hmac = "wrong_hmac_eg_tampered_key"
@@ -149,9 +151,10 @@ def start(bo):
# This should be a new, empty directory
homedir = tempfile.mkdtemp()
+ os.environ["GNUPGHOME"] = homedir
key = import_key_from_file("seckey-no-pw-1.asc", homedir)
log.info("Running with key %r", key)
- file_key_data = get_public_key_data(key.fingerprint, homedir=homedir)
+ file_key_data = get_public_key_data(key.fingerprint)
hmac = mac_generate(key.fingerprint.encode('ascii'), file_key_data)
# Start offering the key
offer = BluetoothOffer(key)
diff --git a/tests/test_wormhole.py b/tests/test_wormhole.py
index 7f1578c..4ae53be 100644
--- a/tests/test_wormhole.py
+++ b/tests/test_wormhole.py
@@ -61,13 +61,14 @@ def import_key_from_file(fixture, homedir):
return openpgpkey_from_data(original)
-@deferred(timeout=200)
+@deferred(timeout=10)
@inlineCallbacks
def test_wrmhl():
# This should be a new, empty directory
homedir = tempfile.mkdtemp()
+ os.environ["GNUPGHOME"] = homedir
key = import_key_from_file("seckey-no-pw-1.asc", homedir)
- file_key_data = get_public_key_data(key.fingerprint, homedir=homedir)
+ file_key_data = get_public_key_data(key.fingerprint)
log.info("Running with key %r", key)
# Start offering the key
offer = WormholeOffer(key)
@@ -87,8 +88,9 @@ def test_wrmhl():
def test_wrmhl_offline_code():
# This should be a new, empty directory
homedir = tempfile.mkdtemp()
+ os.environ["GNUPGHOME"] = homedir
key = import_key_from_file("seckey-no-pw-1.asc", homedir)
- file_key_data = get_public_key_data(key.fingerprint, homedir=homedir)
+ file_key_data = get_public_key_data(key.fingerprint)
# We assume that this channel, at execution time, is free
code = u"5556-penguin-paw-print"
# Start offering the key
@@ -109,6 +111,7 @@ def test_wrmhl_offline_code():
def test_wrmhl_wrong_code():
# This should be a new, empty directory
homedir = tempfile.mkdtemp()
+ os.environ["GNUPGHOME"] = homedir
key = import_key_from_file("seckey-no-pw-1.asc", homedir)
log.info("Running with key %r", key)
# Start offering the key
@@ -129,6 +132,7 @@ def test_wrmhl_wrong_code():
def test_wrmhl_wrong_hmac():
# This should be a new, empty directory
homedir = tempfile.mkdtemp()
+ os.environ["GNUPGHOME"] = homedir
key = import_key_from_file("seckey-no-pw-1.asc", homedir)
log.info("Running with key %r", key)
hmac = "wrong_hmac_eg_tampered_key"
@@ -150,8 +154,9 @@ def test_wrmhl_wrong_hmac():
def test_wrmhl_with_hmac():
# This should be a new, empty directory
homedir = tempfile.mkdtemp()
+ os.environ["GNUPGHOME"] = homedir
key = import_key_from_file("seckey-no-pw-1.asc", homedir)
- file_key_data = get_public_key_data(key.fingerprint, homedir=homedir)
+ file_key_data = get_public_key_data(key.fingerprint)
log.info("Running with key %r", key)
hmac = mac_generate(key.fingerprint.encode('ascii'), file_key_data)
# Start offering the key
@@ -178,6 +183,7 @@ def _received(start_data):
# This should be a new, empty directory
homedir = tempfile.mkdtemp()
+ os.environ["GNUPGHOME"] = homedir
key = import_key_from_file("seckey-no-pw-1.asc", homedir)
log.info("Running with key %r", key)
# Start offering the key
|