use of com.sequenceiq.freeipa.entity.UserSyncStatus in project cloudbreak by hortonworks.
the class CooldownCheckerTest method testIsNotCool.
@Test
void testIsNotCool() {
Stack stack = UserSyncTestUtils.createStack();
UserSyncStatus userSyncStatus = UserSyncTestUtils.createUserSyncStatus(stack);
Instant cooldownExpiration = Instant.now();
long lastStartTime = cooldownExpiration.toEpochMilli() + 1L;
Operation lastRequestedOperation = new Operation();
lastRequestedOperation.setStartTime(lastStartTime);
userSyncStatus.setLastStartedFullSync(lastRequestedOperation);
assertFalse(underTest.isCooldownExpired(userSyncStatus, cooldownExpiration));
}
use of com.sequenceiq.freeipa.entity.UserSyncStatus in project cloudbreak by hortonworks.
the class CooldownCheckerTest method testIsCool.
@Test
void testIsCool() {
Stack stack = UserSyncTestUtils.createStack();
UserSyncStatus userSyncStatus = UserSyncTestUtils.createUserSyncStatus(stack);
Instant cooldownExpiration = Instant.now();
long lastStartTime = cooldownExpiration.toEpochMilli() - 1L;
Operation lastRequestedOperation = new Operation();
lastRequestedOperation.setStartTime(lastStartTime);
userSyncStatus.setLastStartedFullSync(lastRequestedOperation);
assertTrue(underTest.isCooldownExpired(userSyncStatus, cooldownExpiration));
}
use of com.sequenceiq.freeipa.entity.UserSyncStatus in project cloudbreak by hortonworks.
the class CooldownCheckerTest method testNoStartTimeIsCool.
@Test
void testNoStartTimeIsCool() {
Stack stack = UserSyncTestUtils.createStack();
UserSyncStatus userSyncStatus = UserSyncTestUtils.createUserSyncStatus(stack);
Instant cooldownExpiration = Instant.now();
assertTrue(underTest.isCooldownExpired(userSyncStatus, cooldownExpiration));
}
use of com.sequenceiq.freeipa.entity.UserSyncStatus in project cloudbreak by hortonworks.
the class UserSyncPollerTest method testSyncStackWhenCool.
@Test
void testSyncStackWhenCool() {
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(true);
underTest.syncAllFreeIpaStacks();
verify(userSyncService).synchronizeUsers(UserSyncTestUtils.ACCOUNT_ID, "crn:altus:iam:us-west-1:altus:user:__internal__actor__", Set.of(UserSyncTestUtils.ENVIRONMENT_CRN), Set.of(), Set.of(), WorkloadCredentialsUpdateType.UPDATE_IF_CHANGED);
}
use of com.sequenceiq.freeipa.entity.UserSyncStatus in project cloudbreak by hortonworks.
the class UserSyncPollerTest method setupMocks.
private UserSyncStatus setupMocks() {
Stack stack = UserSyncTestUtils.createStack();
setupMockStackService(stack);
when(userSyncPollerEntitlementChecker.isAccountEntitled(anyString())).thenReturn(true);
UserSyncStatus userSyncStatus = UserSyncTestUtils.createUserSyncStatus(stack);
when(userSyncStatusService.getOrCreateForStack(userSyncStatus.getStack())).thenReturn(userSyncStatus);
when(umsEventGenerationIdsProvider.getEventGenerationIds(any(), any())).thenReturn(UserSyncTestUtils.createUniqueUmsEventGenerationIds());
return userSyncStatus;
}
Aggregations