Search in sources :

Example 21 with TemplatePreparationObject

use of com.sequenceiq.cloudbreak.template.TemplatePreparationObject in project cloudbreak by hortonworks.

the class KnoxGatewayConfigProviderTest method testGetAdditionalServicesWhenNoKnoxRequested.

@Test
public void testGetAdditionalServicesWhenNoKnoxRequested() {
    HostgroupView master = new HostgroupView("master", 1, InstanceGroupType.GATEWAY, 1);
    HostgroupView worker = new HostgroupView("worker", 2, InstanceGroupType.CORE, 2);
    TemplatePreparationObject preparationObject = Builder.builder().withHostgroupViews(Set.of(master, worker)).build();
    String inputJson = getBlueprintText("input/clouderamanager.bp");
    CmTemplateProcessor cmTemplateProcessor = new CmTemplateProcessor(inputJson);
    Map<String, ApiClusterTemplateService> additionalServices = underTest.getAdditionalServices(cmTemplateProcessor, preparationObject);
    assertTrue(additionalServices.isEmpty());
}
Also used : TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) ApiClusterTemplateService(com.cloudera.api.swagger.model.ApiClusterTemplateService) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) CmTemplateProcessor(com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor) HostgroupView(com.sequenceiq.cloudbreak.template.views.HostgroupView) Test(org.junit.Test)

Example 22 with TemplatePreparationObject

use of com.sequenceiq.cloudbreak.template.TemplatePreparationObject in project cloudbreak by hortonworks.

the class KnoxGatewayConfigProviderTest method testGatewayWhitelistConfig.

@Test
public void testGatewayWhitelistConfig() {
    TemplatePreparationObject noKerberosTPO = Builder.builder().withGeneralClusterConfigs(new GeneralClusterConfigs()).build();
    assertEquals(config("gateway_dispatch_whitelist", "^*.*$"), underTest.getGatewayWhitelistConfig(noKerberosTPO));
    KerberosConfig kerberosConfig = KerberosConfig.KerberosConfigBuilder.aKerberosConfig().withDomain("example.com").build();
    TemplatePreparationObject kerberosNoAutoTlsTPO = Builder.builder().withGeneralClusterConfigs(new GeneralClusterConfigs()).withKerberosConfig(kerberosConfig).build();
    assertEquals(config("gateway_dispatch_whitelist", "^/.*$;^https?://(.+.example.com):[0-9]+/?.*$"), underTest.getGatewayWhitelistConfig(kerberosNoAutoTlsTPO));
    GeneralClusterConfigs generalClusterConfigs = new GeneralClusterConfigs();
    generalClusterConfigs.setAutoTlsEnabled(true);
    TemplatePreparationObject kerberosAutoTlsTPO = Builder.builder().withGeneralClusterConfigs(generalClusterConfigs).withKerberosConfig(kerberosConfig).build();
    assertEquals(config("gateway_dispatch_whitelist", "^/.*$;^https://(.+.example.com):[0-9]+/?.*$"), underTest.getGatewayWhitelistConfig(kerberosAutoTlsTPO));
}
Also used : TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) GeneralClusterConfigs(com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs) KerberosConfig(com.sequenceiq.cloudbreak.dto.KerberosConfig) Test(org.junit.Test)

Example 23 with TemplatePreparationObject

use of com.sequenceiq.cloudbreak.template.TemplatePreparationObject in project cloudbreak by hortonworks.

the class KnoxIdBrokerConfigProviderTest method getRoleConfigWhenIdBrokerAndNoFileSystemAndAws.

@Test
public void getRoleConfigWhenIdBrokerAndNoFileSystemAndAws() {
    TemplatePreparationObject tpo = new Builder().withCloudPlatform(CloudPlatform.AWS).withAccountMappingView(new AccountMappingView(GROUP_MAPPINGS, USER_MAPPINGS)).build();
    List<ApiClusterTemplateConfig> result = underTest.getRoleConfigs(IDBROKER, tpo);
    Map<String, String> configNameToValueMap = getConfigNameToValueMap(result);
    assertThat(configNameToValueMap).containsOnly(Map.entry(IDBROKER_AWS_USER_MAPPING, USER_MAPPINGS_STR), Map.entry(IDBROKER_AWS_GROUP_MAPPING, GROUP_MAPPINGS_STR));
    Map<String, String> configNameToVariableNameMap = getConfigNameToVariableNameMap(result);
    assertThat(configNameToVariableNameMap).isEmpty();
}
Also used : TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) Builder(com.sequenceiq.cloudbreak.template.TemplatePreparationObject.Builder) ApiClusterTemplateConfig(com.cloudera.api.swagger.model.ApiClusterTemplateConfig) AccountMappingView(com.sequenceiq.cloudbreak.template.views.AccountMappingView) Test(org.junit.Test)

Example 24 with TemplatePreparationObject

use of com.sequenceiq.cloudbreak.template.TemplatePreparationObject in project cloudbreak by hortonworks.

the class KnoxIdBrokerConfigProviderTest method getRoleConfigWhenIdBrokerAndInvalidFileSystem.

@Test
public void getRoleConfigWhenIdBrokerAndInvalidFileSystem() {
    BaseFileSystemConfigurationsView fileSystemConfigurationsView = mock(BaseFileSystemConfigurationsView.class);
    when(fileSystemConfigurationsView.getType()).thenReturn("DOS");
    TemplatePreparationObject tpo = new Builder().withCloudPlatform(CloudPlatform.AWS).withFileSystemConfigurationView(fileSystemConfigurationsView).build();
    thrown.expect(IllegalStateException.class);
    thrown.expectMessage("Unknown file system type:");
    underTest.getRoleConfigs(IDBROKER, tpo);
}
Also used : TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) BaseFileSystemConfigurationsView(com.sequenceiq.cloudbreak.template.filesystem.BaseFileSystemConfigurationsView) Builder(com.sequenceiq.cloudbreak.template.TemplatePreparationObject.Builder) Test(org.junit.Test)

Example 25 with TemplatePreparationObject

use of com.sequenceiq.cloudbreak.template.TemplatePreparationObject in project cloudbreak by hortonworks.

the class KnoxIdBrokerConfigProviderTest method getRoleConfigWhenIdBrokerAndAdlsGen2FileSystemAndInvalidCMVersion.

@Test
public void getRoleConfigWhenIdBrokerAndAdlsGen2FileSystemAndInvalidCMVersion() {
    BaseFileSystemConfigurationsView fileSystemConfigurationsView = mock(BaseFileSystemConfigurationsView.class);
    when(fileSystemConfigurationsView.getType()).thenReturn("ADLS_GEN_2");
    TemplatePreparationObject tpo = new Builder().withCloudPlatform(CloudPlatform.AZURE).withFileSystemConfigurationView(fileSystemConfigurationsView).withAccountMappingView(new AccountMappingView(GROUP_MAPPINGS, USER_MAPPINGS)).withProductDetails(generateCMRepo(CMRepositoryVersionUtil.CLOUDERAMANAGER_VERSION_6_3_0), null).build();
    List<ApiClusterTemplateConfig> result = underTest.getRoleConfigs(IDBROKER, tpo);
    Map<String, String> configNameToValueMap = getConfigNameToValueMap(result);
    assertThat(configNameToValueMap).containsOnly(Map.entry(IDBROKER_AZURE_USER_MAPPING, USER_MAPPINGS_STR), Map.entry(IDBROKER_AZURE_GROUP_MAPPING, GROUP_MAPPINGS_STR));
    Map<String, String> configNameToVariableNameMap = getConfigNameToVariableNameMap(result);
    assertThat(configNameToVariableNameMap).isEmpty();
}
Also used : TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) BaseFileSystemConfigurationsView(com.sequenceiq.cloudbreak.template.filesystem.BaseFileSystemConfigurationsView) Builder(com.sequenceiq.cloudbreak.template.TemplatePreparationObject.Builder) ApiClusterTemplateConfig(com.cloudera.api.swagger.model.ApiClusterTemplateConfig) AccountMappingView(com.sequenceiq.cloudbreak.template.views.AccountMappingView) Test(org.junit.Test)

Aggregations

TemplatePreparationObject (com.sequenceiq.cloudbreak.template.TemplatePreparationObject)266 Test (org.junit.Test)133 ApiClusterTemplateConfig (com.cloudera.api.swagger.model.ApiClusterTemplateConfig)127 CmTemplateProcessor (com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor)116 Test (org.junit.jupiter.api.Test)87 GeneralClusterConfigs (com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs)53 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)48 List (java.util.List)45 ClouderaManagerRepo (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo)40 HostgroupView (com.sequenceiq.cloudbreak.template.views.HostgroupView)38 Builder (com.sequenceiq.cloudbreak.template.TemplatePreparationObject.Builder)36 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)35 ArrayList (java.util.ArrayList)34 BlueprintView (com.sequenceiq.cloudbreak.template.views.BlueprintView)32 ApiClusterTemplateService (com.cloudera.api.swagger.model.ApiClusterTemplateService)27 MethodSource (org.junit.jupiter.params.provider.MethodSource)23 BaseFileSystemConfigurationsView (com.sequenceiq.cloudbreak.template.filesystem.BaseFileSystemConfigurationsView)20 AccountMappingView (com.sequenceiq.cloudbreak.template.views.AccountMappingView)17 RDSConfig (com.sequenceiq.cloudbreak.domain.RDSConfig)16 DisplayName (org.junit.jupiter.api.DisplayName)16