pyinfra/tests/unit_tests/cipher_test.py
Julius Unverfehrt c09476cfae Update tests
All components from payload processing downwards are tested.

Tests that depend on docker compose have been disabled by default
because they take too long to use during development. Furthermore, the
queue manager tests are not stable, a refactoring with inversion of
control is urgently needed to make the components properly testable. The
storage tests are stable and should be run once before releasing, this
should be implemented via the CI script.

Also adds, if present, tenant Id and operation kwargs to storage and
queue response.
2023-08-22 17:33:22 +02:00

30 lines
688 B
Python

import pytest
from pyinfra.utils.cipher import decrypt, encrypt
@pytest.fixture
def ciphertext():
return "AAAADBRzag4/aAE2+rSekyI5phVZ1e0wwSaRkGQTLftPyVvq8vLYZzwxW48Wozc3/w=="
@pytest.fixture
def plaintext():
return "connectzionString"
@pytest.fixture
def public_key():
return "redaction"
class TestDecryption:
def test_decrypt_ciphertext(self, public_key, ciphertext, plaintext):
result = decrypt(public_key, ciphertext)
assert result == plaintext
def test_encrypt_plaintext(self, public_key, plaintext):
ciphertext = encrypt(public_key, plaintext)
result = decrypt(public_key, ciphertext)
assert plaintext == result