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);
}
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()));
}
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);
}
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);
}
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()));
}
Aggregations