Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

1.2 KB
Raw Blame
import hashlib
import os
from typing import Final

import pytest
from e2e_config import SECRET_MANAGER_OPT_IN_ENV
from e2e_metadata import Domain, Subject, meta
from pydantic import TypeAdapter

from litellm.secret_managers.aws_secret_manager_v2 import AWSSecretsManagerV2
from litellm.secret_managers.main import get_secret

pytestmark = [
    pytest.mark.e2e,
    pytest.mark.secret_manager,
    pytest.mark.skipif(
        os.environ.get(SECRET_MANAGER_OPT_IN_ENV, "").strip() != "aws",
        reason=f"runs only on the AWS Secrets Manager lane ({SECRET_MANAGER_OPT_IN_ENV}=aws)",
    ),
]

_AWS_FIXTURE_MASTER_KEY_SHA256: Final = "88dc28d0f030c55ed4ab77ed8faf098196cb1c05df778539800c9f1243fe6b4b"
_STRING_MAP: Final = TypeAdapter(dict[str, str])
_SECRET_STRING: Final = TypeAdapter(str)


class TestAwsSecretManager:
    @meta(Subject(domain=Domain.DEPLOY_OPS))
    def test_aws_secret_manager(self) -> None:
        AWSSecretsManagerV2.load_aws_secret_manager(use_aws_secret_manager=True)
        secret_value: Final = _STRING_MAP.validate_json(
            _SECRET_STRING.validate_python(get_secret("litellm_master_key"))
        )
        assert hashlib.sha256(secret_value["litellm_master_key"].encode()).hexdigest() == _AWS_FIXTURE_MASTER_KEY_SHA256