20 lines
450 B
Python
20 lines
450 B
Python
from cryptography.fernet import Fernet
|
|
|
|
import pytest
|
|
|
|
from exporter.sqlite_store import PasswordEncryptor
|
|
|
|
|
|
def test_encrypt_decrypt_roundtrip():
|
|
key = Fernet.generate_key().decode()
|
|
enc = PasswordEncryptor(key)
|
|
cipher = enc.encrypt("secret")
|
|
assert cipher != b"secret"
|
|
assert enc.decrypt(cipher) == "secret"
|
|
|
|
|
|
def test_encryptor_rejects_invalid_key():
|
|
with pytest.raises(ValueError):
|
|
PasswordEncryptor("too-short")
|
|
|