use of com.sequenceiq.freeipa.entity.UserSyncStatus in project cloudbreak by hortonworks.
the class UserSyncPollerTest method testDontSyncStackWhenNotCool.
@Test
void testDontSyncStackWhenNotCool() {
UserSyncStatus userSyncStatus = setupMocks();
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn:altus:iam:us-west-1:altus:user:__internal__actor__");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
when(eventGenerationIdsChecker.isInSync(eq(userSyncStatus), any())).thenReturn(false);
when(cooldownChecker.isCooldownExpired(eq(userSyncStatus), any())).thenReturn(false);
underTest.syncAllFreeIpaStacks();
verify(userSyncService, times(0)).synchronizeUsers(any(), any(), any(), any(), any(), any());
}
use of com.sequenceiq.freeipa.entity.UserSyncStatus in project cloudbreak by hortonworks.
the class UserSyncStatusToUserSyncStatusResponseConverterTest method convert.
@Test
void convert() {
String requestedId = UUID.randomUUID().toString();
Operation requested = new Operation();
requested.setOperationId(requestedId);
String successfulId = UUID.randomUUID().toString();
Operation successful = new Operation();
successful.setOperationId(successfulId);
Map<String, String> eventGenerationIdMap = Map.of("key1", "value1", "key2", "value2");
UmsEventGenerationIds eventGenerationIds = new UmsEventGenerationIds();
eventGenerationIds.setEventGenerationIds(eventGenerationIdMap);
UserSyncStatus status = new UserSyncStatus();
status.setLastStartedFullSync(requested);
status.setLastSuccessfulFullSync(successful);
status.setUmsEventGenerationIds(new Json(eventGenerationIds));
UserSyncStatusResponse response = underTest.convert(status);
assertThat(response).returns(requestedId, UserSyncStatusResponse::getLastStartedUserSyncId).returns(successfulId, UserSyncStatusResponse::getLastSuccessfulUserSyncId).returns(eventGenerationIdMap, UserSyncStatusResponse::getEventGenerationIds);
}
use of com.sequenceiq.freeipa.entity.UserSyncStatus in project cloudbreak by hortonworks.
the class UserSyncService method updateUserSyncStatusForStack.
private void updateUserSyncStatusForStack(Operation operation, Stack stack) {
UserSyncStatus userSyncStatus = userSyncStatusService.getOrCreateForStack(stack);
userSyncStatus.setLastStartedFullSync(operation);
userSyncStatusService.save(userSyncStatus);
}
use of com.sequenceiq.freeipa.entity.UserSyncStatus in project cloudbreak by hortonworks.
the class UserSyncStatusService method createNewUserSyncStatusForStack.
private UserSyncStatus createNewUserSyncStatusForStack(Stack stack) {
UserSyncStatus userSyncStatus = new UserSyncStatus();
userSyncStatus.setStack(stack);
userSyncStatus.setUmsEventGenerationIds(new Json(new UmsEventGenerationIds()));
return userSyncStatusRepository.save(userSyncStatus);
}
use of com.sequenceiq.freeipa.entity.UserSyncStatus in project cloudbreak by hortonworks.
the class UserSyncForEnvService method asyncSynchronizeStack.
private Future<SyncStatusDetail> asyncSynchronizeStack(Stack stack, UmsUsersState umsUsersState, UmsEventGenerationIds umsEventGenerationIds, UserSyncOptions options, String operationId, String accountId) {
return asyncTaskExecutor.submit(() -> {
SyncStatusDetail statusDetail = userSyncForStackService.synchronizeStack(stack, umsUsersState, options);
if (options.isFullSync() && statusDetail.getStatus() == SynchronizationStatus.COMPLETED) {
UserSyncStatus userSyncStatus = userSyncStatusService.getOrCreateForStack(stack);
userSyncStatus.setUmsEventGenerationIds(new Json(umsEventGenerationIds));
userSyncStatus.setLastSuccessfulFullSync(operationService.getOperationForAccountIdAndOperationId(accountId, operationId));
userSyncStatusService.save(userSyncStatus);
}
return statusDetail;
});
}
Aggregations