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 ArachneCentralAPI by OHDSI.
the class UserControllerTests method testGetProfile.
@Test
@WithUserDetails(value = ADMIN_EMAIL)
@DatabaseSetup("/data/user/enabled-user.xml")
@ExpectedDatabase(value = "/data/user/enabled-user.xml", assertionMode = NON_STRICT)
public void testGetProfile() throws Exception {
MvcResult mvcResult = mvc.perform(get("/api/v1/user-management/users/" + USER_2_UUID + "/profile")).andExpect(NO_ERROR_CODE).andExpect(OK_STATUS).andReturn();
JSONAssert.assertEquals(USER_JSON_OBJECT, getGeneral(mvcResult), false);
}
use of org.springframework.security.test.context.support.WithUserDetails in project ArachneCentralAPI by OHDSI.
the class UserControllerTests method testGetUserInfo.
@Test
@WithUserDetails(value = ADMIN_EMAIL)
@DatabaseSetup("/data/user/admin-user.xml")
@ExpectedDatabase(value = "/data/user/admin-user.xml", assertionMode = NON_STRICT)
public void testGetUserInfo() throws Exception {
MvcResult mvcResult = mvc.perform(get("/api/v1/auth/me")).andExpect(NO_ERROR_CODE).andExpect(OK_STATUS).andReturn();
JSONAssert.assertEquals(ADMIN_JSON_OBJECT, getResultJSONObject(mvcResult), false);
}
use of org.springframework.security.test.context.support.WithUserDetails in project ArachneCentralAPI by OHDSI.
the class UserControllerTests method testDeletePublicationFromUser.
@Test
@WithUserDetails(value = ADMIN_EMAIL)
@DatabaseSetup("/data/user/admin-user-with-publication-for-deleting.xml")
@ExpectedDatabase(value = "/data/user/admin-user.xml", assertionMode = NON_STRICT)
public void testDeletePublicationFromUser() throws Exception {
Integer publicationId = 1;
MvcResult mvcResult = mvc.perform(delete("/api/v1/user-management/users/publications/" + publicationId)).andExpect(jsonPath("$.result.publications").isEmpty()).andReturn();
JSONAssert.assertEquals(ADMIN_JSON_OBJECT, getGeneral(mvcResult), false);
}
use of org.springframework.security.test.context.support.WithUserDetails in project ArachneCentralAPI by OHDSI.
the class UserControllerTests method testUploadAvatar.
@Test
@WithUserDetails(value = ADMIN_EMAIL)
@DatabaseSetup("/data/user/admin-user.xml")
@ExpectedDatabase(value = "/data/user/admin-user.xml", assertionMode = NON_STRICT)
public void testUploadAvatar() throws Exception {
FileInputStream fileInputStream = new FileInputStream(this.getClass().getResource("/test.jpg").getPath());
MockMultipartFile multipartFile = new MockMultipartFile("file", "test.jpg", "image/jpeg", fileInputStream);
this.mvc.perform(fileUpload("/api/v1/user-management/users/avatar").file(multipartFile).contentType(MULTIPART_FORM_DATA)).andExpect(TRUE_RESULT).andExpect(NO_ERROR_CODE).andExpect(OK_STATUS);
}
Aggregations