Skip to content

Commit 730f22c

Browse files
[CDAPI-85]: Minor review comment fixes
1 parent ec4bca0 commit 730f22c

6 files changed

Lines changed: 23 additions & 23 deletions

File tree

.github/workflows/preview-env.yaml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ jobs:
126126
APIM_APIKEY: ${{ secrets.APIM_APIKEY }}
127127
API_MTLS_CERT: ${{ secrets.API_MTLS_CERT }}
128128
API_MTLS_KEY: ${{ secrets.API_MTLS_KEY }}
129+
APIM_KEY_ID: ${{ secrets.APIM_KEY_ID }}
130+
CLIENT_REQUEST_TIMEOUT: ${{ secrets.CLIENT_REQUEST_TIMEOUT }}
129131
run: |
130132
cd pathology-api/target/
131133
FN="${{ steps.names.outputs.function_name }}"
@@ -135,6 +137,8 @@ jobs:
135137
API_KEY="${APIM_APIKEY:-/cds/pathology/dev/apim/api-key}"
136138
MTLS_CERT="${API_MTLS_CERT:-/cds/pathology/dev/mtls/client1-key-public}"
137139
MTLS_KEY="${API_MTLS_KEY:-/cds/pathology/dev/mtls/client1-key-secret}"
140+
KEY_ID="${APIM_KEY_ID:-DEV-1}"
141+
CLIENT_TIMEOUT="${CLIENT_REQUEST_TIMEOUT:-10s}"
138142
echo "Deploying preview function: $FN"
139143
wait_for_lambda_ready() {
140144
while true; do
@@ -163,11 +167,11 @@ jobs:
163167
APIM_API_KEY_NAME=$API_KEY, \
164168
APIM_MTLS_CERT_NAME=$MTLS_CERT, \
165169
APIM_MTLS_KEY_NAME=$MTLS_KEY, \
166-
APIM_KEY_ID=DEV-1, \
170+
APIM_KEY_ID=$KEY_ID, \
167171
APIM_TOKEN_URL=$MOCK_URL/apim/oauth2/token, \
168172
PDM_BUNDLE_URL=$MOCK_URL/apim/check_auth, \
169173
MNS_EVENT_URL=$MOCK_URL/mns, \
170-
CLIENT_TIMEOUT=1m, \
174+
CLIENT_TIMEOUT=$CLIENT_TIMEOUT, \
171175
JWKS_SECRET_NAME=$JWKS_SECRET}" || true
172176
wait_for_lambda_ready
173177
aws lambda update-function-code --function-name "$FN" \
@@ -184,13 +188,13 @@ jobs:
184188
--environment "Variables={APIM_TOKEN_EXPIRY_THRESHOLD=$EXPIRY_THRESHOLD, \
185189
APIM_PRIVATE_KEY_NAME=$PRIVATE_KEY, \
186190
APIM_API_KEY_NAME=$API_KEY, \
187-
APIM_KEY_ID=DEV-1, \
191+
APIM_KEY_ID=$KEY_ID, \
188192
APIM_MTLS_CERT_NAME=$MTLS_CERT, \
189193
APIM_MTLS_KEY_NAME=$MTLS_KEY, \
190194
APIM_TOKEN_URL=$MOCK_URL/apim/oauth2/token, \
191195
PDM_BUNDLE_URL=$MOCK_URL/apim/check_auth, \
192196
MNS_EVENT_URL=$MOCK_URL/mns, \
193-
CLIENT_TIMEOUT=1m, \
197+
CLIENT_TIMEOUT=$CLIENT_TIMEOUT, \
194198
JWKS_SECRET_NAME=$JWKS_SECRET}" \
195199
--publish
196200
wait_for_lambda_ready

.github/workflows/stage-2-test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
retention-days: 30
5151
- name: "Upload unit test results for mocks"
5252
if: always()
53-
uses: actions/upload-artifact@v6
53+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
5454
with:
5555
name: mock-unit-test-results
5656
path: mocks/test-artefacts/

pathology-api/src/pathology_api/apim.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -89,20 +89,16 @@ def _create_client_assertion(self) -> str:
8989
claims["aud"],
9090
)
9191

92-
try:
93-
client_assertion = jwt.encode(
94-
claims,
95-
self._private_key,
96-
algorithm="RS512",
97-
headers={"kid": self._key_id},
98-
)
92+
client_assertion = jwt.encode(
93+
claims,
94+
self._private_key,
95+
algorithm="RS512",
96+
headers={"kid": self._key_id},
97+
)
9998

100-
_logger.debug("Created client assertion. kid: %s", self._key_id)
99+
_logger.debug("Created client assertion. kid: %s", self._key_id)
101100

102-
return client_assertion
103-
except BaseException:
104-
_logger.exception("Failed to create client assertion JWT")
105-
raise
101+
return client_assertion
106102

107103
def _authenticate(self) -> __AccessToken:
108104
@self._session_manager.with_session

pathology-api/src/pathology_api/config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def timedelta(self) -> timedelta:
3030
return timedelta(minutes=self.value)
3131

3232

33-
_SUPPORTED_PRIMATIVES: dict[type[Any], Callable[[str], Any]] = {
33+
_SUPPORTED_PRIMITIVES: dict[type[Any], Callable[[str], Any]] = {
3434
str: str,
3535
int: int,
3636
}
@@ -59,11 +59,11 @@ def get_optional_environment_variable[T](name: str, _type: type[T]) -> T | None:
5959
),
6060
)
6161

62-
case _ if _type in _SUPPORTED_PRIMATIVES:
62+
case _ if _type in _SUPPORTED_PRIMITIVES:
6363
if value is None:
6464
return None
6565

66-
return cast("T", _SUPPORTED_PRIMATIVES[_type](value))
66+
return cast("T", _SUPPORTED_PRIMITIVES[_type](value))
6767

6868
case _:
6969
raise ValueError(

pathology-api/src/pathology_api/http.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,14 @@ def wrapper(*args: Any, **kwargs: Any) -> Any:
6868
if self._client_certificate is not None:
6969
_logger.debug("Configuring session with client certificate...")
7070

71-
# File added to Exit stack to will be automatically cleaned up with
71+
# File added to Exit stack and will be automatically cleaned up with
7272
# the stack.
7373
cert_file = tempfile.NamedTemporaryFile( # noqa: SIM115
7474
delete=True
7575
)
7676
stack.enter_context(cert_file)
7777

78-
# File added to Exit stack to will be automatically cleaned up with
78+
# File added to Exit stack and will be automatically cleaned up with
7979
# the stack.
8080
key_file = tempfile.NamedTemporaryFile( # noqa: SIM115
8181
delete=True

pathology-api/src/pathology_api/test_apim.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def test_auth_existing_invalid_token(
144144
)
145145

146146
apim_authenticator._access_token = { # noqa SLF001 - Private access to support testing
147-
"value": "old_acess_token",
147+
"value": "old_access_token",
148148
"expiry": datetime.now(tz=timezone.utc) - timedelta(seconds=1),
149149
}
150150

0 commit comments

Comments
 (0)