Skip to content

Commit

Permalink
ATO-1321: Handle null internalCommonSubectId
Browse files Browse the repository at this point in the history
We've noticed during previous work[1] that sometimes a user can
end up at arbitrary points in a journey where specific fields on
their session are not defined through, This commit intends to handle
that more gracefully by checking the null-ness of the internalCommon
subjectId before using it as a key to query AuthUserInfo.

[1]-#5730
  • Loading branch information
Ryan-Andrews99 committed Feb 4, 2025
1 parent d8577b0 commit 5a266cf
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ public APIGatewayProxyResponseEvent handleRequestWithUserSession(
}

UserInfo userInfo;

if (Objects.isNull(internalCommonSubjectIdentifier)) {
LOG.warn("InternalCommonSubjectId is null on orch session");
return generateApiGatewayProxyErrorResponse(400, ErrorResponse.ERROR_1000);
}
try {
Optional<UserInfo> userInfoFromStorage =
userInfoStorageService.getAuthenticationUserInfo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,23 @@ void shouldReturnErrorIfOrchSessionIsNotFound() throws Json.JsonException {
verifyNoInteractions(cloudwatchMetricsService, auditService);
}

@Test
void shouldReturnErrorWhenInternalCommonSubjectIdIsNullOnOrchSession()
throws Json.JsonException {
when(sessionService.getSession(anyString())).thenReturn(Optional.of(session));
when(orchSessionService.getSession(anyString()))
.thenReturn(
Optional.of(
new OrchSessionItem(SESSION_ID).withInternalCommonSubjectId(null)));
when(clientSessionService.getClientSession(any()))
.thenReturn(Optional.of(getClientSession()));
var result = handler.handleRequest(event, context);

assertThat(result, hasStatus(400));
assertThat(result, hasBody(objectMapper.writeValueAsString(ErrorResponse.ERROR_1000)));
verifyNoInteractions(cloudwatchMetricsService, auditService);
}

@Test
void shouldReturnCOMPLETEDStatusWhenIdentityCredentialIsPresent() throws Json.JsonException {
usingValidSession();
Expand Down

0 comments on commit 5a266cf

Please sign in to comment.