use of org.springframework.security.test.context.support.WithMockUser in project hub-alert by blackducksoftware.
the class JiraServerGlobalConfigControllerTestIT method verifyValidateEndpointTest.
@Test
@WithMockUser(roles = AlertIntegrationTestConstants.ROLE_ALERT_ADMIN)
public void verifyValidateEndpointTest() throws Exception {
String urlPath = REQUEST_URL + "/validate";
MockHttpServletRequestBuilder request = MockMvcRequestBuilders.post(urlPath).with(SecurityMockMvcRequestPostProcessors.user("admin").roles(AlertIntegrationTestConstants.ROLE_ALERT_ADMIN)).with(SecurityMockMvcRequestPostProcessors.csrf());
UUID uuid = UUID.randomUUID();
JiraServerGlobalConfigModel configModel = createConfigModel(uuid);
request.content(gson.toJson(configModel));
request.contentType(MEDIA_TYPE);
mockMvc.perform(request).andExpect(MockMvcResultMatchers.status().isOk());
}
use of org.springframework.security.test.context.support.WithMockUser in project hub-alert by blackducksoftware.
the class JiraServerGlobalConfigControllerTestIT method verifyDeleteEndpointTest.
@Test
@WithMockUser(roles = AlertIntegrationTestConstants.ROLE_ALERT_ADMIN)
public void verifyDeleteEndpointTest() throws Exception {
JiraServerGlobalConfigModel jiraServerGlobalConfigModel = saveConfigModel(createConfigModel(UUID.randomUUID()));
String urlPath = REQUEST_URL + "/" + jiraServerGlobalConfigModel.getId();
MockHttpServletRequestBuilder request = MockMvcRequestBuilders.delete(urlPath).with(SecurityMockMvcRequestPostProcessors.user("admin").roles(AlertIntegrationTestConstants.ROLE_ALERT_ADMIN)).with(SecurityMockMvcRequestPostProcessors.csrf());
mockMvc.perform(request).andExpect(MockMvcResultMatchers.status().isNoContent());
}
use of org.springframework.security.test.context.support.WithMockUser in project hub-alert by blackducksoftware.
the class JiraServerGlobalConfigControllerTestIT method verifyUpdateEndpointTest.
@Test
@WithMockUser(roles = AlertIntegrationTestConstants.ROLE_ALERT_ADMIN)
public void verifyUpdateEndpointTest() throws Exception {
JiraServerGlobalConfigModel configModel = createConfigModel(UUID.randomUUID());
JiraServerGlobalConfigModel jiraServerGlobalConfigModel = saveConfigModel(configModel);
String urlPath = REQUEST_URL + "/" + jiraServerGlobalConfigModel.getId();
MockHttpServletRequestBuilder request = MockMvcRequestBuilders.put(urlPath).with(SecurityMockMvcRequestPostProcessors.user("admin").roles(AlertIntegrationTestConstants.ROLE_ALERT_ADMIN)).with(SecurityMockMvcRequestPostProcessors.csrf());
request.content(gson.toJson(jiraServerGlobalConfigModel));
request.contentType(MEDIA_TYPE);
mockMvc.perform(request).andExpect(MockMvcResultMatchers.status().isNoContent());
}
use of org.springframework.security.test.context.support.WithMockUser in project hub-alert by blackducksoftware.
the class JiraServerGlobalConfigControllerTestIT method verifyTestEndpointTest.
@Disabled("Test action not yet implemented")
@Test
@WithMockUser(roles = AlertIntegrationTestConstants.ROLE_ALERT_ADMIN)
public void verifyTestEndpointTest() throws Exception {
String urlPath = REQUEST_URL + "/test";
MockHttpServletRequestBuilder request = MockMvcRequestBuilders.post(urlPath).with(SecurityMockMvcRequestPostProcessors.user("admin").roles(AlertIntegrationTestConstants.ROLE_ALERT_ADMIN)).with(SecurityMockMvcRequestPostProcessors.csrf());
UUID uuid = UUID.randomUUID();
JiraServerGlobalConfigModel configModel = createConfigModel(uuid);
request.content(gson.toJson(configModel));
request.contentType(MEDIA_TYPE);
mockMvc.perform(request).andExpect(MockMvcResultMatchers.status().isOk());
}
use of org.springframework.security.test.context.support.WithMockUser in project hub-alert by blackducksoftware.
the class JiraServerGlobalConfigControllerTestIT method verifyDisablePluginEndpointTest.
@Test
@WithMockUser(roles = AlertIntegrationTestConstants.ROLE_ALERT_ADMIN)
public void verifyDisablePluginEndpointTest() throws Exception {
String urlPath = REQUEST_URL + "/install-plugin";
MockHttpServletRequestBuilder request = MockMvcRequestBuilders.post(urlPath).with(SecurityMockMvcRequestPostProcessors.user("admin").roles(AlertIntegrationTestConstants.ROLE_ALERT_ADMIN)).with(SecurityMockMvcRequestPostProcessors.csrf());
UUID uuid = UUID.randomUUID();
// Need to just verify the endpoint exists and not actually connect to Jira
JiraServerGlobalConfigModel configModel = createConfigModel(uuid, "badUrl");
request.content(gson.toJson(configModel));
request.contentType(MEDIA_TYPE);
mockMvc.perform(request).andExpect(MockMvcResultMatchers.status().isOk());
}
Aggregations