Coverage for src/tests/test_crypto.py: 100%

17 statements  

« prev     ^ index     » next       coverage.py v7.5.0, created at 2024-12-29 01:26 +0000

1import pytest 

2 

3from couchers import crypto 

4from tests.test_fixtures import testconfig # noqa 

5 

6 

7@pytest.fixture(autouse=True) 

8def _(testconfig): 

9 pass 

10 

11 

12def test_b64(): 

13 assert crypto.b64decode(crypto.b64encode(b"hello there")) == b"hello there" 

14 

15 

16def test_simple_crypto(): 

17 assert crypto.simple_decrypt("test_simple", crypto.simple_encrypt("test_simple", b"hello there")) == b"hello there" 

18 

19 

20def test_hash_sigs(): 

21 sig = crypto.generate_hash_signature(b"this is the message", crypto.get_secret("test_hash")) 

22 crypto.verify_hash_signature(b"this is the message", crypto.get_secret("test_hash"), sig) 

23 

24 

25def test_asym_crypto(): 

26 skey, pkey = crypto.generate_asym_keypair() 

27 encrypted = crypto.asym_encrypt(pkey, b"a very secret message") 

28 assert crypto.asym_decrypt(skey, encrypted) == b"a very secret message"