mirror of
https://github.com/fabioformosa/quartz-manager.git
synced 2026-05-14 22:00:30 +09:00
#63 added security test to test the whitelisted endpoints
This commit is contained in:
@@ -2,6 +2,8 @@ package it.fabioformosa.quartzmanager.security;
|
||||
|
||||
import it.fabioformosa.quartzmanager.security.controllers.TestController;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.ValueSource;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
@@ -45,10 +47,11 @@ public class SecurityControllerTest {
|
||||
.andExpect(status().isUnauthorized());
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenAnAnonymousUser_whenRequestedSwaggerResource_thenShouldReturn2xx() throws Exception {
|
||||
mockMvc.perform(MockMvcRequestBuilders.get("/swagger-ui.html"))
|
||||
.andExpect(status().isOk());
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = {"/swagger-ui.html", "/v3/api-docs/**", "/swagger-resources/**", "/webjars/**"})
|
||||
void givenAnAnonymousUser_whenRequestedAnEndpointInWhitelist_thenShouldnotReturnForbidden(String whitelistEndpoint) throws Exception {
|
||||
mockMvc.perform(MockMvcRequestBuilders.get(whitelistEndpoint))
|
||||
.andExpect(status().isNotFound());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -18,12 +18,6 @@ public class TestController {
|
||||
|
||||
}
|
||||
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
@GetMapping("/swagger-ui.html")
|
||||
public void getSwaggerUI(){
|
||||
|
||||
}
|
||||
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
@GetMapping(QUARTZ_MANAGER + "/scheduler")
|
||||
public void getQuartzManagerScheduler(){
|
||||
|
||||
Reference in New Issue
Block a user