diff --git a/integration-tests/src/test/java/org/zowe/apiml/integration/zaas/SafIdTokensTest.java b/integration-tests/src/test/java/org/zowe/apiml/integration/zaas/SafIdTokensTest.java index 889e2b851a..a86bb4226c 100644 --- a/integration-tests/src/test/java/org/zowe/apiml/integration/zaas/SafIdTokensTest.java +++ b/integration-tests/src/test/java/org/zowe/apiml/integration/zaas/SafIdTokensTest.java @@ -184,7 +184,7 @@ void givenInvalidApplicationName() { .when() .post(ZAAS_SAFIDT_URI) .then() - .statusCode(is(SC_BAD_REQUEST)) + .statusCode(is(SC_INTERNAL_SERVER_ERROR)) .body("messages.find { it.messageNumber == 'ZWEAG141E' }.messageContent", containsString(expectedMessage)); //@formatter:on } @@ -211,19 +211,6 @@ class WhenGeneratingSafIdToken_returnNotFound { private final String jwt = getZosmfJwtToken(); - @Test - void givenNoContentType() { - //@formatter:off - given() - .body(new TicketRequest(APPLICATION_NAME)) - .cookie(COOKIE, jwt) - .when() - .post(ZAAS_SAFIDT_URI) - .then() - .statusCode(is(SC_NOT_FOUND)); - //@formatter:on - } - @Test void givenInvalidContentType() { //@formatter:off @@ -234,7 +221,7 @@ void givenInvalidContentType() { .when() .post(ZAAS_SAFIDT_URI) .then() - .statusCode(is(SC_NOT_FOUND)); + .statusCode(is(SC_UNSUPPORTED_MEDIA_TYPE)); //@formatter:on } @@ -243,10 +230,11 @@ void givenNoBody() { //@formatter:off given() .cookie(COOKIE, jwt) + .noContentType() .when() .post(ZAAS_SAFIDT_URI) .then() - .statusCode(is(SC_NOT_FOUND)); + .statusCode(is(SC_BAD_REQUEST)); //@formatter:on } } diff --git a/zaas-service/src/main/java/org/zowe/apiml/zaas/zaas/ZaasExceptionHandler.java b/zaas-service/src/main/java/org/zowe/apiml/zaas/zaas/ZaasExceptionHandler.java index d4c984b378..095735164d 100644 --- a/zaas-service/src/main/java/org/zowe/apiml/zaas/zaas/ZaasExceptionHandler.java +++ b/zaas-service/src/main/java/org/zowe/apiml/zaas/zaas/ZaasExceptionHandler.java @@ -19,6 +19,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; +import org.springframework.http.converter.HttpMessageNotReadableException; import org.springframework.security.access.AccessDeniedException; import org.springframework.security.core.AuthenticationException; import org.springframework.util.Assert; @@ -74,8 +75,8 @@ public ResponseEntity handleSafIdtExceptions(RuntimeException ex .body(messageView); } - @ExceptionHandler(value = {ApplicationNameNotFoundException.class}) - public ResponseEntity handleApplIdNotFoundException(ApplicationNameNotFoundException ex) { + @ExceptionHandler(value = {ApplicationNameNotFoundException.class, HttpMessageNotReadableException.class}) + public ResponseEntity handleApplIdNotFoundException() { ApiMessageView messageView = messageService.createMessage("org.zowe.apiml.security.ticket.invalidApplicationName").mapToView(); return ResponseEntity .status(HttpStatus.BAD_REQUEST)