litellm/tests/unit/proxy/control_plane/dataplanes/conftest.py
Yassin Kortam 723ef77441
feat(control_plane): dataplane registry, credential strategies and client (#49655)
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-11-16 17:36:23 +00:00

39 lines
1.1 KiB
Python

from typing import Final
import pytest
from litellm.litellm_core_utils.oauth_token_exchange import OAuthTokenExchangeConfig
from litellm.proxy.control_plane.auth.rbac import (
ADMIN_ROLE,
Principal,
RolePolicy,
TokenKind,
build_policy,
build_principal,
)
from litellm.proxy.control_plane.dataplanes.credentials import Caller
POLICY: Final = build_policy({}, include_defaults=True)
assert isinstance(POLICY, RolePolicy)
def principal(
kind: TokenKind, subject: str = "alice", email: str | None = "alice@x.test", *dataplanes: str
) -> Principal:
return build_principal(POLICY, subject, email, frozenset({ADMIN_ROLE}), None, frozenset(dataplanes), kind)
def caller(kind: TokenKind, bearer: str = "cp-bearer", *dataplanes: str) -> Caller:
return Caller(principal=principal(kind, "alice", "alice@x.test", *dataplanes), bearer=bearer)
@pytest.fixture
def exchange_config() -> OAuthTokenExchangeConfig:
return OAuthTokenExchangeConfig(
token_endpoint="https://idp.test/token",
client_id="cp",
client_secret="s",
profile="rfc8693",
scope=None,
audience="dp",
)