""" Test helper for SSO-based authentication. Provides utilities to create test tokens by injecting them directly into the token cache, bypassing SSO center verification. """ import uuid from middleware.auth_middleware import token_cache def create_test_token(user_data: dict) -> str: """ Create a fake SSO token for testing by injecting it into the token cache. Args: user_data: Dict with id, username, email, role Returns: A fake token string that will be recognized by the auth middleware. """ fake_token = f"test_sso_token_{uuid.uuid4().hex}" token_cache.set(fake_token, user_data) return fake_token