Search in sources :

Example 1 with CcmV2JumpgateParameters

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);
}
Also used : InvertingProxyAgent(com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.InvertingProxyAgent) Optional(java.util.Optional) InvertingProxy(com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.InvertingProxy) CcmV2JumpgateParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmV2JumpgateParameters) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with CcmV2JumpgateParameters

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));
}
Also used : DefaultCcmV2JumpgateParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2JumpgateParameters) CcmV2JumpgateParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmV2JumpgateParameters) Map(java.util.Map) SaltPillarProperties(com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties) Test(org.junit.jupiter.api.Test)

Example 3 with CcmV2JumpgateParameters

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);
}
Also used : CcmConnectivityParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters) DefaultCcmV2JumpgateParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2JumpgateParameters) ScriptParams(com.sequenceiq.cloudbreak.cloud.model.ScriptParams) DefaultCcmV2JumpgateParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2JumpgateParameters) CcmV2JumpgateParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmV2JumpgateParameters) PlatformParameters(com.sequenceiq.cloudbreak.cloud.PlatformParameters) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource) DisplayName(org.junit.jupiter.api.DisplayName)

Example 4 with CcmV2JumpgateParameters

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;
}
Also used : CcmConnectivityParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters) CcmV2JumpgateParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmV2JumpgateParameters)

Example 5 with CcmV2JumpgateParameters

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));
}
Also used : CcmConnectivityParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters) DefaultCcmV2JumpgateParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2JumpgateParameters) InstanceGroupType(com.sequenceiq.common.api.type.InstanceGroupType) DefaultCcmV2JumpgateParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2JumpgateParameters) CcmV2JumpgateParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmV2JumpgateParameters) Test(org.junit.Test)

Aggregations

CcmV2JumpgateParameters (com.sequenceiq.cloudbreak.ccm.cloudinit.CcmV2JumpgateParameters)6 DefaultCcmV2JumpgateParameters (com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2JumpgateParameters)4 CcmConnectivityParameters (com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters)3 SaltPillarProperties (com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties)2 Map (java.util.Map)2 Test (org.junit.jupiter.api.Test)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 InvertingProxy (com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.InvertingProxy)1 InvertingProxyAgent (com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.InvertingProxyAgent)1 PlatformParameters (com.sequenceiq.cloudbreak.cloud.PlatformParameters)1 ScriptParams (com.sequenceiq.cloudbreak.cloud.model.ScriptParams)1 InstanceGroupType (com.sequenceiq.common.api.type.InstanceGroupType)1 Optional (java.util.Optional)1 Test (org.junit.Test)1 DisplayName (org.junit.jupiter.api.DisplayName)1 MethodSource (org.junit.jupiter.params.provider.MethodSource)1 ValueSource (org.junit.jupiter.params.provider.ValueSource)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1