Skip to content

Commit

Permalink
handle safid exceptions in the same way as passticket
Browse files Browse the repository at this point in the history
Signed-off-by: ac892247 <[email protected]>
  • Loading branch information
achmelo committed Oct 31, 2024
1 parent dfcf766 commit abf06aa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
Expand All @@ -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
}

Expand All @@ -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
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -74,8 +75,8 @@ public ResponseEntity<ApiMessageView> handleSafIdtExceptions(RuntimeException ex
.body(messageView);
}

@ExceptionHandler(value = {ApplicationNameNotFoundException.class})
public ResponseEntity<ApiMessageView> handleApplIdNotFoundException(ApplicationNameNotFoundException ex) {
@ExceptionHandler(value = {ApplicationNameNotFoundException.class, HttpMessageNotReadableException.class})
public ResponseEntity<ApiMessageView> handleApplIdNotFoundException() {
ApiMessageView messageView = messageService.createMessage("org.zowe.apiml.security.ticket.invalidApplicationName").mapToView();
return ResponseEntity
.status(HttpStatus.BAD_REQUEST)
Expand Down

0 comments on commit abf06aa

Please sign in to comment.