-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add more tests for Onboarding as well as exception handler for Access…
…DeniedException Previously AccessDeniedException would result in an 5xx http status code, with stack trace included. Returning status code 403 is more correct
- Loading branch information
Showing
3 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
onyxia-api/src/main/java/fr/insee/onyxia/api/controller/RestExceptionHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package fr.insee.onyxia.api.controller; | ||
|
||
import org.springframework.http.HttpStatus; | ||
import org.springframework.security.access.AccessDeniedException; | ||
import org.springframework.web.bind.annotation.ExceptionHandler; | ||
import org.springframework.web.bind.annotation.ResponseStatus; | ||
import org.springframework.web.bind.annotation.RestControllerAdvice; | ||
|
||
@RestControllerAdvice | ||
public class RestExceptionHandler { | ||
|
||
@ResponseStatus(value = HttpStatus.FORBIDDEN) | ||
@ExceptionHandler(AccessDeniedException.class) | ||
public void handleAccessDeniedException(Exception ignored) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters