use of org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder in project hub-alert by blackducksoftware.
the class GlobalControllerTest method testGetConfig.
@Test
@WithMockUser(roles = "ADMIN")
public void testGetConfig() throws Exception {
final MockHttpServletRequestBuilder request = MockMvcRequestBuilders.get(restUrl).with(SecurityMockMvcRequestPostProcessors.user("admin").roles("ADMIN"));
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 testPostConfig.
@Test
@WithMockUser(roles = "ADMIN")
public void testPostConfig() throws Exception {
globalEntityRepository.deleteAll();
final MockHttpServletRequestBuilder request = MockMvcRequestBuilders.post(restUrl).with(SecurityMockMvcRequestPostProcessors.user("admin").roles("ADMIN"));
request.content(gson.toJson(restModel));
request.contentType(contentType);
mockMvc.perform(request).andExpect(MockMvcResultMatchers.status().isCreated());
}
use of org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder in project hub-alert by blackducksoftware.
the class GlobalControllerTest method testTestConfig.
@Test
@WithMockUser(roles = "ADMIN")
public void testTestConfig() throws Exception {
final String testRestUrl = restUrl + "/test";
final MockHttpServletRequestBuilder request = MockMvcRequestBuilders.post(testRestUrl).with(SecurityMockMvcRequestPostProcessors.user("admin").roles("ADMIN"));
mockMvc.perform(request).andExpect(MockMvcResultMatchers.status().isMethodNotAllowed());
}
use of org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder in project hub-alert by blackducksoftware.
the class LoginControllerTestIT method testLogout.
@Test
public void testLogout() throws Exception {
final MockHttpServletRequestBuilder request = MockMvcRequestBuilders.post(logoutUrl).with(SecurityMockMvcRequestPostProcessors.user("admin").roles("ADMIN"));
mockMvc.perform(request).andExpect(MockMvcResultMatchers.status().isNoContent());
}
use of org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder in project hub-alert by blackducksoftware.
the class LoginControllerTestIT method testLogin.
@Test
public void testLogin() throws Exception {
final MockHttpServletRequestBuilder request = MockMvcRequestBuilders.post(loginUrl);
final TestProperties testProperties = new TestProperties();
final MockLoginRestModel mockLoginRestModel = new MockLoginRestModel();
mockLoginRestModel.setHubUsername(testProperties.getProperty(TestPropertyKey.TEST_USERNAME));
mockLoginRestModel.setHubPassword(testProperties.getProperty(TestPropertyKey.TEST_PASSWORD));
globalProperties.setHubTrustCertificate(Boolean.valueOf(testProperties.getProperty(TestPropertyKey.TEST_TRUST_HTTPS_CERT)));
globalProperties.setHubUrl(testProperties.getProperty(TestPropertyKey.TEST_HUB_SERVER_URL));
final String restModel = mockLoginRestModel.getRestModelJson();
request.content(restModel);
request.contentType(contentType);
mockMvc.perform(request).andExpect(MockMvcResultMatchers.status().isOk());
}
Aggregations