File size: 948 Bytes
c794b6b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import os
import pytest


@pytest.fixture(autouse=True)
def _isolate_auth_env(request):
    """Contract tests disable JWT; auth tests opt in via module env."""
    os.environ["CEPHEUS_API_KEY"] = "test-key"
    os.environ.setdefault("CEPHEUS_DEV_JWT_SECRET", "test-jwt-secret-for-ci-min-32-chars!!")
    os.environ.setdefault(
        "CEPHEUS_DEV_AUTH_USERS",
        '[{"username":"admin","password":"admin","role":"admin"},'
        '{"username":"staff","password":"staff","role":"staff"}]',
    )
    os.environ.pop("CEPHEUS_PRODUCTION", None)
    module = request.module.__name__
    if module.endswith("test_auth") or module.endswith("test_refresh_store"):
        os.environ["CEPHEUS_AUTH_DEV_MODE"] = "1"
    else:
        os.environ.pop("CEPHEUS_AUTH_DEV_MODE", None)
        os.environ.pop("CEPHEUS_JWT_SECRET", None)
    try:
        import main as main_module
        main_module.API_KEY = "test-key"
    except Exception:
        pass