36 lines
1004 B
Python
36 lines
1004 B
Python
"""Tests for encryption."""
|
|
|
|
import pytest
|
|
from src.security.encryption import get_encryption_manager, EncryptionManager
|
|
|
|
|
|
class TestEncryption:
|
|
"""Tests for encryption system."""
|
|
|
|
@pytest.fixture
|
|
def encryptor(self):
|
|
"""Create encryption manager."""
|
|
return get_encryption_manager()
|
|
|
|
def test_encrypt_decrypt(self, encryptor):
|
|
"""Test encryption and decryption."""
|
|
plaintext = "test_api_key_12345"
|
|
|
|
encrypted = encryptor.encrypt(plaintext)
|
|
assert encrypted != plaintext
|
|
assert len(encrypted) > 0
|
|
|
|
decrypted = encryptor.decrypt(encrypted)
|
|
assert decrypted == plaintext
|
|
|
|
def test_encrypt_different_values(self, encryptor):
|
|
"""Test that different values encrypt differently."""
|
|
value1 = "key1"
|
|
value2 = "key2"
|
|
|
|
encrypted1 = encryptor.encrypt(value1)
|
|
encrypted2 = encryptor.encrypt(value2)
|
|
|
|
assert encrypted1 != encrypted2
|
|
|