feat: add openai-compatible model gateway
This commit is contained in:
23
backend/apps/modelhub/tests/test_crypto.py
Normal file
23
backend/apps/modelhub/tests/test_crypto.py
Normal file
@@ -0,0 +1,23 @@
|
||||
import pytest
|
||||
|
||||
from apps.modelhub.crypto import (
|
||||
CredentialEncryptionError,
|
||||
decrypt_secret,
|
||||
encrypt_secret,
|
||||
mask_secret,
|
||||
)
|
||||
|
||||
|
||||
def test_encrypts_masks_and_decrypts_secret(settings):
|
||||
encrypted = encrypt_secret("sk-example-1234")
|
||||
|
||||
assert encrypted != "sk-example-1234"
|
||||
assert decrypt_secret(encrypted) == "sk-example-1234"
|
||||
assert mask_secret(encrypted) == "****1234"
|
||||
|
||||
|
||||
def test_missing_encryption_key_is_rejected(settings):
|
||||
settings.AI_CREDENTIAL_ENCRYPTION_KEY = ""
|
||||
|
||||
with pytest.raises(CredentialEncryptionError):
|
||||
encrypt_secret("secret")
|
||||
Reference in New Issue
Block a user