use of com.sequenceiq.freeipa.entity.FreeIpa in project cloudbreak by hortonworks.
the class DnsRecordServiceTest method createFreeIpa.
private FreeIpa createFreeIpa() {
FreeIpa freeIpa = new FreeIpa();
freeIpa.setDomain(DOMAIN);
return freeIpa;
}
use of com.sequenceiq.freeipa.entity.FreeIpa in project cloudbreak by hortonworks.
the class DnsRecordServiceTest method testCnameRecordExistsNotCname.
@Test
public void testCnameRecordExistsNotCname() 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.setPtrrecord(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.entity.FreeIpa in project cloudbreak by hortonworks.
the class FreeIpaConfigServiceTest method testCcmV2Tunnel.
@ParameterizedTest(name = "{0}")
@MethodSource("ccmv2Scenarios")
void testCcmV2Tunnel(Tunnel tunnel, boolean expectedCcmv2Enabled, boolean expectedCcmV2JumpgateEnabled) {
Stack stack = new Stack();
stack.setTunnel(tunnel);
Network network = new Network();
network.setNetworkCidrs(List.of(CIDR));
stack.setNetwork(network);
FreeIpa freeIpa = new FreeIpa();
freeIpa.setDomain(DOMAIN);
when(freeIpaService.findByStack(any())).thenReturn(freeIpa);
when(reverseDnsZoneCalculator.reverseDnsZoneForCidrs(any())).thenReturn(REVERSE_ZONE);
when(networkService.getFilteredSubnetWithCidr(any())).thenReturn(subnetWithCidr);
GatewayConfig gatewayConfig = mock(GatewayConfig.class);
when(gatewayConfig.getHostname()).thenReturn(HOSTNAME);
when(gatewayConfigService.getPrimaryGatewayConfig(any())).thenReturn(gatewayConfig);
when(networkService.getFilteredSubnetWithCidr(any())).thenReturn(subnetWithCidr);
FreeIpaConfigView freeIpaConfigView = underTest.createFreeIpaConfigs(stack, Set.of());
assertEquals(expectedCcmv2Enabled, freeIpaConfigView.isCcmv2Enabled());
assertEquals(expectedCcmV2JumpgateEnabled, freeIpaConfigView.isCcmv2JumpgateEnabled());
}
use of com.sequenceiq.freeipa.entity.FreeIpa in project cloudbreak by hortonworks.
the class FreeIpaConfigServiceTest method testCreateFreeIpaConfigs.
@Test
void testCreateFreeIpaConfigs() {
String backupLocation = "s3://mybucket/test";
Backup backup = new Backup();
backup.setStorageLocation(backupLocation);
backup.setS3(new S3CloudStorageV1Parameters());
FreeIpa freeIpa = new FreeIpa();
freeIpa.setDomain(DOMAIN);
freeIpa.setAdminPassword(PASSWORD);
Stack stack = new Stack();
stack.setCloudPlatform(CloudPlatform.AWS.name());
stack.setBackup(backup);
stack.setEnvironmentCrn("envcrn");
Network network = new Network();
network.setNetworkCidrs(List.of(CIDR));
stack.setNetwork(network);
when(freeIpaService.findByStack(any())).thenReturn(freeIpa);
when(freeIpaClientFactory.getAdminUser()).thenReturn(ADMIN);
when(networkService.getFilteredSubnetWithCidr(any())).thenReturn(subnetWithCidr);
when(reverseDnsZoneCalculator.reverseDnsZoneForCidrs(any())).thenReturn(REVERSE_ZONE);
when(environment.getProperty("freeipa.platform.dnssec.validation.AWS", "true")).thenReturn("true");
GatewayConfig gatewayConfig = mock(GatewayConfig.class);
when(gatewayConfig.getHostname()).thenReturn(HOSTNAME);
when(gatewayConfigService.getPrimaryGatewayConfig(any())).thenReturn(gatewayConfig);
when(proxyConfigDtoService.getByEnvironmentCrn(anyString())).thenReturn(Optional.empty());
Node node = new Node(PRIVATE_IP, null, null, null, HOSTNAME, DOMAIN, (String) null);
Map<String, String> expectedHost = Map.of("ip", PRIVATE_IP, "fqdn", HOSTNAME);
Set<Object> expectedHosts = ImmutableSet.of(expectedHost);
FreeIpaConfigView freeIpaConfigView = underTest.createFreeIpaConfigs(stack, ImmutableSet.of(node));
assertEquals(DOMAIN.toUpperCase(), freeIpaConfigView.getRealm());
assertEquals(DOMAIN, freeIpaConfigView.getDomain());
assertEquals(PASSWORD, freeIpaConfigView.getPassword());
assertEquals(REVERSE_ZONE, freeIpaConfigView.getReverseZones());
assertEquals(ADMIN, freeIpaConfigView.getAdminUser());
assertEquals(HOSTNAME, freeIpaConfigView.getFreeipaToReplicate());
assertEquals(backupLocation, freeIpaConfigView.getBackup().getLocation());
assertEquals(CloudPlatform.AWS.name(), freeIpaConfigView.getBackup().getPlatform());
assertEquals(expectedHosts, freeIpaConfigView.getHosts());
assertEquals(List.of(CIDR), freeIpaConfigView.getCidrBlocks());
}
use of com.sequenceiq.freeipa.entity.FreeIpa 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);
}
Aggregations