use of com.sequenceiq.freeipa.service.freeipa.user.model.SyncStatusDetail in project cloudbreak by hortonworks.
the class UserSyncForStackServiceTest method testSynchronizeFailsToSetupSudoRules.
@Test
public void testSynchronizeFailsToSetupSudoRules() throws Exception {
UmsUsersState umsUsersState = mock(UmsUsersState.class);
UserSyncOptions options = new UserSyncOptions(true, false, WorkloadCredentialsUpdateType.FORCE_UPDATE);
UsersState usersState = mock(UsersState.class);
when(usersState.getUsers()).thenReturn(ImmutableSet.of());
when(usersState.getGroups()).thenReturn(ImmutableSet.of());
when(freeIpaUsersStateProvider.getUsersState(FREE_IPA_CLIENT)).thenReturn(usersState);
UsersStateDifference usersStateDifference = mock(UsersStateDifference.class);
when(userStateDifferenceCalculator.fromUmsAndIpaUsersStates(umsUsersState, usersState, options)).thenReturn(usersStateDifference);
when(entitlementService.cloudIdentityMappingEnabled(ACCOUNT)).thenReturn(TRUE);
when(entitlementService.isEnvironmentPrivilegedUserEnabled(ACCOUNT)).thenReturn(TRUE);
doThrow(new Exception(ERROR_MESSAGE)).when(sudoRuleService).setupSudoRule(STACK, FREE_IPA_CLIENT);
SyncStatusDetail result = underTest.synchronizeStack(STACK, umsUsersState, options);
verify(freeIpaUsersStateProvider, never()).getFilteredFreeIpaState(any(), any());
verify(stateApplier).applyDifference(eq(umsUsersState), eq(ENV_CRN), any(), eq(usersStateDifference), eq(options), eq(FREE_IPA_CLIENT));
verifyNoMoreInteractions(stateApplier);
verify(cloudIdentitySyncService).syncCloudIdentities(eq(STACK), eq(umsUsersState), any());
assertEquals(ENV_CRN, result.getEnvironmentCrn());
assertEquals(FAILED, result.getStatus());
assertTrue(result.getWarnings().get(ENV_CRN).contains(ERROR_MESSAGE));
}
use of com.sequenceiq.freeipa.service.freeipa.user.model.SyncStatusDetail in project cloudbreak by hortonworks.
the class UserSyncForStackServiceTest method testSynchronizeStackForDeleteUserEmpty.
@Test
public void testSynchronizeStackForDeleteUserEmpty() throws FreeIpaClientException {
UsersState usersState = mock(UsersState.class);
when(usersState.getUsers()).thenReturn(ImmutableSet.of());
when(usersState.getGroups()).thenReturn(ImmutableSet.of());
when(freeIpaUsersStateProvider.getFilteredFreeIpaState(FREE_IPA_CLIENT, Set.of("deleteMe"))).thenReturn(usersState);
SyncStatusDetail result = underTest.synchronizeStackForDeleteUser(STACK, "deleteMe");
verifyNoInteractions(stateApplier);
assertEquals(ENV_CRN, result.getEnvironmentCrn());
assertEquals(COMPLETED, result.getStatus());
assertTrue(result.getWarnings().isEmpty());
}
use of com.sequenceiq.freeipa.service.freeipa.user.model.SyncStatusDetail in project cloudbreak by hortonworks.
the class UserSyncForStackServiceTest method testSynchronizeStackForDeleteUserFailure.
@Test
public void testSynchronizeStackForDeleteUserFailure() throws FreeIpaClientException {
when(freeIpaClientFactory.getFreeIpaClientForStack(STACK)).thenThrow(new FreeIpaClientException("totty"));
SyncStatusDetail result = underTest.synchronizeStackForDeleteUser(STACK, "deleteMe");
verifyNoInteractions(stateApplier);
assertEquals(ENV_CRN, result.getEnvironmentCrn());
assertEquals(FAILED, result.getStatus());
assertTrue(result.getWarnings().isEmpty());
}
use of com.sequenceiq.freeipa.service.freeipa.user.model.SyncStatusDetail in project cloudbreak by hortonworks.
the class UserSyncForStackServiceTest method testSynchronizeStackFailsPartial.
@Test
public void testSynchronizeStackFailsPartial() throws FreeIpaClientException, TimeoutException {
UmsUsersState umsUsersState = mock(UmsUsersState.class);
when(umsUsersState.getRequestedWorkloadUsernames()).thenReturn(ImmutableSet.of("user1", "user2"));
UserSyncOptions options = new UserSyncOptions(false, false, WorkloadCredentialsUpdateType.FORCE_UPDATE);
UsersState usersState = mock(UsersState.class);
when(usersState.getUsers()).thenReturn(ImmutableSet.of());
when(usersState.getGroups()).thenReturn(ImmutableSet.of());
when(freeIpaUsersStateProvider.getFilteredFreeIpaState(FREE_IPA_CLIENT, Set.of("user1", "user2"))).thenReturn(usersState);
UsersStateDifference usersStateDifference = mock(UsersStateDifference.class);
when(userStateDifferenceCalculator.fromUmsAndIpaUsersStates(umsUsersState, usersState, options)).thenReturn(usersStateDifference);
doAnswer(invocation -> {
Multimap<String, String> warnings = invocation.getArgument(2, Multimap.class);
warnings.put(ENV_CRN, "failed");
return null;
}).when(stateApplier).applyDifference(eq(umsUsersState), eq(ENV_CRN), any(), eq(usersStateDifference), eq(options), eq(FREE_IPA_CLIENT));
SyncStatusDetail result = underTest.synchronizeStack(STACK, umsUsersState, options);
verify(freeIpaUsersStateProvider, never()).getUsersState(any());
verify(stateApplier).applyDifference(eq(umsUsersState), eq(ENV_CRN), any(), eq(usersStateDifference), eq(options), eq(FREE_IPA_CLIENT));
verifyNoMoreInteractions(stateApplier);
verifyNoInteractions(cloudIdentitySyncService);
verifyNoInteractions(sudoRuleService);
assertEquals(ENV_CRN, result.getEnvironmentCrn());
assertEquals(FAILED, result.getStatus());
assertFalse(result.getWarnings().isEmpty());
}
use of com.sequenceiq.freeipa.service.freeipa.user.model.SyncStatusDetail in project cloudbreak by hortonworks.
the class UserSyncForStackServiceTest method testSynchronizeStackFailsToGetClient.
@Test
public void testSynchronizeStackFailsToGetClient() throws FreeIpaClientException {
UmsUsersState umsUsersState = mock(UmsUsersState.class);
UserSyncOptions options = new UserSyncOptions(false, false, WorkloadCredentialsUpdateType.FORCE_UPDATE);
when(freeIpaClientFactory.getFreeIpaClientForStack(STACK)).thenThrow(new FreeIpaClientException("potty"));
SyncStatusDetail result = underTest.synchronizeStack(STACK, umsUsersState, options);
assertEquals(ENV_CRN, result.getEnvironmentCrn());
assertEquals(FAILED, result.getStatus());
assertTrue(result.getWarnings().isEmpty());
}
Aggregations