use of com.sequenceiq.freeipa.entity.FreeIpa in project cloudbreak by hortonworks.
the class ClusterProxyServiceTest method testClusterProxyRegistrationWhenCCMV2OrJumpgate.
@ParameterizedTest
@EnumSource(value = Tunnel.class, names = { "CCMV2", "CCMV2_JUMPGATE" }, mode = EnumSource.Mode.INCLUDE)
public void testClusterProxyRegistrationWhenCCMV2OrJumpgate(Tunnel ccmv2Mode) {
Stack aStack = getAStack();
aStack.setTunnel(ccmv2Mode);
aStack.setCcmV2AgentCrn("testAgentCrn");
FreeIpa freeIpa = new FreeIpa();
freeIpa.setDomain("ipadom");
GatewayConfig gatewayConfig = new GatewayConfig("connectionAddress", "publicIpAddress", PRIVATE_IP_ADDRESS, ServiceFamilies.GATEWAY.getDefaultPort(), "testInstanceId", true);
ConfigRegistrationResponse configRegResponse = mock(ConfigRegistrationResponse.class);
when(stackService.getStackById(STACK_ID)).thenReturn(aStack);
when(clusterProxyEnablementService.isClusterProxyApplicable(any())).thenReturn(true);
when(gatewayConfigService.getPrimaryGatewayConfig(aStack)).thenReturn(gatewayConfig);
when(securityConfigService.findOneByStack(aStack)).thenReturn(null);
when(clusterProxyRegistrationClient.registerConfig(any())).thenReturn(configRegResponse);
when(stackUpdater.updateClusterProxyRegisteredFlag(aStack, true)).thenReturn(aStack);
when(freeIpaService.findByStack(aStack)).thenReturn(freeIpa);
underTest.registerFreeIpaForBootstrap(STACK_ID);
ArgumentCaptor<ConfigRegistrationRequest> captor = ArgumentCaptor.forClass(ConfigRegistrationRequest.class);
verify(clusterProxyRegistrationClient).registerConfig(captor.capture());
ConfigRegistrationRequest proxyRegistrationReq = captor.getValue();
assertThat(proxyRegistrationReq.getClusterCrn()).isEqualTo(STACK_RESOURCE_CRN);
assertThat(proxyRegistrationReq.getAccountId()).isEqualTo(TEST_ACCOUNT_ID);
assertFalse(proxyRegistrationReq.isUseTunnel(), "CCMV1 tunnel should not be enabled");
assertTrue(proxyRegistrationReq.isUseCcmV2(), ccmv2Mode + " should be enabled.");
assertEquals(List.of(new CcmV2Config("testAgentCrn", PRIVATE_IP_ADDRESS, ServiceFamilies.GATEWAY.getDefaultPort(), "testAgentCrn-testInstanceId", FREEIPA_SERVICE)), proxyRegistrationReq.getCcmV2Configs(), ccmv2Mode + " config should match");
assertThat(proxyRegistrationReq.getServices()).contains(new ClusterServiceConfig("freeipa", List.of("https://privateIpAddress:9443"), List.of(), null));
assertThat(proxyRegistrationReq.getServices()).contains(new ClusterServiceConfig("freeipa.ipadom", List.of("https://privateIpAddress:9443"), List.of(), null));
}
use of com.sequenceiq.freeipa.entity.FreeIpa in project cloudbreak by hortonworks.
the class ClusterProxyServiceTest method testGetPathWithStackWithServiceNameNotRegistered.
@Test
public void testGetPathWithStackWithServiceNameNotRegistered() {
when(clusterProxyConfiguration.getClusterProxyBasePath()).thenReturn("basePath");
Stack stack = getAStack();
FreeIpa freeIpa = new FreeIpa();
freeIpa.setDomain("ipadom");
when(freeIpaService.findByStack(stack)).thenReturn(freeIpa);
ReadConfigResponse readConfigResponse = new ReadConfigResponse();
readConfigResponse.setServices(List.of());
when(clusterProxyRegistrationClient.readConfig(STACK_RESOURCE_CRN)).thenReturn(readConfigResponse);
String result = underTest.getProxyPath(stack, Optional.of("unregistered"));
assertEquals("basePath/proxy/resourceCrn/freeipa.ipadom", result);
}
use of com.sequenceiq.freeipa.entity.FreeIpa in project cloudbreak by hortonworks.
the class ClusterProxyServiceTest method testGetPathWithStackWithServiceNameNotRegisteredWithEmptyServices.
@Test
public void testGetPathWithStackWithServiceNameNotRegisteredWithEmptyServices() {
when(clusterProxyConfiguration.getClusterProxyBasePath()).thenReturn("basePath");
Stack stack = getAStack();
FreeIpa freeIpa = new FreeIpa();
freeIpa.setDomain("ipadom");
when(freeIpaService.findByStack(stack)).thenReturn(freeIpa);
ReadConfigResponse readConfigResponse = new ReadConfigResponse();
when(clusterProxyRegistrationClient.readConfig(STACK_RESOURCE_CRN)).thenReturn(readConfigResponse);
String result = underTest.getProxyPath(stack, Optional.of("unregistered"));
assertEquals("basePath/proxy/resourceCrn/freeipa.ipadom", result);
}
use of com.sequenceiq.freeipa.entity.FreeIpa in project cloudbreak by hortonworks.
the class ClusterProxyServiceTest method testClusterProxyRegistrationWhenCCMV1.
@Test
public void testClusterProxyRegistrationWhenCCMV1() {
Stack aStack = getAStack();
aStack.setTunnel(Tunnel.CCM);
aStack.setMinaSshdServiceId("minaSshdServiceId");
GatewayConfig gatewayConfig = new GatewayConfig("connectionAddress", "publicAddress", PRIVATE_ADDRESS, 9443, "instanceId", false);
ConfigRegistrationResponse configRegResponse = mock(ConfigRegistrationResponse.class);
FreeIpa freeIpa = new FreeIpa();
freeIpa.setDomain("ipadom");
when(stackService.getStackById(STACK_ID)).thenReturn(aStack);
when(clusterProxyEnablementService.isClusterProxyApplicable(any())).thenReturn(true);
when(gatewayConfigService.getPrimaryGatewayConfig(aStack)).thenReturn(gatewayConfig);
when(securityConfigService.findOneByStack(aStack)).thenReturn(null);
when(clusterProxyRegistrationClient.registerConfig(any())).thenReturn(configRegResponse);
when(stackUpdater.updateClusterProxyRegisteredFlag(aStack, true)).thenReturn(aStack);
when(freeIpaService.findByStack(aStack)).thenReturn(freeIpa);
underTest.registerFreeIpaForBootstrap(STACK_ID);
ArgumentCaptor<ConfigRegistrationRequest> captor = ArgumentCaptor.forClass(ConfigRegistrationRequest.class);
verify(clusterProxyRegistrationClient).registerConfig(captor.capture());
ConfigRegistrationRequest proxyRegistrationReq = captor.getValue();
assertThat(proxyRegistrationReq.getClusterCrn()).isEqualTo(STACK_RESOURCE_CRN);
assertThat(proxyRegistrationReq.getAccountId()).isEqualTo(TEST_ACCOUNT_ID);
assertFalse(proxyRegistrationReq.isUseCcmV2(), "CCMV2 should not be enabled.");
assertTrue(proxyRegistrationReq.isUseTunnel(), "CCMV1 tunnel should be enabled");
assertEquals(List.of(new TunnelEntry("instanceId", "GATEWAY", PRIVATE_ADDRESS, 9443, "minaSshdServiceId")), proxyRegistrationReq.getTunnels(), "CCMV1 tunnel should be configured.");
assertThat(proxyRegistrationReq.getServices()).contains(new ClusterServiceConfig("freeipa", List.of("https://privateAddress:9443"), List.of(), null));
assertThat(proxyRegistrationReq.getServices()).contains(new ClusterServiceConfig("freeipa.ipadom", List.of("https://privateAddress:9443"), List.of(), null));
}
use of com.sequenceiq.freeipa.entity.FreeIpa in project cloudbreak by hortonworks.
the class StackToCreateFreeIpaRequestConverter method getFreeIpaServerRequest.
private FreeIpaServerRequest getFreeIpaServerRequest(Stack stack) {
FreeIpaServerRequest request = new FreeIpaServerRequest();
FreeIpa freeIpa = freeIpaService.findByStack(stack);
if (freeIpa != null) {
request.setAdminGroupName(freeIpa.getAdminGroupName());
request.setAdminPassword(freeIpa.getAdminPassword());
request.setDomain(freeIpa.getDomain());
request.setHostname(freeIpa.getHostname());
}
LOGGER.debug("Created FreeIPA server request {} from FreeIPA {}", request, freeIpa);
return request;
}
Aggregations