Search in sources :

Example 1 with Config

use of com.sequenceiq.freeipa.client.model.Config in project cloudbreak by hortonworks.

the class UserSyncStateApplierTest method testApplyDifferenceWithPasswordHashSupport.

@Test
public void testApplyDifferenceWithPasswordHashSupport() throws FreeIpaClientException, TimeoutException {
    UsersState usersState = UsersState.newBuilder().addUserMetadata("userToUpdate1", new UserMetadata("userToUpdate1Crn", 1L)).addUserMetadata("userToUpdate2", new UserMetadata("userToUpdate2Crn", 2L)).build();
    WorkloadCredential workloadCredential1 = mock(WorkloadCredential.class);
    WorkloadCredential workloadCredential2 = mock(WorkloadCredential.class);
    UmsUsersState umsUsersState = UmsUsersState.newBuilder().setUsersState(usersState).addWorkloadCredentials("userToUpdate1", workloadCredential1).addWorkloadCredentials("userToUpdate2", workloadCredential2).build();
    UserSyncOptions userSyncOptions = mock(UserSyncOptions.class);
    UsersStateDifference usersStateDifference = createStateDiff();
    Multimap<String, String> warnings = ArrayListMultimap.create();
    when(userSyncOptions.isFmsToFreeIpaBatchCallEnabled()).thenReturn(Boolean.TRUE);
    Config config = new Config();
    config.setIpauserobjectclasses(Set.of("cdpUserAttr"));
    when(freeIpaClient.getConfig()).thenReturn(config);
    underTest.applyDifference(umsUsersState, ENV_CRN, warnings, usersStateDifference, userSyncOptions, freeIpaClient);
    ArgumentCaptor<Set<WorkloadCredentialUpdate>> credentialUpdateCaptor = ArgumentCaptor.forClass(Set.class);
    verify(workloadCredentialService).setWorkloadCredentials(eq(userSyncOptions), eq(freeIpaClient), credentialUpdateCaptor.capture(), any());
    Set<WorkloadCredentialUpdate> workloadCredentialUpdates = credentialUpdateCaptor.getValue();
    assertThat(workloadCredentialUpdates, allOf(hasItem(allOf(hasProperty("username", is("userToUpdate1")), hasProperty("userCrn", is("userToUpdate1Crn")), hasProperty("workloadCredential", is(workloadCredential1)))), hasItem(allOf(hasProperty("username", is("userToUpdate2")), hasProperty("userCrn", is("userToUpdate2Crn")), hasProperty("workloadCredential", is(workloadCredential2))))));
}
Also used : ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) Config(com.sequenceiq.freeipa.client.model.Config) UmsUsersState(com.sequenceiq.freeipa.service.freeipa.user.model.UmsUsersState) UserMetadata(com.sequenceiq.freeipa.service.freeipa.user.model.UserMetadata) UsersState(com.sequenceiq.freeipa.service.freeipa.user.model.UsersState) UmsUsersState(com.sequenceiq.freeipa.service.freeipa.user.model.UmsUsersState) WorkloadCredential(com.sequenceiq.freeipa.service.freeipa.user.model.WorkloadCredential) UserSyncOptions(com.sequenceiq.freeipa.service.freeipa.user.model.UserSyncOptions) WorkloadCredentialUpdate(com.sequenceiq.freeipa.service.freeipa.user.model.WorkloadCredentialUpdate) UsersStateDifference(com.sequenceiq.freeipa.service.freeipa.user.model.UsersStateDifference) Test(org.junit.jupiter.api.Test)

Example 2 with Config

use of com.sequenceiq.freeipa.client.model.Config in project cloudbreak by hortonworks.

the class SetPasswordHandlerTest method newfreeIpaClient.

private FreeIpaClient newfreeIpaClient(boolean hasPasswordHashSuppport) throws FreeIpaClientException {
    FreeIpaClient mockFreeIpaClient = mock(FreeIpaClient.class);
    Config config = mock(Config.class);
    if (hasPasswordHashSuppport) {
        when(config.getIpauserobjectclasses()).thenReturn(Set.of("cdpUserAttr"));
    } else {
        when(config.getIpauserobjectclasses()).thenReturn(Set.of());
    }
    when(mockFreeIpaClient.getConfig()).thenReturn(config);
    return mockFreeIpaClient;
}
Also used : FreeIpaClient(com.sequenceiq.freeipa.client.FreeIpaClient) Config(com.sequenceiq.freeipa.client.model.Config)

Example 3 with Config

use of com.sequenceiq.freeipa.client.model.Config in project cloudbreak by hortonworks.

the class UserSyncStateApplierTest method testApplyDifferenceNoPasswordHashSupport.

@Test
public void testApplyDifferenceNoPasswordHashSupport() throws FreeIpaClientException, TimeoutException {
    UmsUsersState umsUsersState = mock(UmsUsersState.class);
    UserSyncOptions userSyncOptions = mock(UserSyncOptions.class);
    UsersStateDifference usersStateDifference = createStateDiff();
    Multimap<String, String> warnings = ArrayListMultimap.create();
    when(userSyncOptions.isFmsToFreeIpaBatchCallEnabled()).thenReturn(Boolean.TRUE);
    when(freeIpaClient.getConfig()).thenReturn(new Config());
    underTest.applyDifference(umsUsersState, ENV_CRN, warnings, usersStateDifference, userSyncOptions, freeIpaClient);
    verifyNoInteractions(workloadCredentialService);
}
Also used : Config(com.sequenceiq.freeipa.client.model.Config) UmsUsersState(com.sequenceiq.freeipa.service.freeipa.user.model.UmsUsersState) UserSyncOptions(com.sequenceiq.freeipa.service.freeipa.user.model.UserSyncOptions) UsersStateDifference(com.sequenceiq.freeipa.service.freeipa.user.model.UsersStateDifference) Test(org.junit.jupiter.api.Test)

Example 4 with Config

use of com.sequenceiq.freeipa.client.model.Config in project cloudbreak by hortonworks.

the class UserKeytabServiceTest method newfreeIpaClient.

private FreeIpaClient newfreeIpaClient(boolean hasPasswordHashSuppport) throws FreeIpaClientException {
    FreeIpaClient mockFreeIpaClient = mock(FreeIpaClient.class);
    Config config = mock(Config.class);
    if (hasPasswordHashSuppport) {
        when(config.getIpauserobjectclasses()).thenReturn(Set.of("cdpUserAttr"));
    } else {
        when(config.getIpauserobjectclasses()).thenReturn(Set.of());
    }
    when(mockFreeIpaClient.getConfig()).thenReturn(config);
    return mockFreeIpaClient;
}
Also used : FreeIpaClient(com.sequenceiq.freeipa.client.FreeIpaClient) Config(com.sequenceiq.freeipa.client.model.Config) KerberosConfig(com.sequenceiq.freeipa.kerberos.KerberosConfig)

Example 5 with Config

use of com.sequenceiq.freeipa.client.model.Config in project cloudbreak by hortonworks.

the class ConfigShowResponse method handleInternal.

@Override
protected Config handleInternal(List<CloudVmMetaDataStatus> metadatas, String body) {
    Config config = new Config();
    config.setIpamaxusernamelength(IPA_MAX_USERNAME_LENGTH);
    return config;
}
Also used : Config(com.sequenceiq.freeipa.client.model.Config)

Aggregations

Config (com.sequenceiq.freeipa.client.model.Config)5 FreeIpaClient (com.sequenceiq.freeipa.client.FreeIpaClient)2 UmsUsersState (com.sequenceiq.freeipa.service.freeipa.user.model.UmsUsersState)2 UserSyncOptions (com.sequenceiq.freeipa.service.freeipa.user.model.UserSyncOptions)2 UsersStateDifference (com.sequenceiq.freeipa.service.freeipa.user.model.UsersStateDifference)2 Test (org.junit.jupiter.api.Test)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 KerberosConfig (com.sequenceiq.freeipa.kerberos.KerberosConfig)1 UserMetadata (com.sequenceiq.freeipa.service.freeipa.user.model.UserMetadata)1 UsersState (com.sequenceiq.freeipa.service.freeipa.user.model.UsersState)1 WorkloadCredential (com.sequenceiq.freeipa.service.freeipa.user.model.WorkloadCredential)1 WorkloadCredentialUpdate (com.sequenceiq.freeipa.service.freeipa.user.model.WorkloadCredentialUpdate)1 Set (java.util.Set)1