Search in sources :

Example 1 with LdapConfig

use of com.sequenceiq.freeipa.ldap.LdapConfig in project cloudbreak by hortonworks.

the class LdapConfigV1ServiceTest method testPost.

@Test
public void testPost() {
    // GIVEN
    CreateLdapConfigRequest createLdapConfigRequest = createCreateLdapConfigRequest();
    LdapConfig ldapConfig = createLdapConfig();
    ArgumentCaptor<LdapConfig> ldapConfigParam = ArgumentCaptor.forClass(LdapConfig.class);
    Mockito.when(stringToSecretResponseConverter.convert(SECRET_BINDDN)).thenReturn(new SecretResponse("enginepath", "binddn-secretpath"));
    Mockito.when(stringToSecretResponseConverter.convert(SECRET_PWD)).thenReturn(new SecretResponse("enginepath", "pwd-secretpath"));
    Mockito.when(ldapConfigService.createLdapConfig(ldapConfigParam.capture())).thenReturn(ldapConfig);
    // WHEN
    DescribeLdapConfigResponse actualResponse = underTest.post(createLdapConfigRequest);
    // THEN
    checkInnerLdapConfig(ldapConfigParam.getValue());
    checkResponse(actualResponse);
}
Also used : LdapConfig(com.sequenceiq.freeipa.ldap.LdapConfig) SecretResponse(com.sequenceiq.cloudbreak.service.secret.model.SecretResponse) DescribeLdapConfigResponse(com.sequenceiq.freeipa.api.v1.ldap.model.describe.DescribeLdapConfigResponse) CreateLdapConfigRequest(com.sequenceiq.freeipa.api.v1.ldap.model.create.CreateLdapConfigRequest) Test(org.junit.Test)

Example 2 with LdapConfig

use of com.sequenceiq.freeipa.ldap.LdapConfig in project cloudbreak by hortonworks.

the class LdapBindUserCreationHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<CreateLdapBindUserEvent> event) {
    CreateBindUserEvent data = event.getData();
    Optional<LdapConfig> ldapConfig = ldapConfigService.find(data.getEnvironmentCrn(), data.getAccountId(), data.getSuffix());
    if (ldapConfig.isPresent()) {
        LOGGER.info("LDAP configuration already exists: {}", ldapConfig.get());
        return new CreateBindUserEvent(CreateBindUserFlowEvent.CREATE_LDAP_BIND_USER_FINISHED_EVENT.event(), data);
    } else {
        return createLdapBindUSer(event.getEvent(), data);
    }
}
Also used : LdapConfig(com.sequenceiq.freeipa.ldap.LdapConfig) CreateBindUserEvent(com.sequenceiq.freeipa.flow.freeipa.binduser.create.event.CreateBindUserEvent)

Example 3 with LdapConfig

use of com.sequenceiq.freeipa.ldap.LdapConfig in project cloudbreak by hortonworks.

the class LdapConfigV1ServiceTest method testDescribe.

@Test
public void testDescribe() {
    // GIVEN
    LdapConfig ldapConfig = createLdapConfig();
    Mockito.when(ldapConfigService.get(ENVID)).thenReturn(ldapConfig);
    Mockito.when(stringToSecretResponseConverter.convert(SECRET_BINDDN)).thenReturn(new SecretResponse("enginepath", "binddn-secretpath"));
    Mockito.when(stringToSecretResponseConverter.convert(SECRET_PWD)).thenReturn(new SecretResponse("enginepath", "pwd-secretpath"));
    // WHEN
    DescribeLdapConfigResponse actualResponse = underTest.describe(ENVID);
    // THEN
    checkResponse(actualResponse);
}
Also used : LdapConfig(com.sequenceiq.freeipa.ldap.LdapConfig) SecretResponse(com.sequenceiq.cloudbreak.service.secret.model.SecretResponse) DescribeLdapConfigResponse(com.sequenceiq.freeipa.api.v1.ldap.model.describe.DescribeLdapConfigResponse) Test(org.junit.Test)

Example 4 with LdapConfig

use of com.sequenceiq.freeipa.ldap.LdapConfig in project cloudbreak by hortonworks.

the class LdapConfigV1ServiceTest method testGetCreateRequest.

@Test
public void testGetCreateRequest() {
    // GIVEN
    LdapConfig ldapConfig = createLdapConfig();
    Mockito.when(ldapConfigService.get(ENVID)).thenReturn(ldapConfig);
    // WHEN
    CreateLdapConfigRequest actualRequest = underTest.getCreateLdapConfigRequest(ENVID);
    // THEN
    checkCreateRequest(actualRequest);
}
Also used : LdapConfig(com.sequenceiq.freeipa.ldap.LdapConfig) CreateLdapConfigRequest(com.sequenceiq.freeipa.api.v1.ldap.model.create.CreateLdapConfigRequest) Test(org.junit.Test)

Example 5 with LdapConfig

use of com.sequenceiq.freeipa.ldap.LdapConfig in project cloudbreak by hortonworks.

the class LdapConfigV1ServiceTest method createLdapConfig.

private LdapConfig createLdapConfig() {
    LdapConfig ldapConfig = new LdapConfig();
    ldapConfig.setName(LDAPNAME);
    ldapConfig.setDescription(LDAPDESC);
    ldapConfig.setEnvironmentCrn(ENVID);
    ldapConfig.setProtocol(LDAP_PROTOCOL);
    ldapConfig.setServerHost(HOST);
    ldapConfig.setServerPort(PORT);
    SecretTestUtil.setSecretField(LdapConfig.class, "bindDn", ldapConfig, BINDDN, SECRET_BINDDN);
    SecretTestUtil.setSecretField(LdapConfig.class, "bindPassword", ldapConfig, PWD, SECRET_PWD);
    ldapConfig.setAdminGroup(ADMIN);
    ldapConfig.setCertificate(CERT);
    ldapConfig.setDirectoryType(DirectoryType.LDAP);
    ldapConfig.setDomain(DOMAIN);
    ldapConfig.setGroupMemberAttribute(MEMBER);
    ldapConfig.setGroupObjectClass(GROUPOBJCLASS);
    ldapConfig.setGroupSearchBase(GROUPSEARCHBASE);
    ldapConfig.setGroupNameAttribute(GROUPNAMEATTR);
    ldapConfig.setUserDnPattern(USERDNPATTERN);
    ldapConfig.setUserNameAttribute(USERNAMEATTR);
    ldapConfig.setUserObjectClass(USEROBJCLASS);
    ldapConfig.setUserSearchBase(USERSEARCHBASE);
    return ldapConfig;
}
Also used : LdapConfig(com.sequenceiq.freeipa.ldap.LdapConfig)

Aggregations

LdapConfig (com.sequenceiq.freeipa.ldap.LdapConfig)13 Test (org.junit.Test)3 SecretResponse (com.sequenceiq.cloudbreak.service.secret.model.SecretResponse)2 CreateLdapConfigRequest (com.sequenceiq.freeipa.api.v1.ldap.model.create.CreateLdapConfigRequest)2 DescribeLdapConfigResponse (com.sequenceiq.freeipa.api.v1.ldap.model.describe.DescribeLdapConfigResponse)2 FreeIpa (com.sequenceiq.freeipa.entity.FreeIpa)2 Stack (com.sequenceiq.freeipa.entity.Stack)2 CreateBindUserEvent (com.sequenceiq.freeipa.flow.freeipa.binduser.create.event.CreateBindUserEvent)2 Test (org.junit.jupiter.api.Test)2 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)1 HandlerEvent (com.sequenceiq.flow.reactor.api.handler.HandlerEvent)1 TestLdapConfigResponse (com.sequenceiq.freeipa.api.v1.ldap.model.test.TestLdapConfigResponse)1 InstanceGroup (com.sequenceiq.freeipa.entity.InstanceGroup)1 InstanceMetaData (com.sequenceiq.freeipa.entity.InstanceMetaData)1 CreateLdapBindUserEvent (com.sequenceiq.freeipa.flow.freeipa.binduser.create.event.CreateLdapBindUserEvent)1