use of com.sequenceiq.freeipa.api.v1.dns.model.AddDnsARecordRequest in project cloudbreak by hortonworks.
the class FreeIpaUpgradeTests method addAndDeleteDnsARecord.
private void addAndDeleteDnsARecord(com.sequenceiq.freeipa.api.client.FreeIpaClient ipaClient, String environmentCrn) {
try {
AddDnsARecordRequest aRecordRequest = new AddDnsARecordRequest();
aRecordRequest.setHostname("test-a-record");
aRecordRequest.setCreateReverse(true);
aRecordRequest.setEnvironmentCrn(environmentCrn);
aRecordRequest.setIp("1.2.3.4");
ipaClient.getDnsV1Endpoint().addDnsARecord(aRecordRequest);
ipaClient.getDnsV1Endpoint().deleteDnsARecord(environmentCrn, null, aRecordRequest.getHostname());
} catch (Exception e) {
logger.error("DNS A record test failed during upgrade", e);
throw new TestFailException("DNS A record test failed during upgrade with: " + e.getMessage(), e);
}
}
use of com.sequenceiq.freeipa.api.v1.dns.model.AddDnsARecordRequest in project cloudbreak by hortonworks.
the class FreeIPAEndpointManagementServiceTest method testRegisterLoadBalancerWithIP.
@Test
public void testRegisterLoadBalancerWithIP() {
LoadBalancer loadBalancer = new LoadBalancer();
loadBalancer.setType(LoadBalancerType.PUBLIC);
loadBalancer.setIp(LB_IP);
loadBalancer.setEndpoint(LB_ENDPOINT);
when(loadBalancerPersistenceService.findByStackId(any())).thenReturn(Set.of(loadBalancer));
when(loadBalancerConfigService.selectLoadBalancerForFrontend(any(), any())).thenReturn(Optional.of(loadBalancer));
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn:cdp:freeipa:us-west-1:altus:user:__internal__actor__");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
ThreadBasedUserCrnProvider.doAs(TEST_USER_CRN, () -> underTest.registerLoadBalancerDomainWithFreeIPA(stack));
ArgumentCaptor<AddDnsARecordRequest> requestCaptor = ArgumentCaptor.forClass(AddDnsARecordRequest.class);
verify(dnsV1Endpoint, times(1)).addDnsARecordInternal(any(), requestCaptor.capture());
assertEquals(LB_IP, requestCaptor.getValue().getIp());
assertEquals(LB_ENDPOINT, requestCaptor.getValue().getHostname());
}
use of com.sequenceiq.freeipa.api.v1.dns.model.AddDnsARecordRequest 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());
}
use of com.sequenceiq.freeipa.api.v1.dns.model.AddDnsARecordRequest in project cloudbreak by hortonworks.
the class DnsRecordServiceTest method testARecordCreateReturnDuplicate.
@Test
public void testARecordCreateReturnDuplicate() 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.addDnsARecord(anyString(), eq(request.getHostname()), eq(request.getIp()), eq(true))).thenThrow(new FreeIpaClientException("Duplicate", new JsonRpcClientException(4002, "Duplicate reverse", null)));
Assertions.assertThrows(DnsRecordConflictException.class, () -> underTest.addDnsARecord(ACCOUNT_ID, request));
}
use of com.sequenceiq.freeipa.api.v1.dns.model.AddDnsARecordRequest in project cloudbreak by hortonworks.
the class DnsRecordServiceTest method testARecordAddSameDomain.
@Test
public void testARecordAddSameDomain() throws FreeIpaClientException {
AddDnsARecordRequest request = new AddDnsARecordRequest();
request.setEnvironmentCrn(ENV_CRN);
request.setHostname("Asdf");
request.setIp("1.1.1.2");
request.setDnsZone(DOMAIN);
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(request.getDnsZone(), request.getHostname(), request.getIp(), request.isCreateReverse());
}
Aggregations