Search in sources :

Example 1 with WorkloadCredentialsUpdateType

use of com.sequenceiq.freeipa.api.v1.freeipa.user.model.WorkloadCredentialsUpdateType in project cloudbreak by hortonworks.

the class WorkloadCredentialServiceTest method setWorkloadCredentials.

private void setWorkloadCredentials(boolean batchCallEnabled, boolean updateOptimizationEnabled, FreeIpaClient ipaClient, Map<String, WorkloadCredential> usersWorkloadCredentialMap, Set<String> usersWithCredentialsToUpdate, Map<String, String> userToCrnMap, BiConsumer<String, String> warnings) throws FreeIpaClientException, TimeoutException {
    ImmutableSet<WorkloadCredentialUpdate> credentialUpdates = usersWithCredentialsToUpdate.stream().map(username -> new WorkloadCredentialUpdate(username, userToCrnMap.get(username), usersWorkloadCredentialMap.get(username))).collect(ImmutableSet.toImmutableSet());
    WorkloadCredentialsUpdateType credentialsUpdateType = updateOptimizationEnabled ? WorkloadCredentialsUpdateType.UPDATE_IF_CHANGED : WorkloadCredentialsUpdateType.FORCE_UPDATE;
    underTest.setWorkloadCredentials(new UserSyncOptions(false, batchCallEnabled, credentialsUpdateType), ipaClient, credentialUpdates, warnings);
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) ArrayListMultimap(com.google.common.collect.ArrayListMultimap) ArgumentMatchers.anyLong(org.mockito.ArgumentMatchers.anyLong) ArgumentMatchers.argThat(org.mockito.ArgumentMatchers.argThat) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) Mock(org.mockito.Mock) RPCResponse(com.sequenceiq.cloudbreak.client.RPCResponse) TimeoutException(java.util.concurrent.TimeoutException) Multimap(com.google.common.collect.Multimap) CrnTestUtil(com.sequenceiq.cloudbreak.auth.crn.CrnTestUtil) Function(java.util.function.Function) Mockito.verifyNoInteractions(org.mockito.Mockito.verifyNoInteractions) ArgumentMatcher(org.mockito.ArgumentMatcher) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) Map(java.util.Map) BiConsumer(java.util.function.BiConsumer) WorkloadCredentialsUpdateType(com.sequenceiq.freeipa.api.v1.freeipa.user.model.WorkloadCredentialsUpdateType) BatchPartitionSizeProperties(com.sequenceiq.freeipa.configuration.BatchPartitionSizeProperties) ThreadInterruptChecker(com.sequenceiq.freeipa.util.ThreadInterruptChecker) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) UserMetadataConverter(com.sequenceiq.freeipa.service.freeipa.user.conversion.UserMetadataConverter) Mockito.doReturn(org.mockito.Mockito.doReturn) InjectMocks(org.mockito.InjectMocks) MockitoExtension(org.mockito.junit.jupiter.MockitoExtension) ImmutableSet(com.google.common.collect.ImmutableSet) UserSyncOptions(com.sequenceiq.freeipa.service.freeipa.user.model.UserSyncOptions) WorkloadCredential(com.sequenceiq.freeipa.service.freeipa.user.model.WorkloadCredential) Set(java.util.Set) User(com.sequenceiq.freeipa.client.model.User) Mockito.times(org.mockito.Mockito.times) FreeIpaClientException(com.sequenceiq.freeipa.client.FreeIpaClientException) Mockito.doNothing(org.mockito.Mockito.doNothing) Mockito.when(org.mockito.Mockito.when) UUID(java.util.UUID) WorkloadCredentialUpdate(com.sequenceiq.freeipa.service.freeipa.user.model.WorkloadCredentialUpdate) FreeIpaClient(com.sequenceiq.freeipa.client.FreeIpaClient) Collectors(java.util.stream.Collectors) Mockito.verify(org.mockito.Mockito.verify) Test(org.junit.jupiter.api.Test) List(java.util.List) UserSyncTestUtils(com.sequenceiq.freeipa.service.freeipa.user.UserSyncTestUtils) JsonRpcClientException(com.googlecode.jsonrpc4j.JsonRpcClientException) Optional(java.util.Optional) UserSyncOptions(com.sequenceiq.freeipa.service.freeipa.user.model.UserSyncOptions) WorkloadCredentialsUpdateType(com.sequenceiq.freeipa.api.v1.freeipa.user.model.WorkloadCredentialsUpdateType) WorkloadCredentialUpdate(com.sequenceiq.freeipa.service.freeipa.user.model.WorkloadCredentialUpdate)

Example 2 with WorkloadCredentialsUpdateType

use of com.sequenceiq.freeipa.api.v1.freeipa.user.model.WorkloadCredentialsUpdateType in project cloudbreak by hortonworks.

the class UserSyncService method getUserSyncOptions.

private UserSyncOptions getUserSyncOptions(String accountId, boolean fullSync, WorkloadCredentialsUpdateType requestedCredentialsUpdateType) {
    WorkloadCredentialsUpdateType credentialsUpdateType = requestedCredentialsUpdateType == WorkloadCredentialsUpdateType.UPDATE_IF_CHANGED && !entitlementService.usersyncCredentialsUpdateOptimizationEnabled(accountId) ? WorkloadCredentialsUpdateType.FORCE_UPDATE : requestedCredentialsUpdateType;
    UserSyncOptions userSyncOptions = new UserSyncOptions(fullSync, entitlementService.isFmsToFreeipaBatchCallEnabled(accountId), credentialsUpdateType);
    LOGGER.info("Credentials update optimization is{} enabled for this sync request", userSyncOptions.isCredentialsUpdateOptimizationEnabled() ? "" : " not");
    return userSyncOptions;
}
Also used : UserSyncOptions(com.sequenceiq.freeipa.service.freeipa.user.model.UserSyncOptions) WorkloadCredentialsUpdateType(com.sequenceiq.freeipa.api.v1.freeipa.user.model.WorkloadCredentialsUpdateType)

Aggregations

WorkloadCredentialsUpdateType (com.sequenceiq.freeipa.api.v1.freeipa.user.model.WorkloadCredentialsUpdateType)2 UserSyncOptions (com.sequenceiq.freeipa.service.freeipa.user.model.UserSyncOptions)2 ArrayListMultimap (com.google.common.collect.ArrayListMultimap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Multimap (com.google.common.collect.Multimap)1 JsonRpcClientException (com.googlecode.jsonrpc4j.JsonRpcClientException)1 CrnTestUtil (com.sequenceiq.cloudbreak.auth.crn.CrnTestUtil)1 RPCResponse (com.sequenceiq.cloudbreak.client.RPCResponse)1 FreeIpaClient (com.sequenceiq.freeipa.client.FreeIpaClient)1 FreeIpaClientException (com.sequenceiq.freeipa.client.FreeIpaClientException)1 User (com.sequenceiq.freeipa.client.model.User)1 BatchPartitionSizeProperties (com.sequenceiq.freeipa.configuration.BatchPartitionSizeProperties)1 UserSyncTestUtils (com.sequenceiq.freeipa.service.freeipa.user.UserSyncTestUtils)1 UserMetadataConverter (com.sequenceiq.freeipa.service.freeipa.user.conversion.UserMetadataConverter)1 WorkloadCredential (com.sequenceiq.freeipa.service.freeipa.user.model.WorkloadCredential)1 WorkloadCredentialUpdate (com.sequenceiq.freeipa.service.freeipa.user.model.WorkloadCredentialUpdate)1 ThreadInterruptChecker (com.sequenceiq.freeipa.util.ThreadInterruptChecker)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1