Skip to content

Commit 8006a1a

Browse files
committed
Ensure audience and tenant id env vars are specified
1 parent b4fcd7d commit 8006a1a

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

manage_breast_screening/dicom/tests/test_token_validator.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,18 @@
99

1010
@patch(f"{TokenValidator.__module__}.logger")
1111
class TestTokenValidator:
12+
@pytest.fixture(autouse=True)
13+
def setup_env(self):
14+
with patch.dict(
15+
"os.environ",
16+
{
17+
"API_AUDIENCE": "test_audience",
18+
"TENANT_ID": "test_tenant_id",
19+
"BYPASS_API_TOKEN_AUTH": "false",
20+
},
21+
):
22+
yield
23+
1224
@pytest.fixture
1325
def mock_urlopen_response(self):
1426
return {

manage_breast_screening/dicom/token_validator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
class TokenValidator(HttpBearer):
1515
def __init__(self):
1616
self.bypass_auth = os.getenv("BYPASS_API_TOKEN_AUTH", "false").lower() == "true"
17-
self.api_audience = os.getenv("API_AUDIENCE", "")
18-
self.tenant_id = os.getenv("TENANT_ID", "")
17+
self.api_audience = os.environ["API_AUDIENCE"]
18+
self.tenant_id = os.environ["TENANT_ID"]
1919
self.discovery_keys_url = (
2020
"https://login.microsoftonline.com/"
2121
+ self.tenant_id

0 commit comments

Comments
 (0)