Skip to content
This repository has been archived by the owner on May 16, 2023. It is now read-only.

Fix: Changed Exception Response Status to 422 if group id is missing #199

Merged
merged 1 commit into from
Oct 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/main/java/app/coronawarn/quicktest/utils/Utilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public static ZonedDateTime getEndTimeForLocalDateInGermanyInUtc() {
* Get tenantID and pocID from Token.
*
* @return Map with tokens from keycloak (tenantID and pocID)
* @throws ResponseStatusException 500 if Ids not found in User-Token
* @throws ResponseStatusException 412 if Ids not found in User-Token
*/
public Map<String, String> getIdsFromToken() throws ResponseStatusException {

Expand Down Expand Up @@ -113,7 +113,7 @@ public Map<String, String> getIdsFromToken() throws ResponseStatusException {
if (!ids.containsKey(quickTestConfig.getTenantIdKey())
|| !ids.containsKey(quickTestConfig.getTenantPointOfCareIdKey())) {
log.warn("Ids not found in User-Token");
throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR);
throw new ResponseStatusException(HttpStatus.PRECONDITION_FAILED, "User has no Group assigned");
}
return ids;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public void testGetIdsFromTokenFailed() {
springSecurityContext.setAuthentication(token);

ResponseStatusException e = Assertions.assertThrows(ResponseStatusException.class, () -> utilities.getIdsFromToken());
assertEquals(e.getStatus(), HttpStatus.INTERNAL_SERVER_ERROR, "wrong status");
assertEquals(e.getStatus(), HttpStatus.PRECONDITION_FAILED, "wrong status");
}

@Test
Expand Down