use of com.sequenceiq.freeipa.api.v1.dns.model.AddDnsARecordRequest in project cloudbreak by hortonworks.
the class DnsRecordServiceTest method testARecordAddNotFound.
@Test
public void testARecordAddNotFound() 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);
when(freeIpaClient.showDnsRecord(DOMAIN, request.getHostname())).thenThrow(new FreeIpaClientException("Not found", new JsonRpcClientException(FreeIpaErrorCodes.NOT_FOUND.getValue(), "Not found", null)));
underTest.addDnsARecord(ACCOUNT_ID, request);
verify(freeIpaClient).addDnsARecord(DOMAIN, request.getHostname(), request.getIp(), request.isCreateReverse());
}
use of com.sequenceiq.freeipa.api.v1.dns.model.AddDnsARecordRequest 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());
}
use of com.sequenceiq.freeipa.api.v1.dns.model.AddDnsARecordRequest 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());
}
Aggregations