[gnome-keysign: 50/65] test_bluetooth: add hmac dismatch test



commit 7a179d9de7dabfe85cddecb3b9c7c75c3e29e7f1
Author: RyuzakiKK <aasonykk gmail com>
Date:   Fri Aug 25 16:21:23 2017 +0200

    test_bluetooth: add hmac dismatch test

 tests/test_bluetooth.py | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
---
diff --git a/tests/test_bluetooth.py b/tests/test_bluetooth.py
index 4c3b3fb..51b9569 100644
--- a/tests/test_bluetooth.py
+++ b/tests/test_bluetooth.py
@@ -61,6 +61,28 @@ def test_bt():
 
 @deferred(timeout=15)
 @inlineCallbacks
+def test_bt_wrong_hmac():
+    """This test requires two working Bluetooth devices"""
+    data = read_fixture_file("seckey-no-pw-1.asc")
+    key = openpgpkey_from_data(data)
+    log.info("Running with key %r", key)
+    hmac = "wrong_hmac_eg_tampered_key"
+    # Start offering the key
+    offer = BluetoothOffer(key)
+    data = yield offer.allocate_code()
+    # getting the code from "BT=code;...."
+    code = data.split("=", 1)[1]
+    code = code.split(";", 1)[0]
+    port = int(data.rsplit("=", 1)[1])
+    offer.start()
+    receive = BluetoothReceive(port)
+    msg_tuple = yield receive.find_key(code, hmac)
+    downloaded_key_data, success, _ = msg_tuple
+    assert_false(success)
+
+
+@deferred(timeout=15)
+@inlineCallbacks
 def test_bt_wrong_mac():
     """This test requires one working Bluetooth device"""
     receive = BluetoothReceive()


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