Skip to content

Commit ad4eb8b

Browse files
authored
Merge pull request #3506 from PolicyEngine/fix/gateway-auth-test-env
Fix gateway auth unit tests under deploy env
2 parents c1bc89c + 8a7c1df commit ad4eb8b

3 files changed

Lines changed: 24 additions & 0 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed the staging App Engine deploy build by isolating gateway-auth unit tests from deploy-time auth environment variables.

tests/unit/libs/test_gateway_auth.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@
3232
)
3333

3434

35+
@pytest.fixture(autouse=True)
36+
def clear_gateway_auth_env(monkeypatch):
37+
"""Isolate unit tests from any gateway-auth env baked into the build image."""
38+
for key in (*GATEWAY_AUTH_ENV_VARS, GATEWAY_AUTH_REQUIRED_ENV):
39+
monkeypatch.delenv(key, raising=False)
40+
41+
3542
def _make_token_response(token: str, expires_in: int = 86400) -> MagicMock:
3643
response = MagicMock()
3744
response.status_code = 200

tests/unit/libs/test_simulation_api_modal.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,22 @@
4949

5050
pytest_plugins = ("tests.fixtures.libs.simulation_api_modal",)
5151

52+
GATEWAY_AUTH_TEST_ENV_VARS = (
53+
"GATEWAY_AUTH_ISSUER",
54+
"GATEWAY_AUTH_AUDIENCE",
55+
"GATEWAY_AUTH_CLIENT_ID",
56+
"GATEWAY_AUTH_CLIENT_SECRET",
57+
"GATEWAY_AUTH_CLIENT_SECRET_RESOURCE",
58+
"GATEWAY_AUTH_REQUIRED",
59+
)
60+
61+
62+
@pytest.fixture(autouse=True)
63+
def clear_gateway_auth_env(monkeypatch):
64+
"""Isolate unit tests from gateway-auth env injected during Docker builds."""
65+
for key in GATEWAY_AUTH_TEST_ENV_VARS:
66+
monkeypatch.delenv(key, raising=False)
67+
5268

5369
class TestModalSimulationExecution:
5470
"""Tests for the ModalSimulationExecution dataclass."""

0 commit comments

Comments
 (0)