mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-10 03:28:53 +00:00
TestEncryptResponseId
This commit is contained in:
parent
e34e8b4650
commit
6122ff9fce
2 changed files with 5 additions and 30 deletions
|
|
@ -818,27 +818,3 @@ def test_cache_get_by_file_returns_exact_entry(mock_pm_cls, fake_managers):
|
|||
assert beta and beta["id"] == "nested/beta"
|
||||
|
||||
|
||||
@patch("litellm.integrations.gitlab.gitlab_prompt_manager.GitLabClient")
|
||||
@patch("litellm.integrations.gitlab.gitlab_prompt_manager.GitLabPromptManager")
|
||||
def test_encode_decode_helpers_roundtrip_in_cache_context(mock_pm_cls, mock_client_cls, fake_managers):
|
||||
"""Test that encode/decode helpers work correctly in the cache context."""
|
||||
tm, wrapper = fake_managers
|
||||
tm._discoverable_ids = ["dir1/dir2/item"]
|
||||
mock_pm_cls.return_value = wrapper
|
||||
|
||||
cache = GitLabPromptCache({"project": "g/s/r", "access_token": "tkn"})
|
||||
cache.load_all()
|
||||
|
||||
# Verify mock was used
|
||||
mock_pm_cls.assert_called_once()
|
||||
|
||||
encoded = encode_prompt_id("dir1/dir2/item")
|
||||
assert encoded in cache.list_ids()
|
||||
|
||||
# decode -> encode -> lookup should still work
|
||||
decoded = decode_prompt_id(encoded)
|
||||
assert decoded == "dir1/dir2/item"
|
||||
|
||||
got = cache.get_by_id(decoded)
|
||||
assert got is not None
|
||||
assert got["id"] == "dir1/dir2/item"
|
||||
|
|
@ -136,10 +136,9 @@ class TestEncryptResponseId:
|
|||
)
|
||||
|
||||
with patch(
|
||||
"litellm.proxy.hooks.responses_id_security.encrypt_value_helper"
|
||||
) as mock_encrypt:
|
||||
mock_encrypt.return_value = "encrypted_value_456"
|
||||
|
||||
"litellm.proxy.common_utils.encrypt_decrypt_utils._get_salt_key",
|
||||
return_value="test-salt-key"
|
||||
):
|
||||
with patch.object(
|
||||
responses_id_security, "_get_signing_key", return_value="test-key"
|
||||
):
|
||||
|
|
@ -147,9 +146,9 @@ class TestEncryptResponseId:
|
|||
mock_response, mock_user_api_key_dict
|
||||
)
|
||||
|
||||
assert result.id == "resp_encrypted_value_456"
|
||||
assert result.id.startswith("resp_")
|
||||
mock_encrypt.assert_called_once()
|
||||
# The encrypted ID should be different from the original
|
||||
assert result.id != "resp_456"
|
||||
|
||||
|
||||
class TestCheckUserAccessToResponseId:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue