use of com.sequenceiq.cloudbreak.ccm.cloudinit.CcmV2JumpgateParameters in project cloudbreak by hortonworks.
the class DefaultCcmV2JumpgateParameterSupplierTest method testGetCcmV2JumpgateParameters.
@ParameterizedTest
@ValueSource(booleans = { false, true })
void testGetCcmV2JumpgateParameters(boolean singleWayTls) {
String gatewayDomain = "test.gateway.domain";
InvertingProxy mockInvertingProxy = InvertingProxy.newBuilder().setHostname("invertingProxyHost").setCertificate("invertingProxyCertificate").build();
InvertingProxyAgent mockInvertingProxyAgent = getInvertingProxyAgent(singleWayTls);
when(ccmV2Client.awaitReadyInvertingProxyForAccount(anyString(), anyString())).thenReturn(mockInvertingProxy);
when(ccmV2Client.registerInvertingProxyAgent(anyString(), anyString(), any(Optional.class), anyString(), anyString())).thenReturn(mockInvertingProxyAgent);
CcmV2JumpgateParameters resultParameters = underTest.getCcmV2JumpgateParameters(TEST_ACCOUNT_ID, Optional.of(TEST_ENVIRONMENT_CRN), gatewayDomain, Crn.fromString(TEST_CLUSTER_CRN).getResource());
assertNotNull(resultParameters, "CCMV2 Jumpgate Parameters should not be null");
assertEquals(TEST_ENVIRONMENT_CRN, resultParameters.getEnvironmentCrn(), "EnvironmentCRN should match");
assertEquals("invertingProxyAgentCrn", resultParameters.getAgentCrn(), "AgentCRN should match");
assertEquals("invertingProxyHost", resultParameters.getInvertingProxyHost(), "InvertingProxyHost should match");
assertEquals("invertingProxyCertificate", resultParameters.getInvertingProxyCertificate(), "InvertingProxyCertificate should match");
assertEquals(TEST_RESOURCE_ID, resultParameters.getAgentKeyId(), "AgentKeyId should match");
assertAgentCertOrMachineUser(resultParameters, singleWayTls);
}
use of com.sequenceiq.cloudbreak.ccm.cloudinit.CcmV2JumpgateParameters in project cloudbreak by hortonworks.
the class CcmParametersConfigServiceTest method testParamsWithTwoWayTls.
@Test
void testParamsWithTwoWayTls() {
when(entitlementService.ccmV2UseOneWayTls(ACCOUNT)).thenReturn(false);
CcmV2JumpgateParameters params = createParams();
Map<String, SaltPillarProperties> result = underTest.createCcmParametersPillarConfig(ACCOUNT, params);
assertThat(result).containsKey("ccm_jumpgate");
Map<String, Object> properties = result.get("ccm_jumpgate").getProperties();
assertThat(properties).containsKey("ccm_jumpgate");
Map<String, Object> ccmParameterMap = (Map<String, Object>) properties.get("ccm_jumpgate");
assertThat(ccmParameterMap).containsOnly(Map.entry("inverting_proxy_certificate", INVERTING_PROXY_CERTIFICATE), Map.entry("inverting_proxy_host", INVERTING_PROXY_HOST), Map.entry("agent_certificate", AGENT_CERT), Map.entry("agent_enciphered_key", PRIVATE_KEY), Map.entry("agent_key_id", AGENT_KEY_ID), Map.entry("agent_backend_id_prefix", params.getAgentBackendIdPrefix()), Map.entry("environment_crn", ENV_CRN), Map.entry("agent_access_key_id", EMPTY), Map.entry("agent_enciphered_access_key", EMPTY));
}
use of com.sequenceiq.cloudbreak.ccm.cloudinit.CcmV2JumpgateParameters in project cloudbreak by hortonworks.
the class UserDataBuilderTest method testBuildUserDataWithCCMV2JumpgateParams.
@ParameterizedTest(name = "Forced TLS mode = {0}, entitlement = {1}, filename = {2}")
@MethodSource("tlsCases")
@DisplayName("test if CCM V2 Jumpgate parameters are passed the user data contains them")
void testBuildUserDataWithCCMV2JumpgateParams(CcmV2TlsType ccmV2TlsType, boolean oneWayTlsEntitlementEnabled, String expectedContentFileName) throws IOException {
CcmV2JumpgateParameters ccmV2JumpgateParameters = new DefaultCcmV2JumpgateParameters("invertingProxyHost", "invertingProxyCertificate", "agentCrn", "agentKeyId", "agentEncipheredPrivateKey", "agentCertificate", "environmentCrn", "agentMachineUserAccessKeyId", "agentMachineUserEncipheredAccessKey");
CcmConnectivityParameters ccmConnectivityParameters = new CcmConnectivityParameters(ccmV2JumpgateParameters);
PlatformParameters platformParameters = mock(PlatformParameters.class);
ScriptParams scriptParams = mock(ScriptParams.class);
when(scriptParams.getDiskPrefix()).thenReturn("sd");
when(scriptParams.getStartLabel()).thenReturn(98);
when(platformParameters.scriptParams()).thenReturn(scriptParams);
lenient().when(entitlementService.ccmV2UseOneWayTls(ACCOUNT_ID)).thenReturn(oneWayTlsEntitlementEnabled);
environment.setCcmV2TlsType(ccmV2TlsType);
String userData = underTest.buildUserData(ACCOUNT_ID, environment, Platform.platform("AZURE"), "priv-key".getBytes(), "cloudbreak", platformParameters, "pass", "cert", ccmConnectivityParameters, null);
String expectedUserData = FileReaderUtils.readFileFromClasspath(expectedContentFileName);
assertEquals(expectedUserData, userData);
}
use of com.sequenceiq.cloudbreak.ccm.cloudinit.CcmV2JumpgateParameters in project cloudbreak by hortonworks.
the class CcmUserDataService method getCcmV2JumpgateConnectivityParameters.
private CcmConnectivityParameters getCcmV2JumpgateConnectivityParameters(Stack stack, String keyId) {
String generatedClusterDomain = getGatewayFqdn(stack);
CcmV2JumpgateParameters ccmV2JumpgateParameters = ccmV2JumpgateParameterSupplier.getCcmV2JumpgateParameters(stack.getAccountId(), Optional.of(stack.getEnvironmentCrn()), generatedClusterDomain, keyId);
CcmConnectivityParameters ccmConnectivityParameters = new CcmConnectivityParameters(ccmV2JumpgateParameters);
saveCcmV2Config(stack.getId(), ccmV2JumpgateParameters);
return ccmConnectivityParameters;
}
use of com.sequenceiq.cloudbreak.ccm.cloudinit.CcmV2JumpgateParameters in project cloudbreak by hortonworks.
the class UserDataBuilderTest method testBuildUserDataWithCCMV2Jumpgate.
@Test
public void testBuildUserDataWithCCMV2Jumpgate() throws IOException {
CcmV2JumpgateParameters ccmV2JumpgateParameters = new DefaultCcmV2JumpgateParameters();
CcmConnectivityParameters ccmConnectivityParameters = new CcmConnectivityParameters(ccmV2JumpgateParameters);
Map<InstanceGroupType, String> userdata = underTest.buildUserData(Platform.platform("AZURE"), "priv-key".getBytes(), "cloudbreak", getPlatformParameters(), "pass", "cert", ccmConnectivityParameters, null);
String expectedCoreScript = FileReaderUtils.readFileFromClasspath("azure-core-ccm-init.sh");
String expectedGwScript = FileReaderUtils.readFileFromClasspath("azure-gateway-ccm-v2-jumpgate-init.sh");
Assert.assertEquals(expectedCoreScript, userdata.get(InstanceGroupType.CORE));
Assert.assertEquals(expectedGwScript, userdata.get(InstanceGroupType.GATEWAY));
}
Aggregations