Some checks failed
Test before pr merge / test-lint (pull_request) Failing after 7s
19 lines
531 B
Python
19 lines
531 B
Python
from cryptography.fernet import Fernet
|
|
|
|
from cpl.core.utils.credential_manager import CredentialManager
|
|
|
|
|
|
def test_encrypt_decrypt_roundtrip(tmp_path):
|
|
secret_path = tmp_path / ".secret"
|
|
secret_path.write_text(Fernet.generate_key().decode())
|
|
|
|
CredentialManager.with_secret(str(secret_path))
|
|
|
|
plaintext = "hello-world"
|
|
token = CredentialManager.encrypt(plaintext)
|
|
assert isinstance(token, str)
|
|
assert token != plaintext
|
|
|
|
decrypted = CredentialManager.decrypt(token)
|
|
assert decrypted == plaintext
|