use of com.sequenceiq.cloudbreak.dto.ProxyConfig in project cloudbreak by hortonworks.
the class ProxyConfigProvider method decoratePillarWithProxyDataIfNeeded.
public void decoratePillarWithProxyDataIfNeeded(Map<String, SaltPillarProperties> servicePillar, Cluster cluster) {
Optional<ProxyConfig> proxyConfig = proxyConfigDtoService.getByCrnWithEnvironmentFallback(cluster.getProxyConfigCrn(), cluster.getEnvironmentCrn());
proxyConfig.ifPresent(pc -> {
Map<String, Object> proxy = new HashMap<>();
proxy.put("host", pc.getServerHost());
proxy.put("port", pc.getServerPort());
proxy.put("protocol", pc.getProtocol());
pc.getProxyAuthentication().ifPresent(auth -> {
proxy.put("user", auth.getUserName());
proxy.put("password", auth.getPassword());
});
proxy.put("noProxyHosts", pc.getNoProxyHosts());
servicePillar.put(PROXY_KEY, new SaltPillarProperties(PROXY_SLS_PATH, singletonMap(PROXY_KEY, proxy)));
LOGGER.info("Salt pillar properties extend with proxy config: {}", pc);
});
}
use of com.sequenceiq.cloudbreak.dto.ProxyConfig in project cloudbreak by hortonworks.
the class UserDataBuilderTest method testBuildUserDataAzureWithNoAuthProxy.
@Test
public void testBuildUserDataAzureWithNoAuthProxy() throws IOException {
String expectedGwScript = FileReaderUtils.readFileFromClasspath("azure-gateway-init-noauthproxy.sh");
String expectedCoreScript = FileReaderUtils.readFileFromClasspath("azure-core-init.sh");
ProxyConfig proxyConfig = ProxyConfig.builder().withServerHost("proxy.host").withServerPort(1234).withNoProxyHosts("noproxy.com").withProtocol("http").build();
Map<InstanceGroupType, String> userdata = underTest.buildUserData(Platform.platform("AZURE"), "priv-key".getBytes(), "cloudbreak", getPlatformParameters(), "pass", "cert", new CcmConnectivityParameters(), proxyConfig);
Assert.assertEquals(expectedGwScript, userdata.get(InstanceGroupType.GATEWAY));
Assert.assertEquals(expectedCoreScript, userdata.get(InstanceGroupType.CORE));
}
use of com.sequenceiq.cloudbreak.dto.ProxyConfig in project cloudbreak by hortonworks.
the class UserDataBuilderTest method testBuildUserDataAzureWithAuthProxy.
@Test
public void testBuildUserDataAzureWithAuthProxy() throws IOException {
String expectedGwScript = FileReaderUtils.readFileFromClasspath("azure-gateway-init-authproxy.sh");
String expectedCoreScript = FileReaderUtils.readFileFromClasspath("azure-core-init.sh");
ProxyAuthentication proxyAuthentication = ProxyAuthentication.builder().withUserName("user").withPassword("pwd").build();
ProxyConfig proxyConfig = ProxyConfig.builder().withServerHost("proxy.host").withServerPort(1234).withProxyAuthentication(proxyAuthentication).withNoProxyHosts("noproxy.com").withProtocol("https").build();
Map<InstanceGroupType, String> userdata = underTest.buildUserData(Platform.platform("AZURE"), "priv-key".getBytes(), "cloudbreak", getPlatformParameters(), "pass", "cert", new CcmConnectivityParameters(), proxyConfig);
Assert.assertEquals(expectedGwScript, userdata.get(InstanceGroupType.GATEWAY));
Assert.assertEquals(expectedCoreScript, userdata.get(InstanceGroupType.CORE));
}
use of com.sequenceiq.cloudbreak.dto.ProxyConfig in project cloudbreak by hortonworks.
the class ProxyConfigDtoServiceTest method testGetWhenProxyConfigUserPasswordEmpty.
@ParameterizedTest
@MethodSource("invalidUserPasswords")
void testGetWhenProxyConfigUserPasswordEmpty(String user, String password) {
String name = "aProxyConfig";
String host = "https://test.cloudera.com";
Integer port = 8443;
String decryptedSecretValue = "decrypted-secret-value";
SecretResponse secretResponse = new SecretResponse();
ProxyResponse proxyResponse = new ProxyResponse();
proxyResponse.setName(name);
proxyResponse.setHost(host);
proxyResponse.setPort(port);
proxyResponse.setUserName(secretResponse);
proxyResponse.setPassword(secretResponse);
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
when(environmentServiceCrnClient.withCrn(anyString()).proxyV1Endpoint()).thenReturn(proxyEndpoint);
when(proxyEndpoint.getByResourceCrn(anyString())).thenReturn(proxyResponse);
when(secretService.getByResponse(any(SecretResponse.class))).thenReturn(user).thenReturn(password);
ProxyConfig proxyConfig = underTest.getByCrn("crn:cdp:environments:us-west-1:cloudera:proxyconfig:a2f0bee2-059e-433f-a9d0-2893c53419ad");
assertFalse(proxyConfig.getProxyAuthentication().isPresent());
}
use of com.sequenceiq.cloudbreak.dto.ProxyConfig in project cloudbreak by hortonworks.
the class ProxyConfigDtoServiceTest method testGetWhenProxyConfigUserPasswordSecretsAreEmpty.
@ParameterizedTest
@MethodSource("invalidUserPasswordSecrets")
void testGetWhenProxyConfigUserPasswordSecretsAreEmpty(SecretResponse user, SecretResponse password) {
String name = "aProxyConfig";
String host = "https://test.cloudera.com";
Integer port = 8443;
ProxyResponse proxyResponse = new ProxyResponse();
proxyResponse.setName(name);
proxyResponse.setHost(host);
proxyResponse.setPort(port);
proxyResponse.setUserName(user);
proxyResponse.setPassword(password);
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
when(environmentServiceCrnClient.withCrn(anyString()).proxyV1Endpoint()).thenReturn(proxyEndpoint);
when(proxyEndpoint.getByResourceCrn(anyString())).thenReturn(proxyResponse);
ProxyConfig proxyConfig = underTest.getByCrn("crn:cdp:environments:us-west-1:cloudera:proxyconfig:a2f0bee2-059e-433f-a9d0-2893c53419ad");
assertFalse(proxyConfig.getProxyAuthentication().isPresent());
}
Aggregations