mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-05 02:41:56 +00:00
test(auth_v2): move tests under proxy/ to mirror the module relocation
The module moved from litellm/auth_v2 to litellm/proxy/auth_v2 (commit 104a5e1),
so the mirrored tests move from tests/test_litellm/auth_v2 to
tests/test_litellm/proxy/auth_v2 and their imports switch to
litellm.proxy.auth_v2. No behavior change; 134 tests still pass at the new path.
This commit is contained in:
parent
104a5e1443
commit
2dd336a795
12 changed files with 40 additions and 40 deletions
|
|
@ -6,8 +6,8 @@ import pytest
|
|||
from cryptography.hazmat.primitives import serialization
|
||||
from cryptography.hazmat.primitives.asymmetric import rsa
|
||||
|
||||
from litellm.auth_v2.authenticators import JwtVerifier
|
||||
from litellm.auth_v2.config import OidcProviderConfig
|
||||
from litellm.proxy.auth_v2.authenticators import JwtVerifier
|
||||
from litellm.proxy.auth_v2.config import OidcProviderConfig
|
||||
|
||||
from auth_v2_helpers import TEST_AUDIENCE, TEST_ISSUER, FakeJwksClient, TokenFactory
|
||||
|
||||
|
|
@ -6,7 +6,7 @@ from unittest.mock import AsyncMock, MagicMock, patch
|
|||
|
||||
import pytest
|
||||
|
||||
from litellm.auth_v2.authenticators import (
|
||||
from litellm.proxy.auth_v2.authenticators import (
|
||||
ApiKeyAuthenticator,
|
||||
HttpAuthenticator,
|
||||
JwtVerifier,
|
||||
|
|
@ -15,7 +15,7 @@ from litellm.auth_v2.authenticators import (
|
|||
OidcAuthenticator,
|
||||
build_authenticators,
|
||||
)
|
||||
from litellm.auth_v2.config import (
|
||||
from litellm.proxy.auth_v2.config import (
|
||||
ApiKeySchemeConfig,
|
||||
AuthConfig,
|
||||
HttpBasicConfig,
|
||||
|
|
@ -23,8 +23,8 @@ from litellm.auth_v2.config import (
|
|||
OAuth2IntrospectionConfig,
|
||||
OidcProviderConfig,
|
||||
)
|
||||
from litellm.auth_v2.errors import AuthError
|
||||
from litellm.auth_v2.models import AuthMethod, SecuritySchemeType
|
||||
from litellm.proxy.auth_v2.errors import AuthError
|
||||
from litellm.proxy.auth_v2.models import AuthMethod, SecuritySchemeType
|
||||
|
||||
from auth_v2_helpers import (
|
||||
TEST_AUDIENCE,
|
||||
|
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
|||
import pytest
|
||||
from pydantic import ValidationError
|
||||
|
||||
from litellm.auth_v2.config import (
|
||||
from litellm.proxy.auth_v2.config import (
|
||||
OAuth2IntrospectionConfig,
|
||||
OidcProviderConfig,
|
||||
SamlConfig,
|
||||
|
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
|||
import pytest
|
||||
from pydantic import ValidationError
|
||||
|
||||
from litellm.auth_v2.models import (
|
||||
from litellm.proxy.auth_v2.models import (
|
||||
AuthMethod,
|
||||
Credential,
|
||||
Principal,
|
||||
|
|
@ -13,7 +13,7 @@ from litellm.auth_v2.models import (
|
|||
TeamRole,
|
||||
UserIdentity,
|
||||
)
|
||||
from litellm.auth_v2.rbac import Role
|
||||
from litellm.proxy.auth_v2.rbac import Role
|
||||
|
||||
|
||||
def _credential() -> Credential:
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from litellm.auth_v2.config import TrustedProxyConfig
|
||||
from litellm.auth_v2.network import resolve_client_ip, resolve_network_context
|
||||
from litellm.proxy.auth_v2.config import TrustedProxyConfig
|
||||
from litellm.proxy.auth_v2.network import resolve_client_ip, resolve_network_context
|
||||
|
||||
from auth_v2_helpers import make_request
|
||||
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from litellm.auth_v2.config import OidcProviderConfig
|
||||
from litellm.auth_v2.oidc import _provider_key, _user_from_userinfo
|
||||
from litellm.auth_v2.resolver import InMemoryIdentityStore
|
||||
from litellm.proxy.auth_v2.config import OidcProviderConfig
|
||||
from litellm.proxy.auth_v2.oidc import _provider_key, _user_from_userinfo
|
||||
from litellm.proxy.auth_v2.resolver import InMemoryIdentityStore
|
||||
|
||||
|
||||
def test_userinfo_maps_standard_claims_to_scim_user():
|
||||
|
|
@ -3,8 +3,8 @@ from __future__ import annotations
|
|||
import pytest
|
||||
from fastapi.security import SecurityScopes
|
||||
|
||||
from litellm.auth_v2.models import AuthMethod, Principal, PrincipalType
|
||||
from litellm.auth_v2.rbac import RbacEngine, Role, has_required_scopes
|
||||
from litellm.proxy.auth_v2.models import AuthMethod, Principal, PrincipalType
|
||||
from litellm.proxy.auth_v2.rbac import RbacEngine, Role, has_required_scopes
|
||||
|
||||
|
||||
def _principal(*, scopes=None, roles=None) -> Principal:
|
||||
|
|
@ -2,8 +2,8 @@ from __future__ import annotations
|
|||
|
||||
import pytest
|
||||
|
||||
from litellm.auth_v2.errors import AuthError
|
||||
from litellm.auth_v2.models import (
|
||||
from litellm.proxy.auth_v2.errors import AuthError
|
||||
from litellm.proxy.auth_v2.models import (
|
||||
AuthMethod,
|
||||
ClientCertificate,
|
||||
Credential,
|
||||
|
|
@ -11,8 +11,8 @@ from litellm.auth_v2.models import (
|
|||
PrincipalType,
|
||||
SecuritySchemeType,
|
||||
)
|
||||
from litellm.auth_v2.rbac import Role
|
||||
from litellm.auth_v2.resolver import InMemoryIdentityStore, _hash_api_key
|
||||
from litellm.proxy.auth_v2.rbac import Role
|
||||
from litellm.proxy.auth_v2.resolver import InMemoryIdentityStore, _hash_api_key
|
||||
|
||||
|
||||
def _api_key_credential(raw: str) -> Credential:
|
||||
|
|
@ -94,7 +94,7 @@ def saml_env(tmp_path: Path) -> SamlEnv:
|
|||
from saml2.saml import NAMEID_FORMAT_EMAILADDRESS
|
||||
from saml2.server import Server
|
||||
|
||||
from litellm.auth_v2.config import SamlConfig
|
||||
from litellm.proxy.auth_v2.config import SamlConfig
|
||||
|
||||
idp_key, idp_cert = _gen_cert(tmp_path, "idp")
|
||||
sp_key, sp_cert = _gen_cert(tmp_path, "sp")
|
||||
|
|
@ -155,10 +155,10 @@ def saml_env(tmp_path: Path) -> SamlEnv:
|
|||
|
||||
|
||||
def _build_app(saml_env: SamlEnv):
|
||||
from litellm.auth_v2.config import AuthConfig
|
||||
from litellm.auth_v2.models import Principal
|
||||
from litellm.auth_v2.resolver import InMemoryIdentityStore
|
||||
from litellm.auth_v2.security import get_current_principal, install_auth
|
||||
from litellm.proxy.auth_v2.config import AuthConfig
|
||||
from litellm.proxy.auth_v2.models import Principal
|
||||
from litellm.proxy.auth_v2.resolver import InMemoryIdentityStore
|
||||
from litellm.proxy.auth_v2.security import get_current_principal, install_auth
|
||||
|
||||
app = FastAPI()
|
||||
store = InMemoryIdentityStore()
|
||||
|
|
@ -354,8 +354,8 @@ def test_login_rejects_open_redirect_next(saml_env):
|
|||
|
||||
|
||||
def test_map_attributes_applies_attribute_map():
|
||||
from litellm.auth_v2.config import DEFAULT_SAML_ATTRIBUTE_MAP
|
||||
from litellm.auth_v2.saml import _map_attributes
|
||||
from litellm.proxy.auth_v2.config import DEFAULT_SAML_ATTRIBUTE_MAP
|
||||
from litellm.proxy.auth_v2.saml import _map_attributes
|
||||
|
||||
ava = {
|
||||
"email": ["alice@example.com"],
|
||||
|
|
@ -371,7 +371,7 @@ def test_map_attributes_applies_attribute_map():
|
|||
|
||||
|
||||
def test_user_from_mapped_builds_name_and_email():
|
||||
from litellm.auth_v2.saml import _user_from_mapped
|
||||
from litellm.proxy.auth_v2.saml import _user_from_mapped
|
||||
|
||||
user = _user_from_mapped(
|
||||
"alice@example.com",
|
||||
|
|
@ -398,7 +398,7 @@ def test_user_from_mapped_builds_name_and_email():
|
|||
],
|
||||
)
|
||||
def test_safe_relay_state_blocks_open_redirects(candidate, expected):
|
||||
from litellm.auth_v2.saml import _safe_relay_state
|
||||
from litellm.proxy.auth_v2.saml import _safe_relay_state
|
||||
|
||||
assert _safe_relay_state(candidate, "/") == expected
|
||||
|
||||
|
|
@ -412,6 +412,6 @@ def test_safe_relay_state_blocks_open_redirects(candidate, expected):
|
|||
],
|
||||
)
|
||||
def test_metadata_source_classifies_input(metadata, expected_key):
|
||||
from litellm.auth_v2.saml import _metadata_source
|
||||
from litellm.proxy.auth_v2.saml import _metadata_source
|
||||
|
||||
assert expected_key in _metadata_source(metadata)
|
||||
|
|
@ -4,10 +4,10 @@ import pytest
|
|||
from fastapi import FastAPI
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from litellm.auth_v2.config import AuthConfig
|
||||
from litellm.auth_v2.models import AuthMethod, Principal, PrincipalType
|
||||
from litellm.auth_v2.resolver import InMemoryIdentityStore, _hash_api_key
|
||||
from litellm.auth_v2.security import install_auth
|
||||
from litellm.proxy.auth_v2.config import AuthConfig
|
||||
from litellm.proxy.auth_v2.models import AuthMethod, Principal, PrincipalType
|
||||
from litellm.proxy.auth_v2.resolver import InMemoryIdentityStore, _hash_api_key
|
||||
from litellm.proxy.auth_v2.security import install_auth
|
||||
|
||||
USER_SCHEMA = "urn:ietf:params:scim:schemas:core:2.0:User"
|
||||
GROUP_SCHEMA = "urn:ietf:params:scim:schemas:core:2.0:Group"
|
||||
|
|
@ -6,21 +6,21 @@ import pytest
|
|||
from fastapi import FastAPI, Security
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from litellm.auth_v2.authenticators import (
|
||||
from litellm.proxy.auth_v2.authenticators import (
|
||||
ApiKeyAuthenticator,
|
||||
HttpAuthenticator,
|
||||
JwtVerifier,
|
||||
)
|
||||
from litellm.auth_v2.config import (
|
||||
from litellm.proxy.auth_v2.config import (
|
||||
ApiKeySchemeConfig,
|
||||
AuthConfig,
|
||||
HttpBasicConfig,
|
||||
OidcProviderConfig,
|
||||
)
|
||||
from litellm.auth_v2.models import AuthMethod, Principal, PrincipalType
|
||||
from litellm.auth_v2.rbac import RbacEngine, Role
|
||||
from litellm.auth_v2.resolver import InMemoryIdentityStore, _hash_api_key
|
||||
from litellm.auth_v2.security import (
|
||||
from litellm.proxy.auth_v2.models import AuthMethod, Principal, PrincipalType
|
||||
from litellm.proxy.auth_v2.rbac import RbacEngine, Role
|
||||
from litellm.proxy.auth_v2.resolver import InMemoryIdentityStore, _hash_api_key
|
||||
from litellm.proxy.auth_v2.security import (
|
||||
AuthContext,
|
||||
get_current_principal,
|
||||
require_permission,
|
||||
Loading…
Add table
Reference in a new issue