Search in sources :

Example 1 with DnsRecord

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

the class DnsRecordServiceTest method testARecordExists.

@Test
public void testARecordExists() 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);
    DnsRecord dnsRecord = new DnsRecord();
    dnsRecord.setArecord(List.of(request.getIp()));
    dnsRecord.setIdnsname(request.getHostname());
    when(freeIpaClient.showDnsRecord(DOMAIN, request.getHostname())).thenReturn(dnsRecord);
    underTest.addDnsARecord(ACCOUNT_ID, request);
    verify(freeIpaClient, times(0)).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) DnsRecord(com.sequenceiq.freeipa.client.model.DnsRecord) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Example 2 with DnsRecord

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

the class DnsRecordServiceTest method testARecordExistsDifferentValue.

@Test
public void testARecordExistsDifferentValue() 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);
    DnsRecord dnsRecord = new DnsRecord();
    dnsRecord.setArecord(List.of("asdf"));
    dnsRecord.setIdnsname(request.getHostname());
    when(freeIpaClient.showDnsRecord(DOMAIN, request.getHostname())).thenReturn(dnsRecord);
    Assertions.assertThrows(DnsRecordConflictException.class, () -> underTest.addDnsARecord(ACCOUNT_ID, request));
}
Also used : FreeIpa(com.sequenceiq.freeipa.entity.FreeIpa) AddDnsARecordRequest(com.sequenceiq.freeipa.api.v1.dns.model.AddDnsARecordRequest) DnsRecord(com.sequenceiq.freeipa.client.model.DnsRecord) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Example 3 with DnsRecord

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

the class DnsRecordAddResponse method handleInternal.

@Override
protected DnsRecord handleInternal(List<CloudVmMetaDataStatus> metadatas, String body) {
    DnsRecord dnsRecord = new DnsRecord();
    dnsRecord.setIdnsname("localhost");
    return dnsRecord;
}
Also used : DnsRecord(com.sequenceiq.freeipa.client.model.DnsRecord)

Example 4 with DnsRecord

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

the class DnsRecordFindResponse method handleInternal.

@Override
protected Set<DnsRecord> handleInternal(List<CloudVmMetaDataStatus> metadatas, String body) {
    DnsRecord dnsRecord = new DnsRecord();
    dnsRecord.setIdnsname("admin");
    return Set.of(dnsRecord);
}
Also used : DnsRecord(com.sequenceiq.freeipa.client.model.DnsRecord)

Example 5 with DnsRecord

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

the class DnsRecordShowResponse method handleInternal.

@Override
protected DnsRecord handleInternal(List<CloudVmMetaDataStatus> metadatas, String body) {
    DnsRecord dnsRecord = new DnsRecord();
    dnsRecord.setIdnsname("localhost");
    return dnsRecord;
}
Also used : DnsRecord(com.sequenceiq.freeipa.client.model.DnsRecord)

Aggregations

DnsRecord (com.sequenceiq.freeipa.client.model.DnsRecord)14 FreeIpa (com.sequenceiq.freeipa.entity.FreeIpa)8 Stack (com.sequenceiq.freeipa.entity.Stack)8 Test (org.junit.jupiter.api.Test)6 AddDnsARecordRequest (com.sequenceiq.freeipa.api.v1.dns.model.AddDnsARecordRequest)5 AddDnsCnameRecordRequest (com.sequenceiq.freeipa.api.v1.dns.model.AddDnsCnameRecordRequest)5 DnsZone (com.sequenceiq.freeipa.client.model.DnsZone)4 Measure (com.sequenceiq.cloudbreak.aspect.Measure)3 FreeIpaClient (com.sequenceiq.freeipa.client.FreeIpaClient)3 FreeIpaClientException (com.sequenceiq.freeipa.client.FreeIpaClientException)3 Set (java.util.Set)3 Retryable (org.springframework.retry.annotation.Retryable)3 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)2 MDCBuilder (com.sequenceiq.cloudbreak.logger.MDCBuilder)2 FreeIpaClientExceptionUtil (com.sequenceiq.freeipa.client.FreeIpaClientExceptionUtil)2 FreeIpaClientExceptionUtil.ignoreEmptyModExceptionWithValue (com.sequenceiq.freeipa.client.FreeIpaClientExceptionUtil.ignoreEmptyModExceptionWithValue)2 FreeIpaClientExceptionUtil.ignoreNotFoundException (com.sequenceiq.freeipa.client.FreeIpaClientExceptionUtil.ignoreNotFoundException)2 FreeIpaClientExceptionUtil.ignoreNotFoundExceptionWithValue (com.sequenceiq.freeipa.client.FreeIpaClientExceptionUtil.ignoreNotFoundExceptionWithValue)2 RetryableFreeIpaClientException (com.sequenceiq.freeipa.client.RetryableFreeIpaClientException)2 FreeIpaClientFactory (com.sequenceiq.freeipa.service.freeipa.FreeIpaClientFactory)2