use of com.sequenceiq.freeipa.entity.FreeIpa in project cloudbreak by hortonworks.
the class DnsRecordServiceTest method testDeleteIgnoreNotFound.
@Test
public void testDeleteIgnoreNotFound() throws FreeIpaClientException {
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.deleteDnsRecord("asdf", DOMAIN)).thenThrow(new FreeIpaClientException("Not found", new JsonRpcClientException(FreeIpaErrorCodes.NOT_FOUND.getValue(), "Not found", null)));
underTest.deleteDnsRecord(ACCOUNT_ID, ENV_CRN, null, "asdf");
}
use of com.sequenceiq.freeipa.entity.FreeIpa in project cloudbreak by hortonworks.
the class KerberosConfigRegisterServiceTest method testRegister.
@Test
void testRegister() {
Stack stack = new Stack();
stack.setEnvironmentCrn("env");
stack.setAccountId("acc");
stack.setName("name");
stack.setAppVersion("2.20.0");
InstanceGroup instanceGroup = new InstanceGroup();
instanceGroup.setInstanceGroupType(InstanceGroupType.MASTER);
InstanceMetaData instanceMetaData = new InstanceMetaData();
instanceMetaData.setDiscoveryFQDN("fqdn");
instanceMetaData.setPrivateIp("1.1.1.1");
instanceGroup.setInstanceMetaData(Collections.singleton(instanceMetaData));
stack.setInstanceGroups(Collections.singleton(instanceGroup));
when(stackService.getByIdWithListsInTransaction(anyLong())).thenReturn(stack);
FreeIpa freeIpa = new FreeIpa();
freeIpa.setDomain("testdomain.local");
freeIpa.setAdminPassword("asdf");
when(freeIpaService.findByStackId(anyLong())).thenReturn(freeIpa);
when(balancedDnsAvailabilityChecker.isBalancedDnsAvailable(stack)).thenReturn(true);
underTest.register(1L);
ArgumentCaptor<KerberosConfig> kerberosConfigArgumentCaptor = ArgumentCaptor.forClass(KerberosConfig.class);
ArgumentCaptor<String> accountIdArgumentCaptor = ArgumentCaptor.forClass(String.class);
verify(kerberosConfigService).createKerberosConfig(kerberosConfigArgumentCaptor.capture(), accountIdArgumentCaptor.capture());
assertEquals(stack.getAccountId(), accountIdArgumentCaptor.getValue());
KerberosConfig kerberosConfig = kerberosConfigArgumentCaptor.getValue();
assertEquals(stack.getName(), kerberosConfig.getName());
assertEquals(stack.getEnvironmentCrn(), kerberosConfig.getEnvironmentCrn());
assertEquals("kdc.testdomain.local", kerberosConfig.getUrl());
assertEquals("kerberos.testdomain.local", kerberosConfig.getAdminUrl());
assertEquals(instanceMetaData.getPrivateIp(), kerberosConfig.getNameServers());
assertEquals(freeIpa.getAdminPassword(), kerberosConfig.getPassword());
assertEquals(freeIpa.getDomain(), kerberosConfig.getDomain());
assertEquals(freeIpa.getDomain().toUpperCase(), kerberosConfig.getRealm());
assertEquals(KerberosType.FREEIPA, kerberosConfig.getType());
assertEquals(KerberosConfigRegisterService.FREEIPA_DEFAULT_ADMIN, kerberosConfig.getPrincipal());
}
use of com.sequenceiq.freeipa.entity.FreeIpa in project cloudbreak by hortonworks.
the class FreeIpaClientFactoryTest method getFreeIpaClientForStackShouldReturnClientWhenStackStatusIsValid.
@Test
void getFreeIpaClientForStackShouldReturnClientWhenStackStatusIsValid() throws FreeIpaClientException {
Stack stack = createStack();
stack.setGatewayport(80);
FreeIpa freeIpa = new FreeIpa();
freeIpa.setAdminPassword(new Secret("", ""));
when(freeIpaService.findByStack(stack)).thenReturn(freeIpa);
when(stackService.getByIdWithListsInTransaction(stack.getId())).thenReturn(stack);
when(tlsSecurityService.buildTLSClientConfig(any(), any(), any())).thenReturn(new HttpClientConfig(FREEIPP_FQDN));
Status unreachableState = Status.AVAILABLE;
StackStatus stackStatus = new StackStatus(stack, unreachableState, "The FreeIPA instance is reachable.", DetailedStackStatus.AVAILABLE);
stack.setStackStatus(stackStatus);
when(clusterProxyService.isCreateConfigForClusterProxy(stack)).thenReturn(false);
FreeIpaClientException exception = Assertions.assertThrows(FreeIpaClientException.class, () -> underTest.getFreeIpaClientForStack(stack));
verify(clusterProxyService, times(1)).isCreateConfigForClusterProxy(stack);
verify(tlsSecurityService, times(1)).buildTLSClientConfig(any(), any(), any());
Assertions.assertEquals(FreeIpaClientException.class, exception.getCause().getClass());
}
use of com.sequenceiq.freeipa.entity.FreeIpa in project cloudbreak by hortonworks.
the class FreeIpaClientFactoryTest method getFreeIpaClientForStackForLegacyHealthCheckShouldReturnClientWhenStackStatusIsUnreachable.
@Test
void getFreeIpaClientForStackForLegacyHealthCheckShouldReturnClientWhenStackStatusIsUnreachable() {
Stack stack = createStack();
stack.setGatewayport(80);
FreeIpa freeIpa = new FreeIpa();
freeIpa.setAdminPassword(new Secret("", ""));
when(freeIpaService.findByStack(stack)).thenReturn(freeIpa);
when(stackService.getByIdWithListsInTransaction(stack.getId())).thenReturn(stack);
when(tlsSecurityService.buildTLSClientConfig(any(), any(), any())).thenReturn(new HttpClientConfig(FREEIPP_FQDN));
Status unreachableState = Status.FREEIPA_UNREACHABLE_STATUSES.stream().findAny().get();
StackStatus stackStatus = new StackStatus(stack, unreachableState, "The FreeIPA instance is unreachable.", DetailedStackStatus.UNREACHABLE);
stack.setStackStatus(stackStatus);
FreeIpaClientException exception = Assertions.assertThrows(FreeIpaClientException.class, () -> underTest.getFreeIpaClientForStackForLegacyHealthCheck(stack, FREEIPP_FQDN));
verify(clusterProxyService, times(1)).isCreateConfigForClusterProxy(stack);
verify(tlsSecurityService, times(1)).buildTLSClientConfig(any(), any(), any());
Assertions.assertEquals(FreeIpaClientException.class, exception.getCause().getClass());
}
use of com.sequenceiq.freeipa.entity.FreeIpa in project cloudbreak by hortonworks.
the class FreeIpaToListFreeIpaResponseConverterTest method createFreeIpa.
private FreeIpa createFreeIpa(String domain, Stack stack) {
FreeIpa freeIpa = new FreeIpa();
freeIpa.setDomain(domain);
freeIpa.setStack(stack);
return freeIpa;
}
Aggregations