use of org.eclipse.che.api.user.server.model.impl.UserImpl in project che by eclipse.
the class UserServiceTest method shouldCreateUserFromToken.
@Test
public void shouldCreateUserFromToken() throws Exception {
when(tokenValidator.validateToken("token_value")).thenReturn(new UserImpl("id", "test@eclipse.org", "test"));
final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).when().contentType("application/json").post(SECURE_PATH + "/user?token=token_value");
assertEquals(response.statusCode(), 201);
verify(userManager).create(userCaptor.capture(), anyBoolean());
final User user = userCaptor.getValue();
assertEquals(user.getEmail(), "test@eclipse.org");
assertEquals(user.getName(), "test");
}
use of org.eclipse.che.api.user.server.model.impl.UserImpl in project che by eclipse.
the class UserServiceTest method shouldNotUpdatePasswordIfPasswordIsNull.
@Test
public void shouldNotUpdatePasswordIfPasswordIsNull() 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").when().post(SECURE_PATH + "/user/password");
assertEquals(response.getStatusCode(), 400);
assertEquals(unwrapError(response), "Password required");
}
use of org.eclipse.che.api.user.server.model.impl.UserImpl in project che by eclipse.
the class JpaTckModule method configure.
@Override
protected void configure() {
H2DBTestServer server = H2DBTestServer.startDefault();
install(new PersistTestModuleBuilder().setDriver(Driver.class).runningOn(server).addEntityClasses(UserImpl.class, ProfileImpl.class, PreferenceEntity.class, AccountImpl.class).setExceptionHandler(H2ExceptionHandler.class).build());
bind(DBInitializer.class).asEagerSingleton();
bind(SchemaInitializer.class).toInstance(new FlywaySchemaInitializer(server.getDataSource(), "che-schema"));
bind(TckResourcesCleaner.class).toInstance(new H2JpaCleaner(server.getDataSource()));
bind(new TypeLiteral<TckRepository<UserImpl>>() {
}).to(UserJpaTckRepository.class);
bind(new TypeLiteral<TckRepository<ProfileImpl>>() {
}).toInstance(new JpaTckRepository<>(ProfileImpl.class));
bind(new TypeLiteral<TckRepository<Pair<String, Map<String, String>>>>() {
}).to(PreferenceJpaTckRepository.class);
bind(UserDao.class).to(JpaUserDao.class);
bind(ProfileDao.class).to(JpaProfileDao.class);
bind(PreferenceDao.class).to(JpaPreferenceDao.class);
// SHA-512 encryptor is faster than PBKDF2 so it is better for testing
bind(PasswordEncryptor.class).to(SHA512PasswordEncryptor.class).in(Singleton.class);
}
use of org.eclipse.che.api.user.server.model.impl.UserImpl in project che by eclipse.
the class UserJpaTckRepository method createAll.
@Override
public void createAll(Collection<? extends UserImpl> entities) throws TckRepositoryException {
final EntityManager manager = managerProvider.get();
entities.stream().map(user -> new UserImpl(user.getId(), user.getEmail(), user.getName(), encryptor.encrypt(user.getPassword()), user.getAliases())).forEach(manager::persist);
}
use of org.eclipse.che.api.user.server.model.impl.UserImpl in project che by eclipse.
the class ProfileDaoTest method setUp.
@BeforeMethod
private void setUp() throws TckRepositoryException {
UserImpl[] users = new UserImpl[COUNT_OF_PROFILES];
profiles = new ProfileImpl[COUNT_OF_PROFILES];
for (int i = 0; i < COUNT_OF_PROFILES; i++) {
final String userId = NameGenerator.generate("user", Constants.ID_LENGTH);
users[i] = new UserImpl(userId, userId + "@eclipse.org", userId, "password", emptyList());
final Map<String, String> attributes = new HashMap<>();
attributes.put("firstName", "first-name-" + i);
attributes.put("lastName", "last-name-" + i);
attributes.put("company", "company-" + i);
profiles[i] = new ProfileImpl(userId, attributes);
}
userTckRepository.createAll(Arrays.asList(users));
profileTckRepository.createAll(Arrays.asList(profiles));
}
Aggregations