Search in sources :

Example 1 with ReadConfigResponse

use of com.sequenceiq.cloudbreak.clusterproxy.ReadConfigResponse in project cloudbreak by hortonworks.

the class ClusterProxyServiceTest method testGetPathWithStackWithServiceNameRegistered.

@Test
public void testGetPathWithStackWithServiceNameRegistered() {
    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();
    ReadConfigService service = new ReadConfigService();
    service.setName("registered");
    readConfigResponse.setServices(List.of(service));
    when(clusterProxyRegistrationClient.readConfig(STACK_RESOURCE_CRN)).thenReturn(readConfigResponse);
    String result = underTest.getProxyPath(stack, Optional.of("registered"));
    assertEquals("basePath/proxy/resourceCrn/registered", result);
}
Also used : FreeIpa(com.sequenceiq.freeipa.entity.FreeIpa) ReadConfigService(com.sequenceiq.cloudbreak.clusterproxy.ReadConfigService) ReadConfigResponse(com.sequenceiq.cloudbreak.clusterproxy.ReadConfigResponse) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with ReadConfigResponse

use of com.sequenceiq.cloudbreak.clusterproxy.ReadConfigResponse in project cloudbreak by hortonworks.

the class ClusterProxyService method isServiceEndpointWithIdentityIsRegistered.

private boolean isServiceEndpointWithIdentityIsRegistered(String crn, String endpointWithIdentity) {
    ReadConfigResponse readConfigResponse = clusterProxyRegistrationClient.readConfig(crn);
    LOGGER.debug("Check if internal endpoint with identity is registered");
    return readConfigResponse.getServices().stream().anyMatch(readConfigService -> endpointWithIdentity.equals(readConfigService.getName()));
}
Also used : ReadConfigResponse(com.sequenceiq.cloudbreak.clusterproxy.ReadConfigResponse)

Example 3 with ReadConfigResponse

use of com.sequenceiq.cloudbreak.clusterproxy.ReadConfigResponse 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);
}
Also used : FreeIpa(com.sequenceiq.freeipa.entity.FreeIpa) ReadConfigResponse(com.sequenceiq.cloudbreak.clusterproxy.ReadConfigResponse) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 4 with ReadConfigResponse

use of com.sequenceiq.cloudbreak.clusterproxy.ReadConfigResponse 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);
}
Also used : FreeIpa(com.sequenceiq.freeipa.entity.FreeIpa) ReadConfigResponse(com.sequenceiq.cloudbreak.clusterproxy.ReadConfigResponse) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 5 with ReadConfigResponse

use of com.sequenceiq.cloudbreak.clusterproxy.ReadConfigResponse in project cloudbreak by hortonworks.

the class ClusterProxyService method isServiceEndpointWithIdentityRegistered.

private boolean isServiceEndpointWithIdentityRegistered(String crn, String serviceName) {
    ReadConfigResponse readConfigResponse = clusterProxyRegistrationClient.readConfig(crn);
    LOGGER.debug("Check if internal endpoint with serviceName [{}] is registered", serviceName);
    return readConfigResponse.getServices() != null && readConfigResponse.getServices().stream().anyMatch(readConfigService -> serviceName.equals(readConfigService.getName()));
}
Also used : FreeIpaCertVaultComponent(com.sequenceiq.freeipa.vault.FreeIpaCertVaultComponent) CCMV2_BACKEND_ID_FORMAT(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmV2ParameterConstants.CCMV2_BACKEND_ID_FORMAT) FreeIpaDomainUtils(com.sequenceiq.freeipa.service.config.FreeIpaDomainUtils) LoggerFactory(org.slf4j.LoggerFactory) ConfigRegistrationRequestBuilder(com.sequenceiq.cloudbreak.clusterproxy.ConfigRegistrationRequestBuilder) ConfigRegistrationResponse(com.sequenceiq.cloudbreak.clusterproxy.ConfigRegistrationResponse) MDCBuilder(com.sequenceiq.cloudbreak.logger.MDCBuilder) JsonUtil(com.sequenceiq.cloudbreak.common.json.JsonUtil) ConfigRegistrationRequest(com.sequenceiq.cloudbreak.clusterproxy.ConfigRegistrationRequest) StringUtils(org.apache.commons.lang3.StringUtils) ClusterProxyConfiguration(com.sequenceiq.cloudbreak.clusterproxy.ClusterProxyConfiguration) Inject(javax.inject.Inject) Value(org.springframework.beans.factory.annotation.Value) VaultSecret(com.sequenceiq.cloudbreak.service.secret.vault.VaultSecret) TunnelEntry(com.sequenceiq.cloudbreak.clusterproxy.TunnelEntry) Service(org.springframework.stereotype.Service) LinkedList(java.util.LinkedList) ServiceFamilies(com.sequenceiq.cloudbreak.ccm.endpoint.ServiceFamilies) Tunnel(com.sequenceiq.common.api.type.Tunnel) Stack(com.sequenceiq.freeipa.entity.Stack) VaultConfigException(com.sequenceiq.cloudbreak.service.secret.vault.VaultConfigException) ClientCertificate(com.sequenceiq.cloudbreak.clusterproxy.ClientCertificate) ClusterServiceConfig(com.sequenceiq.cloudbreak.clusterproxy.ClusterServiceConfig) Logger(org.slf4j.Logger) FreeIpa(com.sequenceiq.freeipa.entity.FreeIpa) ClusterServiceHealthCheck(com.sequenceiq.cloudbreak.clusterproxy.ClusterServiceHealthCheck) ReadConfigResponse(com.sequenceiq.cloudbreak.clusterproxy.ReadConfigResponse) IOException(java.io.IOException) ServiceEndpointHealthListenerTask(com.sequenceiq.freeipa.service.polling.clusterproxy.ServiceEndpointHealthListenerTask) SecurityConfigService(com.sequenceiq.freeipa.service.SecurityConfigService) ClusterProxyServiceAvailabilityChecker(com.sequenceiq.freeipa.util.ClusterProxyServiceAvailabilityChecker) ClusterProxyEnablementService(com.sequenceiq.cloudbreak.clusterproxy.ClusterProxyEnablementService) ServiceEndpointHealthPollerObject(com.sequenceiq.freeipa.service.polling.clusterproxy.ServiceEndpointHealthPollerObject) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) SecurityConfig(com.sequenceiq.freeipa.entity.SecurityConfig) List(java.util.List) ClusterProxyRegistrationClient(com.sequenceiq.cloudbreak.clusterproxy.ClusterProxyRegistrationClient) GatewayConfigService(com.sequenceiq.freeipa.service.GatewayConfigService) PollingService(com.sequenceiq.cloudbreak.polling.PollingService) FreeIpaService(com.sequenceiq.freeipa.service.freeipa.FreeIpaService) CcmV2Config(com.sequenceiq.cloudbreak.clusterproxy.CcmV2Config) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig) Optional(java.util.Optional) HealthCheckAvailabilityChecker(com.sequenceiq.freeipa.util.HealthCheckAvailabilityChecker) ReadConfigResponse(com.sequenceiq.cloudbreak.clusterproxy.ReadConfigResponse)

Aggregations

ReadConfigResponse (com.sequenceiq.cloudbreak.clusterproxy.ReadConfigResponse)6 FreeIpa (com.sequenceiq.freeipa.entity.FreeIpa)4 Stack (com.sequenceiq.freeipa.entity.Stack)4 Test (org.junit.jupiter.api.Test)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 ClusterProxyRegistrationClient (com.sequenceiq.cloudbreak.clusterproxy.ClusterProxyRegistrationClient)2 Logger (org.slf4j.Logger)2 LoggerFactory (org.slf4j.LoggerFactory)2 CCMV2_BACKEND_ID_FORMAT (com.sequenceiq.cloudbreak.ccm.cloudinit.CcmV2ParameterConstants.CCMV2_BACKEND_ID_FORMAT)1 ServiceFamilies (com.sequenceiq.cloudbreak.ccm.endpoint.ServiceFamilies)1 CcmV2Config (com.sequenceiq.cloudbreak.clusterproxy.CcmV2Config)1 ClientCertificate (com.sequenceiq.cloudbreak.clusterproxy.ClientCertificate)1 ClusterProxyConfiguration (com.sequenceiq.cloudbreak.clusterproxy.ClusterProxyConfiguration)1 ClusterProxyEnablementService (com.sequenceiq.cloudbreak.clusterproxy.ClusterProxyEnablementService)1 ClusterServiceConfig (com.sequenceiq.cloudbreak.clusterproxy.ClusterServiceConfig)1 ClusterServiceHealthCheck (com.sequenceiq.cloudbreak.clusterproxy.ClusterServiceHealthCheck)1 ConfigRegistrationRequest (com.sequenceiq.cloudbreak.clusterproxy.ConfigRegistrationRequest)1 ConfigRegistrationRequestBuilder (com.sequenceiq.cloudbreak.clusterproxy.ConfigRegistrationRequestBuilder)1 ConfigRegistrationResponse (com.sequenceiq.cloudbreak.clusterproxy.ConfigRegistrationResponse)1 ReadConfigEndpoint (com.sequenceiq.cloudbreak.clusterproxy.ReadConfigEndpoint)1