use of com.sequenceiq.freeipa.service.freeipa.user.model.FmsUser in project cloudbreak by hortonworks.
the class UsersStateDifferenceCalculatorTest method testCalculateUsersToRemove.
@Test
void testCalculateUsersToRemove() {
FmsUser userUms = new FmsUser().withName("userUms");
FmsUser userBoth = new FmsUser().withName("userBoth");
FmsUser userIPA = new FmsUser().withName("userIPA");
FmsUser userIPA2 = new FmsUser().withName("userIPA2");
FmsUser userProtected = new FmsUser().withName(FreeIpaChecks.IPA_PROTECTED_USERS.get(0));
UmsUsersState umsUsersState = new UmsUsersState.Builder().setUsersState(new UsersState.Builder().addUser(userUms).addMemberToGroup(UserSyncConstants.CDP_USERSYNC_INTERNAL_GROUP, userUms.getName()).addUser(userBoth).addMemberToGroup(UserSyncConstants.CDP_USERSYNC_INTERNAL_GROUP, userBoth.getName()).build()).build();
UsersState ipaUsersState = new UsersState.Builder().addUser(userBoth).addMemberToGroup(UserSyncConstants.CDP_USERSYNC_INTERNAL_GROUP, userBoth.getName()).addUser(userIPA).addMemberToGroup(UserSyncConstants.CDP_USERSYNC_INTERNAL_GROUP, userIPA.getName()).addUser(userIPA2).addUser(userProtected).addMemberToGroup(UserSyncConstants.CDP_USERSYNC_INTERNAL_GROUP, userProtected.getName()).build();
ImmutableSet<String> usersToRemove = new UserStateDifferenceCalculator().calculateUsersToRemove(umsUsersState, ipaUsersState);
// the users that exists only in IPA that are members of the CDP_USERSYNC_INTERNAL_GROUP will be removed
assertTrue(usersToRemove.contains(userIPA.getName()));
// protected users will be ignored
assertFalse(usersToRemove.contains(userProtected.getName()));
// users that exist only in ums, exist in both ums and ipa, or are not members of CDP_USERSYNC_INTERNAL_GROUP will not be removed
assertFalse(usersToRemove.contains(userUms.getName()));
assertFalse(usersToRemove.contains(userBoth.getName()));
assertFalse(usersToRemove.contains(userIPA2.getName()));
}
use of com.sequenceiq.freeipa.service.freeipa.user.model.FmsUser in project cloudbreak by hortonworks.
the class UsersStateDifferenceCalculatorTest method testCalculateUsersToAdd.
@Test
void testCalculateUsersToAdd() {
FmsUser userUms = new FmsUser().withName("userUms");
FmsUser userDisabledUms = new FmsUser().withName("userDisabledUms").withState(FmsUser.State.DISABLED);
FmsUser userProtected = new FmsUser().withName(FreeIpaChecks.IPA_PROTECTED_USERS.get(0));
FmsUser userBothUms = new FmsUser().withName("userBoth");
FmsUser userBothIpa = new FmsUser().withName("userBoth");
FmsUser userIpa = new FmsUser().withName("userIPA");
FmsUser userSameStateUms = new FmsUser().withName("userSameState").withState(FmsUser.State.DISABLED);
FmsUser userSameStateIpa = new FmsUser().withName("userSameState").withState(FmsUser.State.DISABLED);
FmsUser userDifferentStateUms = new FmsUser().withName("userDifferentState").withState(FmsUser.State.ENABLED);
FmsUser userDifferentStateIpa = new FmsUser().withName("userDifferentState").withState(FmsUser.State.DISABLED);
UmsUsersState umsUsersState = new UmsUsersState.Builder().setUsersState(new UsersState.Builder().addUser(userUms).addUser(userDisabledUms).addUser(userProtected).addUser(userBothUms).addUser(userSameStateUms).addUser(userDifferentStateUms).build()).build();
UsersState ipaUsersState = new UsersState.Builder().addUser(userBothIpa).addUser(userIpa).addUser(userSameStateIpa).addUser(userDifferentStateIpa).build();
ImmutableSet<FmsUser> usersToAdd = new UserStateDifferenceCalculator().calculateUsersToAdd(umsUsersState, ipaUsersState);
// the user that exists only in the UMS will be added
assertTrue(usersToAdd.contains(userUms));
assertTrue(usersToAdd.contains(userDisabledUms));
// protected users will be ignored
assertFalse(usersToAdd.contains(userProtected));
// users that exist in both or only in ipa will not be added
assertFalse(usersToAdd.contains(userBothUms));
assertFalse(usersToAdd.contains(userIpa));
assertFalse(usersToAdd.contains(userSameStateUms));
assertFalse(usersToAdd.contains(userDifferentStateUms));
}
use of com.sequenceiq.freeipa.service.freeipa.user.model.FmsUser in project cloudbreak by hortonworks.
the class FmsUserConverterTest method testUserToFmsUserMissingNames.
@Test
public void testUserToFmsUserMissingNames() {
String workloadUsername = "foobar";
UserManagementProto.User umsUser = UserManagementProto.User.newBuilder().setWorkloadUsername(workloadUsername).setState(UserManagementProto.ActorState.Value.ACTIVE).build();
FmsUser fmsUser = underTest.toFmsUser(umsUser);
assertEquals(workloadUsername, fmsUser.getName());
assertEquals(underTest.NONE_STRING, fmsUser.getFirstName());
assertEquals(underTest.NONE_STRING, fmsUser.getLastName());
assertEquals(FmsUser.State.ENABLED, fmsUser.getState());
}
use of com.sequenceiq.freeipa.service.freeipa.user.model.FmsUser in project cloudbreak by hortonworks.
the class FmsUserConverterTest method testUserSyncActorDetailsToFmsUserUnrecognizedState.
@Test
public void testUserSyncActorDetailsToFmsUserUnrecognizedState() {
String workloadUsername = "foobar";
UserManagementProto.UserSyncActorDetails actorDetails = UserManagementProto.UserSyncActorDetails.newBuilder().setWorkloadUsername(workloadUsername).setStateValue(UNRECOGNIZED_STATE_VALUE).build();
FmsUser fmsUser = underTest.toFmsUser(actorDetails);
assertEquals(workloadUsername, fmsUser.getName());
assertEquals(underTest.NONE_STRING, fmsUser.getFirstName());
assertEquals(underTest.NONE_STRING, fmsUser.getLastName());
assertEquals(FmsUser.State.ENABLED, fmsUser.getState());
}
use of com.sequenceiq.freeipa.service.freeipa.user.model.FmsUser in project cloudbreak by hortonworks.
the class FmsUserConverterTest method testUserToFmsUserMissingState.
@Test
public void testUserToFmsUserMissingState() {
String workloadUsername = "foobar";
UserManagementProto.User umsUser = UserManagementProto.User.newBuilder().setWorkloadUsername(workloadUsername).build();
FmsUser fmsUser = underTest.toFmsUser(umsUser);
assertEquals(workloadUsername, fmsUser.getName());
assertEquals(underTest.NONE_STRING, fmsUser.getFirstName());
assertEquals(underTest.NONE_STRING, fmsUser.getLastName());
assertEquals(FmsUser.State.ENABLED, fmsUser.getState());
}
Aggregations