Coverage for src/tests/test_crypto.py: 100%
17 statements
« prev ^ index » next coverage.py v7.5.0, created at 2024-11-21 04:21 +0000
« prev ^ index » next coverage.py v7.5.0, created at 2024-11-21 04:21 +0000
1import pytest
3from couchers import crypto
4from tests.test_fixtures import testconfig # noqa
7@pytest.fixture(autouse=True)
8def _(testconfig):
9 pass
12def test_b64():
13 assert crypto.b64decode(crypto.b64encode(b"hello there")) == b"hello there"
16def test_simple_crypto():
17 assert crypto.simple_decrypt("test_simple", crypto.simple_encrypt("test_simple", b"hello there")) == b"hello there"
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)
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"