use of org.eclipse.che.api.user.shared.dto.UserDto in project che by eclipse.
the class UserServiceTest method shouldNotCreateUserFromEntityIfPasswordIsNotValid.
@Test
public void shouldNotCreateUserFromEntityIfPasswordIsNotValid() throws Exception {
final UserDto newUser = newDto(UserDto.class).withEmail("test@codenvy.com").withName("test").withPassword("1");
final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).when().body(newUser).contentType("application/json").post(SECURE_PATH + "/user");
assertEquals(response.statusCode(), 400);
assertEquals(unwrapError(response), "Password should contain at least 8 characters");
}
use of org.eclipse.che.api.user.shared.dto.UserDto in project che by eclipse.
the class UserServiceTest method shouldNotCreateUserFromEntityIfEmailIsNull.
@Test
public void shouldNotCreateUserFromEntityIfEmailIsNull() throws Exception {
final UserDto newUser = newDto(UserDto.class).withName("test").withPassword("password12345");
final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).when().body(newUser).contentType("application/json").post(SECURE_PATH + "/user");
assertEquals(response.statusCode(), 400);
assertEquals(unwrapError(response), "User email required");
}
use of org.eclipse.che.api.user.shared.dto.UserDto in project che by eclipse.
the class UserLinksInjectorTest method shouldInjectLinks.
@Test
public void shouldInjectLinks() throws Exception {
final UserDto userDto = DtoFactory.newDto(UserDto.class).withId("user123").withEmail("user@codenvy.com").withName("user");
linksInjector.injectLinks(userDto, serviceContext);
// [rel, method] pairs links
final Set<Pair<String, String>> links = userDto.getLinks().stream().map(link -> Pair.of(link.getMethod(), link.getRel())).collect(Collectors.toSet());
final Set<Pair<String, String>> expectedLinks = new HashSet<>(asList(Pair.of("GET", Constants.LINK_REL_SELF), Pair.of("GET", Constants.LINK_REL_CURRENT_USER), Pair.of("GET", Constants.LINK_REL_PROFILE), Pair.of("GET", Constants.LINK_REL_CURRENT_USER_SETTINGS), Pair.of("GET", Constants.LINK_REL_PREFERENCES), Pair.of("POST", Constants.LINK_REL_CURRENT_USER_PASSWORD)));
assertEquals(links, expectedLinks, "Difference " + Sets.symmetricDifference(links, expectedLinks) + "\n");
}
use of org.eclipse.che.api.user.shared.dto.UserDto in project che by eclipse.
the class UserServiceTest method shouldNotCreateUserFromEntityIfNameIsNull.
@Test
public void shouldNotCreateUserFromEntityIfNameIsNull() throws Exception {
final UserDto newUser = newDto(UserDto.class).withEmail("test@codenvy.com").withPassword("password12345");
final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).when().body(newUser).contentType("application/json").post(SECURE_PATH + "/user");
assertEquals(response.statusCode(), 400);
assertEquals(unwrapError(response), "User name required");
}
use of org.eclipse.che.api.user.shared.dto.UserDto in project che by eclipse.
the class UserServiceTest method shouldBeAbleToFindUserByEmail.
@Test
public void shouldBeAbleToFindUserByEmail() throws Exception {
final UserImpl testUser = copySubject();
when(userManager.getByEmail(testUser.getEmail())).thenReturn(testUser);
final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).when().get(SECURE_PATH + "/user/find?email=" + testUser.getEmail());
assertEquals(response.getStatusCode(), 200);
final UserDto fetchedUser = unwrapDto(response, UserDto.class);
assertEquals(fetchedUser.getId(), testUser.getId());
assertEquals(fetchedUser.getName(), testUser.getName());
assertEquals(fetchedUser.getEmail(), testUser.getEmail());
}
Aggregations