Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,22 @@
import pytest
from typing import Optional, Union, List
from clerk_backend_api import Clerk
from clerk_backend_api.security import verifytoken
from clerk_backend_api.security.types import AuthenticateRequestOptions, VerifyTokenOptions


def has_env_vars(env_vars: List[str]) -> bool:
return all(os.getenv(var, "").strip() for var in env_vars)


@pytest.fixture(autouse=True)
def clear_jwk_cache():
"""The module-global JWKS cache in verifytoken is keyed only by kid, so a
key cached by one test lets later tests skip the network fetch entirely,
making error-path tests order-dependent. Start every test with a cold cache."""
getattr(verifytoken, '__jwkcache').cache.clear()


@pytest.fixture
def secret_key() -> Optional[str]:
"""Secret Key from Clerk Dashboard."""
Expand Down