mirror of
https://github.com/aljazceru/python-teos.git
synced 2025-12-17 22:24:23 +01:00
Moves EncryptedBlob to common
This commit is contained in:
@@ -4,7 +4,7 @@ import binascii
|
||||
from pytest import fixture
|
||||
|
||||
from common.appointment import Appointment
|
||||
from pisa.encrypted_blob import EncryptedBlob
|
||||
from common.encrypted_blob import EncryptedBlob
|
||||
|
||||
from test.pisa.unit.conftest import get_random_value_hex
|
||||
|
||||
|
||||
18
test/common/unit/test_blob.py
Normal file
18
test/common/unit/test_blob.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from binascii import unhexlify
|
||||
|
||||
from common.blob import Blob
|
||||
from test.pisa.unit.conftest import get_random_value_hex
|
||||
|
||||
|
||||
def test_init_blob():
|
||||
data = get_random_value_hex(64)
|
||||
blob = Blob(data)
|
||||
assert isinstance(blob, Blob)
|
||||
|
||||
# Wrong data
|
||||
try:
|
||||
Blob(unhexlify(get_random_value_hex(64)))
|
||||
assert False, "Able to create blob with wrong data"
|
||||
|
||||
except ValueError:
|
||||
assert True
|
||||
@@ -5,10 +5,10 @@ from cryptography.hazmat.primitives.asymmetric import ec
|
||||
from cryptography.hazmat.primitives import serialization
|
||||
|
||||
import common.cryptographer
|
||||
from apps.cli.blob import Blob
|
||||
from common.blob import Blob
|
||||
from common.logger import Logger
|
||||
from common.cryptographer import Cryptographer
|
||||
from pisa.encrypted_blob import EncryptedBlob
|
||||
from common.encrypted_blob import EncryptedBlob
|
||||
from test.common.unit.conftest import get_random_value_hex
|
||||
|
||||
common.cryptographer.logger = Logger(actor="Cryptographer", log_name_prefix="")
|
||||
|
||||
16
test/common/unit/test_encrypted_blob.py
Normal file
16
test/common/unit/test_encrypted_blob.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from common.encrypted_blob import EncryptedBlob
|
||||
from test.pisa.unit.conftest import get_random_value_hex
|
||||
|
||||
|
||||
def test_init_encrypted_blob():
|
||||
# No much to test here, basically that the object is properly created
|
||||
data = get_random_value_hex(64)
|
||||
assert EncryptedBlob(data).data == data
|
||||
|
||||
|
||||
def test_equal():
|
||||
data = get_random_value_hex(64)
|
||||
e_blob1 = EncryptedBlob(data)
|
||||
e_blob2 = EncryptedBlob(data)
|
||||
|
||||
assert e_blob1 == e_blob2 and id(e_blob1) != id(e_blob2)
|
||||
Reference in New Issue
Block a user