use of com.synopsys.integration.alert.common.persistence.model.UserModel in project hub-alert by blackducksoftware.
the class UserAccessorTestIT method testChangeUserEmailAddress.
@Test
public void testChangeUserEmailAddress() throws AlertForbiddenOperationException, AlertConfigurationException {
String userName = "testUser";
String password = "testPassword";
String email = "testEmail";
UserModel userModel = userAccessor.addUser(userName, password, email);
assertNotNull(userModel);
assertEquals(userName, userModel.getName());
assertEquals(email, userModel.getEmailAddress());
assertTrue(userModel.getRoles().isEmpty());
assertTrue(userAccessor.changeUserEmailAddress(userModel.getName(), "new_test_email"));
Optional<UserModel> foundModel = userAccessor.getUser(userName);
assertTrue(foundModel.isPresent());
UserModel updatedModel = foundModel.get();
assertEquals(userModel.getName(), updatedModel.getName());
assertNotEquals(userModel.getEmailAddress(), updatedModel.getEmailAddress());
userAccessor.deleteUser(userName);
assertFalse(userAccessor.changeUserEmailAddress("bad_user_name", "new_test_email"));
}
use of com.synopsys.integration.alert.common.persistence.model.UserModel in project hub-alert by blackducksoftware.
the class UserAccessorTestIT method testExternalUserUpdateRoles.
@Test
public void testExternalUserUpdateRoles() throws AlertForbiddenOperationException, AlertConfigurationException {
String userName = "testUser";
String password = "testPassword";
String email = "testEmail";
UserModel userModel = UserModel.newUser(userName, password, email, AuthenticationType.LDAP, Collections.emptySet(), true);
userModel = userAccessor.addUser(userModel, false);
UserRoleModel userRole = UserRoleModel.of(DefaultUserRole.ALERT_ADMIN.name());
Set<UserRoleModel> roles = Set.of(userRole);
UserModel existingUser = UserModel.existingUser(userModel.getId(), userName, null, email, AuthenticationType.LDAP, roles, true);
UserModel updatedUser = userAccessor.updateUser(existingUser, true);
assertEquals(roles.stream().map(UserRoleModel::getName).collect(Collectors.toSet()), updatedUser.getRoles().stream().map(UserRoleModel::getName).collect(Collectors.toSet()));
userAccessor.deleteUser(userName);
}
use of com.synopsys.integration.alert.common.persistence.model.UserModel in project hub-alert by blackducksoftware.
the class UserAccessorTestIT method testExternalUserUpdateNameException.
@Test
public void testExternalUserUpdateNameException() throws AlertForbiddenOperationException, AlertConfigurationException {
String userName = "testUser";
String password = "testPassword";
String email = "testEmail";
UserModel userModel = UserModel.newUser(userName, password, email, AuthenticationType.LDAP, Collections.emptySet(), true);
userModel = userAccessor.addUser(userModel, false);
UserModel updatedUser = UserModel.existingUser(userModel.getId(), userName + "_updated", null, email, AuthenticationType.LDAP, Collections.emptySet(), true);
testUserUpdateException(updatedUser);
userAccessor.deleteUser(userName);
}
use of com.synopsys.integration.alert.common.persistence.model.UserModel in project hub-alert by blackducksoftware.
the class UserAccessorTestIT method testAddUser.
@Test
public void testAddUser() throws AlertForbiddenOperationException, AlertConfigurationException {
String userName = "testUser";
String password = "testPassword";
String email = "testEmail";
UserModel userModel = userAccessor.addUser(userName, password, email);
assertNotNull(userModel);
assertEquals(userName, userModel.getName());
assertEquals(email, userModel.getEmailAddress());
assertTrue(userModel.getRoles().isEmpty());
userAccessor.deleteUser(userName);
}
use of com.synopsys.integration.alert.common.persistence.model.UserModel in project hub-alert by blackducksoftware.
the class UserAccessorTestIT method testExternalUserUpdatePasswordException.
@Test
public void testExternalUserUpdatePasswordException() throws AlertForbiddenOperationException, AlertConfigurationException {
String userName = "testUser";
String password = "testPassword";
String email = "testEmail";
UserModel userModel = UserModel.newUser(userName, password, email, AuthenticationType.LDAP, Collections.emptySet(), true);
userModel = userAccessor.addUser(userModel, false);
UserModel updatedUser = UserModel.existingUser(userModel.getId(), userName, password, email, AuthenticationType.LDAP, Collections.emptySet(), true);
testUserUpdateException(updatedUser);
userAccessor.deleteUser(userName);
}
Aggregations