Search in sources :

Example 51 with FreeIpa

use of com.sequenceiq.freeipa.entity.FreeIpa in project cloudbreak by hortonworks.

the class DnsRecordServiceTest method testARecordAdd.

@Test
public void testARecordAdd() throws FreeIpaClientException {
    AddDnsARecordRequest request = new AddDnsARecordRequest();
    request.setEnvironmentCrn(ENV_CRN);
    request.setHostname("Asdf");
    request.setIp("1.1.1.2");
    request.setCreateReverse(true);
    Stack stack = createStack();
    when(stackService.getByEnvironmentCrnAndAccountId(ENV_CRN, ACCOUNT_ID)).thenReturn(stack);
    FreeIpa freeIpa = createFreeIpa();
    when(freeIpaService.findByStack(stack)).thenReturn(freeIpa);
    when(freeIpaClientFactory.getFreeIpaClientForStack(stack)).thenReturn(freeIpaClient);
    underTest.addDnsARecord(ACCOUNT_ID, request);
    verify(freeIpaClient).addDnsARecord(DOMAIN, request.getHostname(), request.getIp(), request.isCreateReverse());
}
Also used : FreeIpa(com.sequenceiq.freeipa.entity.FreeIpa) AddDnsARecordRequest(com.sequenceiq.freeipa.api.v1.dns.model.AddDnsARecordRequest) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Example 52 with FreeIpa

use of com.sequenceiq.freeipa.entity.FreeIpa in project cloudbreak by hortonworks.

the class DnsRecordServiceTest method testCnameRecordExists.

@Test
public void testCnameRecordExists() throws FreeIpaClientException {
    AddDnsCnameRecordRequest request = new AddDnsCnameRecordRequest();
    request.setEnvironmentCrn(ENV_CRN);
    request.setCname("Asdf");
    request.setTargetFqdn(TARGET_FQDN);
    Stack stack = createStack();
    when(stackService.getByEnvironmentCrnAndAccountId(ENV_CRN, ACCOUNT_ID)).thenReturn(stack);
    FreeIpa freeIpa = createFreeIpa();
    when(freeIpaService.findByStack(stack)).thenReturn(freeIpa);
    when(freeIpaClientFactory.getFreeIpaClientForStack(stack)).thenReturn(freeIpaClient);
    DnsRecord dnsRecord = new DnsRecord();
    dnsRecord.setCnamerecord(List.of(request.getTargetFqdn()));
    dnsRecord.setIdnsname(request.getCname());
    when(freeIpaClient.showDnsRecord(DOMAIN, request.getCname())).thenReturn(dnsRecord);
    underTest.addDnsCnameRecord(ACCOUNT_ID, request);
    verify(freeIpaClient, times(0)).addDnsCnameRecord(DOMAIN, request.getCname(), request.getTargetFqdn());
}
Also used : FreeIpa(com.sequenceiq.freeipa.entity.FreeIpa) AddDnsCnameRecordRequest(com.sequenceiq.freeipa.api.v1.dns.model.AddDnsCnameRecordRequest) DnsRecord(com.sequenceiq.freeipa.client.model.DnsRecord) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Example 53 with FreeIpa

use of com.sequenceiq.freeipa.entity.FreeIpa in project cloudbreak by hortonworks.

the class DnsRecordServiceTest method testDeleteSameDomain.

@Test
public void testDeleteSameDomain() throws FreeIpaClientException {
    Stack stack = createStack();
    when(stackService.getByEnvironmentCrnAndAccountId(ENV_CRN, ACCOUNT_ID)).thenReturn(stack);
    FreeIpa freeIpa = createFreeIpa();
    when(freeIpaService.findByStack(stack)).thenReturn(freeIpa);
    when(freeIpaClientFactory.getFreeIpaClientForStack(stack)).thenReturn(freeIpaClient);
    underTest.deleteDnsRecord(ACCOUNT_ID, ENV_CRN, DOMAIN, "asdf");
    verify(freeIpaClient).deleteDnsRecord("asdf", DOMAIN);
}
Also used : FreeIpa(com.sequenceiq.freeipa.entity.FreeIpa) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Example 54 with FreeIpa

use of com.sequenceiq.freeipa.entity.FreeIpa in project cloudbreak by hortonworks.

the class DnsRecordServiceTest method testCnameRecordAddDifferentDomainExists.

@Test
public void testCnameRecordAddDifferentDomainExists() throws FreeIpaClientException {
    AddDnsCnameRecordRequest request = new AddDnsCnameRecordRequest();
    request.setEnvironmentCrn(ENV_CRN);
    request.setCname("Asdf");
    request.setTargetFqdn(TARGET_FQDN);
    request.setDnsZone(DOMAIN2);
    Stack stack = createStack();
    when(stackService.getByEnvironmentCrnAndAccountId(ENV_CRN, ACCOUNT_ID)).thenReturn(stack);
    FreeIpa freeIpa = createFreeIpa();
    when(freeIpaService.findByStack(stack)).thenReturn(freeIpa);
    when(freeIpaClientFactory.getFreeIpaClientForStack(stack)).thenReturn(freeIpaClient);
    when(freeIpaClient.findAllDnsZone()).thenReturn(createDnsZones(DOMAIN, DOMAIN2));
    underTest.addDnsCnameRecord(ACCOUNT_ID, request);
    verify(freeIpaClient).addDnsCnameRecord(request.getDnsZone(), request.getCname(), request.getTargetFqdn());
}
Also used : FreeIpa(com.sequenceiq.freeipa.entity.FreeIpa) AddDnsCnameRecordRequest(com.sequenceiq.freeipa.api.v1.dns.model.AddDnsCnameRecordRequest) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Example 55 with FreeIpa

use of com.sequenceiq.freeipa.entity.FreeIpa in project cloudbreak by hortonworks.

the class DnsRecordServiceTest method testARecordAddDifferentDomainExists.

@Test
public void testARecordAddDifferentDomainExists() throws FreeIpaClientException {
    AddDnsARecordRequest request = new AddDnsARecordRequest();
    request.setEnvironmentCrn(ENV_CRN);
    request.setHostname("Asdf");
    request.setIp("1.1.1.2");
    request.setDnsZone(DOMAIN2);
    Stack stack = createStack();
    when(stackService.getByEnvironmentCrnAndAccountId(ENV_CRN, ACCOUNT_ID)).thenReturn(stack);
    FreeIpa freeIpa = createFreeIpa();
    when(freeIpaService.findByStack(stack)).thenReturn(freeIpa);
    when(freeIpaClientFactory.getFreeIpaClientForStack(stack)).thenReturn(freeIpaClient);
    when(freeIpaClient.findAllDnsZone()).thenReturn(createDnsZones(DOMAIN, DOMAIN2));
    underTest.addDnsARecord(ACCOUNT_ID, request);
    verify(freeIpaClient).addDnsARecord(request.getDnsZone(), request.getHostname(), request.getIp(), request.isCreateReverse());
}
Also used : FreeIpa(com.sequenceiq.freeipa.entity.FreeIpa) AddDnsARecordRequest(com.sequenceiq.freeipa.api.v1.dns.model.AddDnsARecordRequest) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Aggregations

FreeIpa (com.sequenceiq.freeipa.entity.FreeIpa)75 Stack (com.sequenceiq.freeipa.entity.Stack)62 Test (org.junit.jupiter.api.Test)50 GatewayConfig (com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)12 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)11 AddDnsARecordRequest (com.sequenceiq.freeipa.api.v1.dns.model.AddDnsARecordRequest)10 AddDnsCnameRecordRequest (com.sequenceiq.freeipa.api.v1.dns.model.AddDnsCnameRecordRequest)10 FreeIpaClientException (com.sequenceiq.freeipa.client.FreeIpaClientException)10 ImageEntity (com.sequenceiq.freeipa.entity.ImageEntity)10 InstanceMetaData (com.sequenceiq.freeipa.entity.InstanceMetaData)8 InstanceGroup (com.sequenceiq.freeipa.entity.InstanceGroup)7 JsonRpcClientException (com.googlecode.jsonrpc4j.JsonRpcClientException)6 HttpClientConfig (com.sequenceiq.cloudbreak.client.HttpClientConfig)6 DnsRecord (com.sequenceiq.freeipa.client.model.DnsRecord)6 Set (java.util.Set)6 ClusterServiceConfig (com.sequenceiq.cloudbreak.clusterproxy.ClusterServiceConfig)5 ConfigRegistrationRequest (com.sequenceiq.cloudbreak.clusterproxy.ConfigRegistrationRequest)5 ConfigRegistrationResponse (com.sequenceiq.cloudbreak.clusterproxy.ConfigRegistrationResponse)5 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)5 Optional (java.util.Optional)5