diff --git a/integration-test/test_integration.py b/integration-test/test_integration.py index 41468457..ca925d2e 100644 --- a/integration-test/test_integration.py +++ b/integration-test/test_integration.py @@ -1,13 +1,8 @@ -import binascii -import json -import time -import uuid - import msgpack import pytest import requests -from helpers import get_random_json, serialize, get_hash, to_base64, get_random_hash_base64, verify_upp_signature +from helpers import * class TestIntegration: @@ -122,13 +117,13 @@ def test_chain(self): assert res.json()["hash"] == data_hash_64 assert res.json()["response"]["statusCode"] == 200 - upp = binascii.a2b_base64(res.json()["upp"]) + upp = a2b_base64(res.json()["upp"]) unpacked = msgpack.unpackb(upp) assert len(unpacked) == 6 assert unpacked[0] == 0x23 assert unpacked[1] == uuid.UUID(self.uuid).bytes assert unpacked[3] == 0x00 - assert unpacked[4] == binascii.a2b_base64(data_hash_64) + assert unpacked[4] == a2b_base64(data_hash_64) registered_pubkey = requests.get(self.pubkey_url).json()[0]["pubKeyInfo"]["pubKey"] assert res.json()["publicKey"] == registered_pubkey @@ -150,7 +145,7 @@ def test_chain(self): assert res.status_code == 200, f"request failed ({i}): [{res.status_code}] {res.content}" - unpacked = msgpack.unpackb(binascii.a2b_base64(res.json()["upp"])) + unpacked = msgpack.unpackb(a2b_base64(res.json()["upp"])) assert unpacked[2] == prev_signature, f"chain check failed in loop {i}" prev_signature = unpacked[5] @@ -166,13 +161,13 @@ def test_chain_hash(self): assert res.json()["hash"] == data_hash_64 assert res.json()["response"]["statusCode"] == 200 - upp = binascii.a2b_base64(res.json()["upp"]) + upp = a2b_base64(res.json()["upp"]) unpacked = msgpack.unpackb(upp) assert len(unpacked) == 6 assert unpacked[0] == 0x23 assert unpacked[1] == uuid.UUID(self.uuid).bytes assert unpacked[3] == 0x00 - assert unpacked[4] == binascii.a2b_base64(data_hash_64) + assert unpacked[4] == a2b_base64(data_hash_64) registered_pubkey = requests.get(self.pubkey_url).json()[0]["pubKeyInfo"]["pubKey"] assert res.json()["publicKey"] == registered_pubkey @@ -196,7 +191,7 @@ def test_chain_hash(self): assert res.status_code == 200, f"request failed ({i}): [{res.status_code}] {res.content}" - unpacked = msgpack.unpackb(binascii.a2b_base64(res.json()["upp"])) + unpacked = msgpack.unpackb(a2b_base64(res.json()["upp"])) assert unpacked[2] == prev_signature, f"chain check failed in loop {i}" prev_signature = unpacked[5] @@ -214,13 +209,13 @@ def test_chain_offline(self): with pytest.raises(KeyError): res.json()["response"] - upp = binascii.a2b_base64(res.json()["upp"]) + upp = a2b_base64(res.json()["upp"]) unpacked = msgpack.unpackb(upp) assert len(unpacked) == 6 assert unpacked[0] == 0x23 assert unpacked[1] == uuid.UUID(self.uuid).bytes assert unpacked[3] == 0x00 - assert unpacked[4] == binascii.a2b_base64(data_hash_64) + assert unpacked[4] == a2b_base64(data_hash_64) registered_pubkey = requests.get(self.pubkey_url).json()[0]["pubKeyInfo"]["pubKey"] assert res.json()["publicKey"] == registered_pubkey @@ -241,7 +236,7 @@ def test_chain_offline(self): assert res.status_code == 200, f"request failed ({i}): [{res.status_code}] {res.content}" - unpacked = msgpack.unpackb(binascii.a2b_base64(res.json()["upp"])) + unpacked = msgpack.unpackb(a2b_base64(res.json()["upp"])) assert unpacked[2] == prev_signature, f"chain check failed in loop {i}" prev_signature = unpacked[5] @@ -258,13 +253,13 @@ def test_chain_offline_hash(self): with pytest.raises(KeyError): res.json()["response"] - upp = binascii.a2b_base64(res.json()["upp"]) + upp = a2b_base64(res.json()["upp"]) unpacked = msgpack.unpackb(upp) assert len(unpacked) == 6 assert unpacked[0] == 0x23 assert unpacked[1] == uuid.UUID(self.uuid).bytes assert unpacked[3] == 0x00 - assert unpacked[4] == binascii.a2b_base64(data_hash_64) + assert unpacked[4] == a2b_base64(data_hash_64) registered_pubkey = requests.get(self.pubkey_url).json()[0]["pubKeyInfo"]["pubKey"] assert res.json()["publicKey"] == registered_pubkey @@ -287,7 +282,7 @@ def test_chain_offline_hash(self): assert res.status_code == 200, f"request failed ({i}): [{res.status_code}] {res.content}" - unpacked = msgpack.unpackb(binascii.a2b_base64(res.json()["upp"])) + unpacked = msgpack.unpackb(a2b_base64(res.json()["upp"])) assert unpacked[2] == prev_signature, f"chain check failed in loop {i}" prev_signature = unpacked[5] @@ -304,13 +299,13 @@ def test_anchor(self): assert res.json()["hash"] == data_hash_64 assert res.json()["response"]["statusCode"] == 200 - upp = binascii.a2b_base64(res.json()["upp"]) + upp = a2b_base64(res.json()["upp"]) unpacked = msgpack.unpackb(upp) assert len(unpacked) == 5 assert unpacked[0] == 0x22 assert unpacked[1] == uuid.UUID(self.uuid).bytes assert unpacked[2] == 0x00 - assert unpacked[3] == binascii.a2b_base64(data_hash_64) + assert unpacked[3] == a2b_base64(data_hash_64) registered_pubkey = requests.get(self.pubkey_url).json()[0]["pubKeyInfo"]["pubKey"] assert res.json()["publicKey"] == registered_pubkey @@ -336,13 +331,13 @@ def test_anchor_hash(self): assert res.json()["hash"] == data_hash_64 assert res.json()["response"]["statusCode"] == 200 - upp = binascii.a2b_base64(res.json()["upp"]) + upp = a2b_base64(res.json()["upp"]) unpacked = msgpack.unpackb(upp) assert len(unpacked) == 5 assert unpacked[0] == 0x22 assert unpacked[1] == uuid.UUID(self.uuid).bytes assert unpacked[2] == 0x00 - assert unpacked[3] == binascii.a2b_base64(data_hash_64) + assert unpacked[3] == a2b_base64(data_hash_64) registered_pubkey = requests.get(self.pubkey_url).json()[0]["pubKeyInfo"]["pubKey"] assert res.json()["publicKey"] == registered_pubkey @@ -369,13 +364,13 @@ def test_disable(self): assert res.json()["hash"] == data_hash_64 assert res.json()["response"]["statusCode"] == 200 - upp = binascii.a2b_base64(res.json()["upp"]) + upp = a2b_base64(res.json()["upp"]) unpacked = msgpack.unpackb(upp) assert len(unpacked) == 5 assert unpacked[0] == 0x22 assert unpacked[1] == uuid.UUID(self.uuid).bytes assert unpacked[2] == 0xFA - assert unpacked[3] == binascii.a2b_base64(data_hash_64) + assert unpacked[3] == a2b_base64(data_hash_64) registered_pubkey = requests.get(self.pubkey_url).json()[0]["pubKeyInfo"]["pubKey"] assert res.json()["publicKey"] == registered_pubkey @@ -400,13 +395,13 @@ def test_disable_hash(self): assert res.json()["hash"] == data_hash_64 assert res.json()["response"]["statusCode"] == 200 - upp = binascii.a2b_base64(res.json()["upp"]) + upp = a2b_base64(res.json()["upp"]) unpacked = msgpack.unpackb(upp) assert len(unpacked) == 5 assert unpacked[0] == 0x22 assert unpacked[1] == uuid.UUID(self.uuid).bytes assert unpacked[2] == 0xFA - assert unpacked[3] == binascii.a2b_base64(data_hash_64) + assert unpacked[3] == a2b_base64(data_hash_64) registered_pubkey = requests.get(self.pubkey_url).json()[0]["pubKeyInfo"]["pubKey"] assert res.json()["publicKey"] == registered_pubkey @@ -432,13 +427,13 @@ def test_enable(self): assert res.json()["hash"] == data_hash_64 assert res.json()["response"]["statusCode"] == 200 - upp = binascii.a2b_base64(res.json()["upp"]) + upp = a2b_base64(res.json()["upp"]) unpacked = msgpack.unpackb(upp) assert len(unpacked) == 5 assert unpacked[0] == 0x22 assert unpacked[1] == uuid.UUID(self.uuid).bytes assert unpacked[2] == 0xFB - assert unpacked[3] == binascii.a2b_base64(data_hash_64) + assert unpacked[3] == a2b_base64(data_hash_64) registered_pubkey = requests.get(self.pubkey_url).json()[0]["pubKeyInfo"]["pubKey"] assert res.json()["publicKey"] == registered_pubkey @@ -463,13 +458,13 @@ def test_enable_hash(self): assert res.json()["hash"] == data_hash_64 assert res.json()["response"]["statusCode"] == 200 - upp = binascii.a2b_base64(res.json()["upp"]) + upp = a2b_base64(res.json()["upp"]) unpacked = msgpack.unpackb(upp) assert len(unpacked) == 5 assert unpacked[0] == 0x22 assert unpacked[1] == uuid.UUID(self.uuid).bytes assert unpacked[2] == 0xFB - assert unpacked[3] == binascii.a2b_base64(data_hash_64) + assert unpacked[3] == a2b_base64(data_hash_64) registered_pubkey = requests.get(self.pubkey_url).json()[0]["pubKeyInfo"]["pubKey"] assert res.json()["publicKey"] == registered_pubkey @@ -495,13 +490,13 @@ def test_delete(self): assert res.json()["hash"] == data_hash_64 assert res.json()["response"]["statusCode"] == 200 - upp = binascii.a2b_base64(res.json()["upp"]) + upp = a2b_base64(res.json()["upp"]) unpacked = msgpack.unpackb(upp) assert len(unpacked) == 5 assert unpacked[0] == 0x22 assert unpacked[1] == uuid.UUID(self.uuid).bytes assert unpacked[2] == 0xFC - assert unpacked[3] == binascii.a2b_base64(data_hash_64) + assert unpacked[3] == a2b_base64(data_hash_64) registered_pubkey = requests.get(self.pubkey_url).json()[0]["pubKeyInfo"]["pubKey"] assert res.json()["publicKey"] == registered_pubkey @@ -526,13 +521,13 @@ def test_delete_hash(self): assert res.json()["hash"] == data_hash_64 assert res.json()["response"]["statusCode"] == 200 - upp = binascii.a2b_base64(res.json()["upp"]) + upp = a2b_base64(res.json()["upp"]) unpacked = msgpack.unpackb(upp) assert len(unpacked) == 5 assert unpacked[0] == 0x22 assert unpacked[1] == uuid.UUID(self.uuid).bytes assert unpacked[2] == 0xFC - assert unpacked[3] == binascii.a2b_base64(data_hash_64) + assert unpacked[3] == a2b_base64(data_hash_64) registered_pubkey = requests.get(self.pubkey_url).json()[0]["pubKeyInfo"]["pubKey"] assert res.json()["publicKey"] == registered_pubkey @@ -559,13 +554,13 @@ def test_anchor_offline(self): with pytest.raises(KeyError): res.json()["response"] - upp = binascii.a2b_base64(res.json()["upp"]) + upp = a2b_base64(res.json()["upp"]) unpacked = msgpack.unpackb(upp) assert len(unpacked) == 5 assert unpacked[0] == 0x22 assert unpacked[1] == uuid.UUID(self.uuid).bytes assert unpacked[2] == 0x00 - assert unpacked[3] == binascii.a2b_base64(data_hash_64) + assert unpacked[3] == a2b_base64(data_hash_64) registered_pubkey = requests.get(self.pubkey_url).json()[0]["pubKeyInfo"]["pubKey"] assert res.json()["publicKey"] == registered_pubkey @@ -591,13 +586,13 @@ def test_anchor_offline_hash(self): with pytest.raises(KeyError): res.json()["response"] - upp = binascii.a2b_base64(res.json()["upp"]) + upp = a2b_base64(res.json()["upp"]) unpacked = msgpack.unpackb(upp) assert len(unpacked) == 5 assert unpacked[0] == 0x22 assert unpacked[1] == uuid.UUID(self.uuid).bytes assert unpacked[2] == 0x00 - assert unpacked[3] == binascii.a2b_base64(data_hash_64) + assert unpacked[3] == a2b_base64(data_hash_64) registered_pubkey = requests.get(self.pubkey_url).json()[0]["pubKeyInfo"]["pubKey"] assert res.json()["publicKey"] == registered_pubkey