use of org.springframework.security.test.context.support.WithUserDetails in project nixmash-blog by mintster.
the class AdminControllerTests method registeredUserCannotAccessAdmin.
@Test
@WithUserDetails(value = "erwin", userDetailsServiceBeanName = "currentUserDetailsService")
public void registeredUserCannotAccessAdmin() throws Exception {
// Erwin a registered user but not in ROLE_POSTS
RequestBuilder request = get("/admin").with(csrf());
mvc.perform(request).andExpect(status().isForbidden()).andExpect(forwardedUrl("/403"));
}
use of org.springframework.security.test.context.support.WithUserDetails in project oc-explorer by devgateway.
the class UserDashboardRestControllerTest method saveDashboardForCurrentUser.
@Test
@WithUserDetails(value = "admin", userDetailsServiceBeanName = "testUserDetailsAdminProcuringEntity")
public void saveDashboardForCurrentUser() {
UserDashboard ud = new UserDashboard();
ud.setName("some name");
ud.setFormUrlEncodedBody("some body");
ResponseEntity<Void> responseEntity = userDashboardRestController.saveDashboardForCurrentUser(ud);
Assert.assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
}
use of org.springframework.security.test.context.support.WithUserDetails in project ocvn by devgateway.
the class UserDashboardRestControllerTest method saveDashboardForCurrentUser.
@Test
@WithUserDetails(value = "admin", userDetailsServiceBeanName = "testUserDetailsAdminProcuringEntity")
public void saveDashboardForCurrentUser() {
UserDashboard ud = new UserDashboard();
ud.setName("some name");
ud.setFormUrlEncodedBody("some body");
ResponseEntity<Void> responseEntity = userDashboardRestController.saveDashboardForCurrentUser(ud);
Assert.assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
}
use of org.springframework.security.test.context.support.WithUserDetails in project ArachneCentralAPI by OHDSI.
the class AnalysisControllerTests method testUpdateAnalysisDescription.
@Test
@WithUserDetails(value = ADMIN_EMAIL)
@DatabaseSetups({ @DatabaseSetup("/data/study-with-contributor.xml"), @DatabaseSetup("/data/analysis/analysis-before-updating.xml") })
@ExpectedDatabases({ @ExpectedDatabase(value = "/data/study-with-contributor.xml", assertionMode = NON_STRICT), @ExpectedDatabase(value = "/data/analysis/analysis-after-description-updating.xml", assertionMode = NON_STRICT) })
public void testUpdateAnalysisDescription() throws Exception {
AnalysisUpdateDTO analysisDTO = new AnalysisUpdateDTO();
analysisDTO.setDescription(UPDATED_ANALYSIS_DESCRIPTION_VALUE);
analysisDTO.setTypeId(ANALYSIS_TYPE_ID);
testUpdate(analysisDTO, UPDATED_ANALYSIS_DESCR_JSON_OBJECT, null);
}
use of org.springframework.security.test.context.support.WithUserDetails in project ArachneCentralAPI by OHDSI.
the class AnalysisControllerTests method testUpdateCodeFile.
@Test
@WithUserDetails(value = ADMIN_EMAIL)
@DatabaseSetups({ @DatabaseSetup("/data/study-with-contributor.xml"), @DatabaseSetup("/data/analysis/analysis-list.xml"), @DatabaseSetup("/data/analysis/code-file-before-deleting.xml") })
@ExpectedDatabases({ @ExpectedDatabase(value = "/data/study-with-contributor.xml", assertionMode = NON_STRICT), @ExpectedDatabase(value = "/data/analysis/code-file-after-updating.xml", assertionMode = NON_STRICT) })
public void testUpdateCodeFile() throws Exception {
String uuid = "68b75ac9-ab29-49a6-8edb-95142456f5fc";
String path = this.getClass().getResource("/test.jpg").getPath();
FileInputStream fileInputStream = new FileInputStream(path);
MockMultipartFile multipartFile = new MockMultipartFile("file", "test_updated.jpg", "image/jpeg", fileInputStream);
MockMultipartHttpServletRequestBuilder builder = fileUpload("/api/v1/analysis-management/analyses/{analysisId}/files/{fileUuid}", ANALYSIS_ID, uuid);
builder.with(request -> {
request.setMethod("PUT");
return request;
});
mvc.perform(builder.file(multipartFile).param("label", "labelUploadedFile").param("file", path).contentType(MULTIPART_FORM_DATA)).andExpect(NO_ERROR_CODE).andExpect(TRUE_RESULT);
}
Aggregations