@Test public void testDeleteDnsRecordByFqdn() throws Exception { Stack stack = createStack(); given(stackService.getByEnvironmentCrnAndAccountId(ENV_CRN, ACCOUNT_ID)).willReturn(stack); given(freeIpaService.findByStack(any())).willReturn(createFreeIpa()); given(freeIpaClientFactory.getFreeIpaClientForStack(stack)).willReturn(freeIpaClient); given(freeIpaClient.findAllDnsZone()).willReturn(createDnsZones()); given(freeIpaClient.findAllDnsRecordInZone(DOMAIN)).willReturn(createDnsRecords()); underTest.deleteDnsRecordByFqdn(ENV_CRN, ACCOUNT_ID, List.of("www.example.com", "foo.example.com")); verify(freeIpaClient).deleteDnsRecord(eq("www.example.com"), eq("example.com")); verify(freeIpaClient).deleteDnsSrvRecord(eq("foo.example.com"), eq("example.com"), eq(SRV_RECORDS)); }
public void deleteDnsRecordByFqdn(String environmentCrn, String accountId, List<String> fqdns) throws FreeIpaClientException { Stack stack = stackService.getByEnvironmentCrnAndAccountId(environmentCrn, accountId); MDCBuilder.buildMdcContext(stack); FreeIpa freeIpa = freeIpaService.findByStack(stack); FreeIpaClient freeIpaClient = freeIpaClientFactory.getFreeIpaClientForStack(stack); for (DnsZone dnsZone : freeIpaClient.findAllDnsZone()) { LOGGER.debug("Looking for records in zone [{}]", dnsZone.getIdnsname()); Set<DnsRecord> allDnsRecordsInZone = freeIpaClient.findAllDnsRecordInZone(dnsZone.getIdnsname()); deleteRegularRecords(freeIpaClient, dnsZone, allDnsRecordsInZone, fqdns, freeIpa.getDomain()); deleteSrvRecords(freeIpaClient, dnsZone, allDnsRecordsInZone, fqdns); } }
DnsRecordService { public void deleteDnsRecordByFqdn(String environmentCrn, String accountId, List<String> fqdns) throws FreeIpaClientException { Stack stack = stackService.getByEnvironmentCrnAndAccountId(environmentCrn, accountId); MDCBuilder.buildMdcContext(stack); FreeIpa freeIpa = freeIpaService.findByStack(stack); FreeIpaClient freeIpaClient = freeIpaClientFactory.getFreeIpaClientForStack(stack); for (DnsZone dnsZone : freeIpaClient.findAllDnsZone()) { LOGGER.debug("Looking for records in zone [{}]", dnsZone.getIdnsname()); Set<DnsRecord> allDnsRecordsInZone = freeIpaClient.findAllDnsRecordInZone(dnsZone.getIdnsname()); deleteRegularRecords(freeIpaClient, dnsZone, allDnsRecordsInZone, fqdns, freeIpa.getDomain()); deleteSrvRecords(freeIpaClient, dnsZone, allDnsRecordsInZone, fqdns); } } }
DnsRecordService { public void deleteDnsRecordByFqdn(String environmentCrn, String accountId, List<String> fqdns) throws FreeIpaClientException { Stack stack = stackService.getByEnvironmentCrnAndAccountId(environmentCrn, accountId); MDCBuilder.buildMdcContext(stack); FreeIpa freeIpa = freeIpaService.findByStack(stack); FreeIpaClient freeIpaClient = freeIpaClientFactory.getFreeIpaClientForStack(stack); for (DnsZone dnsZone : freeIpaClient.findAllDnsZone()) { LOGGER.debug("Looking for records in zone [{}]", dnsZone.getIdnsname()); Set<DnsRecord> allDnsRecordsInZone = freeIpaClient.findAllDnsRecordInZone(dnsZone.getIdnsname()); deleteRegularRecords(freeIpaClient, dnsZone, allDnsRecordsInZone, fqdns, freeIpa.getDomain()); deleteSrvRecords(freeIpaClient, dnsZone, allDnsRecordsInZone, fqdns); } }  }
DnsRecordService { public void deleteDnsRecordByFqdn(String environmentCrn, String accountId, List<String> fqdns) throws FreeIpaClientException { Stack stack = stackService.getByEnvironmentCrnAndAccountId(environmentCrn, accountId); MDCBuilder.buildMdcContext(stack); FreeIpa freeIpa = freeIpaService.findByStack(stack); FreeIpaClient freeIpaClient = freeIpaClientFactory.getFreeIpaClientForStack(stack); for (DnsZone dnsZone : freeIpaClient.findAllDnsZone()) { LOGGER.debug("Looking for records in zone [{}]", dnsZone.getIdnsname()); Set<DnsRecord> allDnsRecordsInZone = freeIpaClient.findAllDnsRecordInZone(dnsZone.getIdnsname()); deleteRegularRecords(freeIpaClient, dnsZone, allDnsRecordsInZone, fqdns, freeIpa.getDomain()); deleteSrvRecords(freeIpaClient, dnsZone, allDnsRecordsInZone, fqdns); } }  void deleteDnsRecordByFqdn(String environmentCrn, String accountId,  List<String> fqdns); }
DnsRecordService { public void deleteDnsRecordByFqdn(String environmentCrn, String accountId, List<String> fqdns) throws FreeIpaClientException { Stack stack = stackService.getByEnvironmentCrnAndAccountId(environmentCrn, accountId); MDCBuilder.buildMdcContext(stack); FreeIpa freeIpa = freeIpaService.findByStack(stack); FreeIpaClient freeIpaClient = freeIpaClientFactory.getFreeIpaClientForStack(stack); for (DnsZone dnsZone : freeIpaClient.findAllDnsZone()) { LOGGER.debug("Looking for records in zone [{}]", dnsZone.getIdnsname()); Set<DnsRecord> allDnsRecordsInZone = freeIpaClient.findAllDnsRecordInZone(dnsZone.getIdnsname()); deleteRegularRecords(freeIpaClient, dnsZone, allDnsRecordsInZone, fqdns, freeIpa.getDomain()); deleteSrvRecords(freeIpaClient, dnsZone, allDnsRecordsInZone, fqdns); } }  void deleteDnsRecordByFqdn(String environmentCrn, String accountId,  List<String> fqdns);  }