use of org.eclipse.che.api.user.server.model.impl.UserImpl in project che by eclipse.
the class UserManagerTest method shouldGetAllUsers.
@Test
public void shouldGetAllUsers() throws Exception {
final Page users = new Page(Arrays.asList(new UserImpl("identifier1", "test1@email.com", "testName1", "password", Collections.singletonList("alias1")), new UserImpl("identifier2", "test2@email.com", "testName2", "password", Collections.singletonList("alias2")), new UserImpl("identifier3", "test3@email.com", "testName3", "password", Collections.singletonList("alias3"))), 0, 30, 3);
when(userDao.getAll(30, 0)).thenReturn(users);
assertEquals(manager.getAll(30, 0), users);
verify(userDao).getAll(30, 0);
}
use of org.eclipse.che.api.user.server.model.impl.UserImpl in project che by eclipse.
the class UserManagerTest method shouldTryToRollbackWhenEntityCreationFailed.
@Test(dataProvider = "rollback")
public void shouldTryToRollbackWhenEntityCreationFailed(Callable preAction) throws Exception {
preAction.call();
// Creating new user
try {
manager.create(new UserImpl(null, "test@email.com", "testName", null, null), false);
fail("Had to throw Exception");
} catch (Exception x) {
// defined by userDao mock
}
// Capturing identifier
final ArgumentCaptor<UserImpl> captor = ArgumentCaptor.forClass(UserImpl.class);
verify(userDao).create(captor.capture());
final String userId = captor.getValue().getId();
// Verifying rollback
verify(userDao).remove(userId);
verify(preferencesDao).remove(userId);
verify(profileDao).remove(userId);
}
use of org.eclipse.che.api.user.server.model.impl.UserImpl in project che by eclipse.
the class UserManagerTest method shouldGetUserByEmail.
@Test
public void shouldGetUserByEmail() throws Exception {
final User user = new UserImpl("identifier", "test@email.com", "testName", "password", Collections.singletonList("alias"));
when(manager.getByEmail(user.getEmail())).thenReturn(user);
assertEquals(manager.getByEmail(user.getEmail()), user);
}
use of org.eclipse.che.api.user.server.model.impl.UserImpl in project che by eclipse.
the class UserServiceTest method shouldUpdatePassword.
@Test
public void shouldUpdatePassword() throws Exception {
final UserImpl testUser = copySubject();
when(userManager.getById(testUser.getId())).thenReturn(testUser);
final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).contentType("application/x-www-form-urlencoded").body("password=password12345").when().post(SECURE_PATH + "/user/password");
verify(userManager).update(userCaptor.capture());
final User fetchedUser = userCaptor.getValue();
assertEquals(fetchedUser.getPassword(), "password12345");
}
use of org.eclipse.che.api.user.server.model.impl.UserImpl in project che by eclipse.
the class UserServiceTest method shouldNotUpdatePasswordIfPasswordContainsLessThan8Chars.
@Test
public void shouldNotUpdatePasswordIfPasswordContainsLessThan8Chars() throws Exception {
final UserImpl testUser = copySubject();
when(userManager.getById(testUser.getId())).thenReturn(testUser);
final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).contentType("application/x-www-form-urlencoded").body("password=0xf").when().post(SECURE_PATH + "/user/password");
assertEquals(response.getStatusCode(), 400);
assertEquals(unwrapError(response), "Password should contain at least 8 characters");
}
Aggregations