mirror of
https://github.com/fabioformosa/quartz-manager.git
synced 2025-12-30 14:13:16 +09:00
#63 fixed tests
This commit is contained in:
@@ -7,6 +7,9 @@ import org.quartz.Scheduler;
|
||||
import org.springframework.context.support.GenericApplicationContext;
|
||||
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
class SchedulerConfigTest {
|
||||
|
||||
public static final String TEST_SCHEDULER_NAME = "foo";
|
||||
@@ -16,7 +19,9 @@ class SchedulerConfigTest {
|
||||
void givenASchedulerName_whenTheSchedulerIsInstatiated_thenTheSchedulerHasThatName() throws Exception {
|
||||
QuartzModuleProperties quartzModuleProperties = new QuartzModuleProperties();
|
||||
quartzModuleProperties.getProperties().put("org.quartz.scheduler.instanceName", TEST_SCHEDULER_NAME);
|
||||
SchedulerConfig schedulerConfig = new SchedulerConfig(quartzModuleProperties);
|
||||
List<QuartzModuleProperties> quartzModulePropertiesList = new ArrayList<>();
|
||||
quartzModulePropertiesList.add(quartzModuleProperties);
|
||||
SchedulerConfig schedulerConfig = new SchedulerConfig(quartzModulePropertiesList);
|
||||
GenericApplicationContext applicationContext = new GenericApplicationContext();
|
||||
applicationContext.refresh();
|
||||
SchedulerFactoryBean schedulerFactoryBean = schedulerConfig.schedulerFactoryBean(schedulerConfig.jobFactory(applicationContext));
|
||||
@@ -29,7 +34,9 @@ class SchedulerConfigTest {
|
||||
@Test
|
||||
void givenNoSchedulerName_whenTheSchedulerIsInstatiated_thenTheSchedulerHasTheDefaultName() throws Exception {
|
||||
QuartzModuleProperties quartzModuleProperties = new QuartzModuleProperties();
|
||||
SchedulerConfig schedulerConfig = new SchedulerConfig(quartzModuleProperties);
|
||||
List<QuartzModuleProperties> quartzModulePropertiesList = new ArrayList<>();
|
||||
quartzModulePropertiesList.add(quartzModuleProperties);
|
||||
SchedulerConfig schedulerConfig = new SchedulerConfig(quartzModulePropertiesList);
|
||||
GenericApplicationContext applicationContext = new GenericApplicationContext();
|
||||
applicationContext.refresh();
|
||||
SchedulerFactoryBean schedulerFactoryBean = schedulerConfig.schedulerFactoryBean(schedulerConfig.jobFactory(applicationContext));
|
||||
|
||||
@@ -7,7 +7,7 @@ import org.springframework.http.*;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
import static it.fabioformosa.quartzmanager.security.WebSecurityConfigJWT.LOGIN_PATH;
|
||||
import static it.fabioformosa.quartzmanager.common.config.QuartzManagerPaths.QUARTZ_MANAGER_LOGIN_PATH;
|
||||
|
||||
public class AbstractSecurityLoginTest {
|
||||
@Autowired
|
||||
@@ -23,7 +23,7 @@ public class AbstractSecurityLoginTest {
|
||||
|
||||
HttpEntity<MultiValueMap<String, String>> entity = new HttpEntity<>(map, headers);
|
||||
|
||||
ResponseEntity<UserTokenState> responseEntity = testRestTemplate.exchange(LOGIN_PATH, HttpMethod.POST, entity, UserTokenState.class);
|
||||
ResponseEntity<UserTokenState> responseEntity = testRestTemplate.exchange(QUARTZ_MANAGER_LOGIN_PATH, HttpMethod.POST, entity, UserTokenState.class);
|
||||
return responseEntity;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package it.fabioformosa.quartzmanager.security;
|
||||
|
||||
import it.fabioformosa.quartzmanager.security.controllers.TestController;
|
||||
import org.hamcrest.core.IsNot;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.ValueSource;
|
||||
@@ -12,7 +13,7 @@ import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
||||
|
||||
import static it.fabioformosa.quartzmanager.security.WebSecurityConfigJWT.LOGIN_PATH;
|
||||
import static it.fabioformosa.quartzmanager.common.config.QuartzManagerPaths.QUARTZ_MANAGER_LOGIN_PATH;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
@SpringBootTest
|
||||
@@ -51,7 +52,7 @@ public class SecurityControllerTest {
|
||||
@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());
|
||||
.andExpect(status().is(IsNot.not(403)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -63,7 +64,7 @@ public class SecurityControllerTest {
|
||||
|
||||
@Test
|
||||
void givenAnAnonymousUser_whenCalledTheLoginPath_thenShouldReturn2xx() throws Exception {
|
||||
mockMvc.perform(MockMvcRequestBuilders.post(LOGIN_PATH)
|
||||
mockMvc.perform(MockMvcRequestBuilders.post(QUARTZ_MANAGER_LOGIN_PATH)
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.accept("application/json")
|
||||
.param("username", "foo")
|
||||
|
||||
Reference in New Issue
Block a user