Search in sources :

Example 31 with UserSyncStatus

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));
}
Also used : Instant(java.time.Instant) UserSyncStatus(com.sequenceiq.freeipa.entity.UserSyncStatus) Operation(com.sequenceiq.freeipa.entity.Operation) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Example 32 with UserSyncStatus

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));
}
Also used : Instant(java.time.Instant) UserSyncStatus(com.sequenceiq.freeipa.entity.UserSyncStatus) Operation(com.sequenceiq.freeipa.entity.Operation) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Example 33 with UserSyncStatus

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));
}
Also used : Instant(java.time.Instant) UserSyncStatus(com.sequenceiq.freeipa.entity.UserSyncStatus) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Example 34 with UserSyncStatus

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);
}
Also used : UserSyncStatus(com.sequenceiq.freeipa.entity.UserSyncStatus) Test(org.junit.jupiter.api.Test)

Example 35 with UserSyncStatus

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;
}
Also used : UserSyncStatus(com.sequenceiq.freeipa.entity.UserSyncStatus) Stack(com.sequenceiq.freeipa.entity.Stack)

Aggregations

UserSyncStatus (com.sequenceiq.freeipa.entity.UserSyncStatus)41 Test (org.junit.jupiter.api.Test)30 Stack (com.sequenceiq.freeipa.entity.Stack)18 Operation (com.sequenceiq.freeipa.entity.Operation)17 UmsEventGenerationIds (com.sequenceiq.freeipa.service.freeipa.user.model.UmsEventGenerationIds)10 Json (com.sequenceiq.cloudbreak.common.json.Json)8 EnvironmentUserSyncState (com.sequenceiq.freeipa.api.v1.freeipa.user.model.EnvironmentUserSyncState)7 UserSyncOptions (com.sequenceiq.freeipa.service.freeipa.user.model.UserSyncOptions)6 OperationType (com.sequenceiq.freeipa.api.v1.operation.model.OperationType)5 SuccessDetails (com.sequenceiq.freeipa.api.v1.freeipa.user.model.SuccessDetails)4 SyncStatusDetail (com.sequenceiq.freeipa.service.freeipa.user.model.SyncStatusDetail)4 Instant (java.time.Instant)4 FreeIpa (com.sequenceiq.freeipa.entity.FreeIpa)3 ImageEntity (com.sequenceiq.freeipa.entity.ImageEntity)3 DescribeFreeIpaResponse (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse)2 UserSyncStatusResponse (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.usersync.UserSyncStatusResponse)2 UmsUsersState (com.sequenceiq.freeipa.service.freeipa.user.model.UmsUsersState)2 Collection (java.util.Collection)2 Optional (java.util.Optional)2 Callable (java.util.concurrent.Callable)2