use of org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder in project hub-alert by blackducksoftware.
the class HomeControllerTestIT method testIndex.
@Test
public void testIndex() throws Exception {
final MockHttpServletRequestBuilder request = MockMvcRequestBuilders.get(homeUrl);
mockMvc.perform(request).andExpect(MockMvcResultMatchers.status().isOk());
}
use of org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder in project hub-alert by blackducksoftware.
the class GlobalHubConfigControllerTestIT method testTestConfig.
@Test
@Override
@WithMockUser(roles = "ADMIN")
public void testTestConfig() throws Exception {
final String hubUrl = testProperties.getProperty(TestPropertyKey.TEST_HUB_SERVER_URL);
final String timeout = testProperties.getProperty(TestPropertyKey.TEST_HUB_TIMEOUT);
final String apiKey = testProperties.getProperty(TestPropertyKey.TEST_HUB_API_KEY);
final String alwaysTrust = testProperties.getProperty(TestPropertyKey.TEST_TRUST_HTTPS_CERT);
final String testRestUrl = restUrl + "/test";
globalProperties.setHubUrl(hubUrl);
globalProperties.setHubTrustCertificate(Boolean.valueOf(alwaysTrust));
final MockHttpServletRequestBuilder request = MockMvcRequestBuilders.post(testRestUrl).with(SecurityMockMvcRequestPostProcessors.user("admin").roles("ADMIN"));
final GlobalHubConfigRestModel hubRestModel = new GlobalHubConfigRestModel(null, hubUrl, String.valueOf(timeout), apiKey, false, null, null, null, null, false, "true");
request.content(gson.toJson(hubRestModel));
request.contentType(contentType);
mockMvc.perform(request).andExpect(MockMvcResultMatchers.status().isOk());
assertTrue(true);
globalProperties.setHubUrl(null);
globalProperties.setHubTrustCertificate(Boolean.FALSE);
}
use of org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder in project hub-alert by blackducksoftware.
the class GlobalSchedulingConfigControllerTestIT method testTestConfig.
@Test
@Override
@WithMockUser(roles = "ADMIN")
public void testTestConfig() throws Exception {
globalEntityRepository.deleteAll();
final GlobalSchedulingConfigEntity savedEntity = globalEntityRepository.save(entity);
final String testRestUrl = restUrl + "/test";
final MockHttpServletRequestBuilder request = MockMvcRequestBuilders.post(testRestUrl).with(SecurityMockMvcRequestPostProcessors.user("admin").roles("ADMIN"));
restModel.setId(String.valueOf(savedEntity.getId()));
request.content(gson.toJson(restModel));
request.contentType(contentType);
mockMvc.perform(request).andExpect(MockMvcResultMatchers.status().isMethodNotAllowed());
}
use of org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder in project hub-alert by blackducksoftware.
the class ControllerTest method testValidConfig.
@Test
@WithMockUser(roles = "ADMIN")
public void testValidConfig() throws Exception {
entityRepository.deleteAll();
final String testRestUrl = restUrl + "/validate";
final MockHttpServletRequestBuilder request = MockMvcRequestBuilders.post(testRestUrl).with(SecurityMockMvcRequestPostProcessors.user("admin").roles("ADMIN"));
request.content(gson.toJson(restModel));
request.contentType(contentType);
mockMvc.perform(request).andExpect(MockMvcResultMatchers.status().isOk());
}
use of org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder in project hub-alert by blackducksoftware.
the class GlobalControllerTest method testPutConfig.
@Test
@WithMockUser(roles = "ADMIN")
public void testPutConfig() throws Exception {
globalEntityRepository.deleteAll();
final GE savedEntity = globalEntityRepository.save(entity);
final MockHttpServletRequestBuilder request = MockMvcRequestBuilders.put(restUrl).with(SecurityMockMvcRequestPostProcessors.user("admin").roles("ADMIN"));
restModel.setId(String.valueOf(savedEntity.getId()));
request.content(gson.toJson(restModel));
request.contentType(contentType);
mockMvc.perform(request).andExpect(MockMvcResultMatchers.status().isAccepted());
}
Aggregations