Skip to content

Commit 8db7193

Browse files
committed
[GPCAPIM-395]: Update PDS API secret handling
- Normalize line endings for PDS API secret in environment values - Update test values to use base64 encoding for PDS API secret - Adjust environment variable names for consistency with PDS integration
1 parent 95759f6 commit 8db7193

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

gateway-api/src/gateway_api/apim_app_auth/environment.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ def values() -> Environment:
3636
base64.b64decode(get_environment_variable("PDS_API_SECRET", str))
3737
.decode("utf-8")
3838
.replace("\\n", "\n")
39+
.replace("\r\n", "\n")
40+
.replace("\r", "\n")
3941
.strip()
4042
)
4143
_environment = Environment(

gateway-api/src/gateway_api/apim_app_auth/test_environment.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import base64
12
import os
23
from datetime import timedelta
34
from unittest.mock import MagicMock, patch
@@ -25,10 +26,10 @@ def test_session_manager(self) -> None:
2526
def test_values(self) -> None:
2627
os.environ["CLIENT_TIMEOUT"] = "30s"
2728
os.environ["APIM_TOKEN_URL"] = "token_url" # noqa S105 - dummy value
28-
os.environ["APIM_PRIVATE_KEY"] = "private_key"
29-
os.environ["APIM_API_KEY"] = "api_key"
29+
os.environ["PDS_API_SECRET"] = base64.b64encode(b"private_key").decode("utf-8")
30+
os.environ["PDS_API_TOKEN"] = "api_key" # noqa S105 - dummy value
3031
os.environ["APIM_TOKEN_EXPIRY_THRESHOLD"] = "60s" # noqa S105 - dummy value
31-
os.environ["APIM_KEY_ID"] = "key_id"
32+
os.environ["PDS_API_KID"] = "key_id"
3233

3334
environ = environment.values()
3435

0 commit comments

Comments
 (0)