Search in sources :

Example 11 with AddDnsCnameRecordRequest

use of com.sequenceiq.freeipa.api.v1.dns.model.AddDnsCnameRecordRequest in project cloudbreak by hortonworks.

the class DnsRecordServiceTest method testCnameRecordAddWithoutTrailingDot.

@Test
public void testCnameRecordAddWithoutTrailingDot() throws FreeIpaClientException {
    AddDnsCnameRecordRequest request = new AddDnsCnameRecordRequest();
    request.setEnvironmentCrn(ENV_CRN);
    request.setCname("Asdf");
    request.setTargetFqdn("example2.com");
    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.addDnsCnameRecord(ACCOUNT_ID, request);
    verify(freeIpaClient).addDnsCnameRecord(DOMAIN, request.getCname(), TARGET_FQDN);
}
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 12 with AddDnsCnameRecordRequest

use of com.sequenceiq.freeipa.api.v1.dns.model.AddDnsCnameRecordRequest in project cloudbreak by hortonworks.

the class DnsRecordServiceTest method testCnameRecordExistsDifferentValue.

@Test
public void testCnameRecordExistsDifferentValue() 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("asdf"));
    dnsRecord.setIdnsname(request.getCname());
    when(freeIpaClient.showDnsRecord(DOMAIN, request.getCname())).thenReturn(dnsRecord);
    Assertions.assertThrows(DnsRecordConflictException.class, () -> underTest.addDnsCnameRecord(ACCOUNT_ID, request));
}
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 13 with AddDnsCnameRecordRequest

use of com.sequenceiq.freeipa.api.v1.dns.model.AddDnsCnameRecordRequest in project cloudbreak by hortonworks.

the class FreeIpaUpgradeTests method addAndDeleteDnsCnameRecord.

private void addAndDeleteDnsCnameRecord(com.sequenceiq.freeipa.api.client.FreeIpaClient ipaClient, String environmentCrn) {
    try {
        AddDnsCnameRecordRequest request = new AddDnsCnameRecordRequest();
        request.setCname("test-cname-record");
        request.setTargetFqdn("cloudera.com");
        request.setEnvironmentCrn(environmentCrn);
        ipaClient.getDnsV1Endpoint().addDnsCnameRecord(request);
        ipaClient.getDnsV1Endpoint().deleteDnsCnameRecord(environmentCrn, null, request.getCname());
    } catch (Exception e) {
        logger.error("DNS CNAME record test failed during upgrade", e);
        throw new TestFailException("DNS CNAME record test failed during upgrade with: " + e.getMessage(), e);
    }
}
Also used : TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) AddDnsCnameRecordRequest(com.sequenceiq.freeipa.api.v1.dns.model.AddDnsCnameRecordRequest) WebApplicationException(javax.ws.rs.WebApplicationException) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException)

Aggregations

AddDnsCnameRecordRequest (com.sequenceiq.freeipa.api.v1.dns.model.AddDnsCnameRecordRequest)13 FreeIpa (com.sequenceiq.freeipa.entity.FreeIpa)10 Stack (com.sequenceiq.freeipa.entity.Stack)10 Test (org.junit.jupiter.api.Test)10 DnsRecord (com.sequenceiq.freeipa.client.model.DnsRecord)3 JsonRpcClientException (com.googlecode.jsonrpc4j.JsonRpcClientException)2 FreeIpaClientException (com.sequenceiq.freeipa.client.FreeIpaClientException)2 LoadBalancer (com.sequenceiq.cloudbreak.domain.stack.loadbalancer.LoadBalancer)1 TestFailException (com.sequenceiq.it.cloudbreak.exception.TestFailException)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 Test (org.junit.Test)1