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);
}
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));
}
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);
}
}
Aggregations