Files

21 lines
1.0 KiB
Python

"""Existing feature tests run as a signed-in admin; identity tests use real auth.
This is a test-only principal, never a runtime authentication bypass. The auth,
proxy, OIDC and machine-boundary suites exercise real middleware separately.
"""
import pytest
@pytest.fixture(autouse=True)
def authenticated_feature_tests(request, monkeypatch):
# Load route modules before patching. Otherwise their direct imports can
# retain this test principal after monkeypatch restores the service module.
from backend.app import main as app_main
app_main._MUTATION_WINDOWS.clear()
if request.path.name in {"test_user_auth.py", "test_oidc_login.py", "test_security_boundaries.py", "test_mcp_rag_n8n_integrations.py"}:
return
from backend.app.db.models import GatewayUser
from backend.app.services import user_access
principal = GatewayUser(id=f"feature-test:{request.node.nodeid}", provider="authentik", issuer="test", subject="feature-test-admin", role="admin")
monkeypatch.setattr(user_access, "current_user", lambda _request: principal)