Skip to content

Commit

Permalink
minor: cleanup imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Roxana Meixner committed Dec 1, 2022
1 parent c2dd282 commit 3d969d2
Showing 1 changed file with 33 additions and 38 deletions.
71 changes: 33 additions & 38 deletions integration-test/test_integration.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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]
Expand All @@ -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
Expand All @@ -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]
Expand All @@ -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
Expand All @@ -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]
Expand All @@ -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
Expand All @@ -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]
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 3d969d2

Please sign in to comment.