Search in sources :

Example 81 with ClouderaManagerRepo

use of com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo in project cloudbreak by hortonworks.

the class KnoxGatewayConfigProviderTest method roleConfigsWithGatewayWithLdapConfigWhenOdbcEntitlementFalse.

@Test
public void roleConfigsWithGatewayWithLdapConfigWhenOdbcEntitlementFalse() {
    Gateway gateway = new Gateway();
    gateway.setKnoxMasterSecret("admin");
    gateway.setPath("/a/b/c");
    IdBroker idBroker = new IdBroker();
    idBroker.setMasterSecret("supersecret");
    BlueprintTextProcessor blueprintTextProcessor = mock(BlueprintTextProcessor.class);
    LdapView ldapConfig = LdapViewBuilder.aLdapView().build();
    BlueprintView blueprintView = new BlueprintView("text", "7.2.11", "CDH", blueprintTextProcessor);
    GeneralClusterConfigs generalClusterConfigs = new GeneralClusterConfigs();
    generalClusterConfigs.setAccountId(Optional.of("1234"));
    TemplatePreparationObject source = Builder.builder().withGateway(gateway, "key", new HashSet<>()).withLdapConfig(ldapConfig).withGeneralClusterConfigs(generalClusterConfigs).withBlueprintView(blueprintView).withVirtualGroupView(new VirtualGroupRequest(TestConstants.CRN, "")).withProductDetails(new ClouderaManagerRepo().withVersion("7.4.2"), List.of(new ClouderaManagerProduct().withVersion("7.2.10").withName("CDH"))).withIdBroker(idBroker).build();
    when(virtualGroupService.createOrGetVirtualGroup(source.getVirtualGroupRequest(), UmsVirtualGroupRight.KNOX_ADMIN)).thenReturn("knox_admins");
    when(entitlementService.isOjdbcTokenDhOneHour(anyString())).thenReturn(false);
    assertEquals(List.of(config("idbroker_master_secret", "supersecret"), config("idbroker_gateway_knox_admin_groups", "knox_admins"), config("idbroker_gateway_signing_keystore_name", "signing.jks"), config("idbroker_gateway_signing_keystore_type", "JKS"), config("idbroker_gateway_signing_key_alias", "signing-identity")), underTest.getRoleConfigs(KnoxRoles.IDBROKER, source));
    assertEquals(List.of(config("gateway_master_secret", gateway.getKnoxMasterSecret()), config("gateway_default_topology_name", "cdp-proxy"), config("gateway_knox_admin_groups", "knox_admins"), config("gateway_auto_discovery_enabled", "false"), config("gateway_path", gateway.getPath()), config("gateway_signing_keystore_name", "signing.jks"), config("gateway_signing_keystore_type", "JKS"), config("gateway_signing_key_alias", "signing-identity"), config("gateway_dispatch_whitelist", "^*.*$"), config("gateway_token_generation_enable_lifespan_input", "true"), config("gateway_token_generation_knox_token_ttl", "86400000"), config("gateway_service_tokenstate_impl", "org.apache.knox.gateway.services.token.impl.JDBCTokenStateService")), ThreadBasedUserCrnProvider.doAs(TEST_USER_CRN, () -> underTest.getRoleConfigs(KnoxRoles.KNOX_GATEWAY, source)));
    assertEquals(List.of(), underTest.getRoleConfigs("NAMENODE", source));
}
Also used : TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) GeneralClusterConfigs(com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs) VirtualGroupRequest(com.sequenceiq.cloudbreak.auth.altus.VirtualGroupRequest) Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) BlueprintTextProcessor(com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor) BlueprintView(com.sequenceiq.cloudbreak.template.views.BlueprintView) ClouderaManagerProduct(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct) IdBroker(com.sequenceiq.cloudbreak.domain.stack.cluster.IdBroker) LdapView(com.sequenceiq.cloudbreak.dto.LdapView) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 82 with ClouderaManagerRepo

use of com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo in project cloudbreak by hortonworks.

the class KnoxServiceConfigProviderTest method testGetServiceConfigsWhenCMAtLeast741AndCDHVersion7291ShouldIncludeDBProperties.

@ParameterizedTest(name = "{index}: check knox properties cm version {0} and cdh version {1} will produce {2} property")
@MethodSource("cmCdhCombinations")
public void testGetServiceConfigsWhenCMAtLeast741AndCDHVersion7291ShouldIncludeDBProperties(String cdhVersion, String cmVersion, int numberOfProperties) {
    CmTemplateProcessor templateProcessor = mock(CmTemplateProcessor.class);
    BlueprintTextProcessor blueprintTextProcessor = mock(BlueprintTextProcessor.class);
    BlueprintView blueprintView = new BlueprintView("text", cdhVersion, "CDH", blueprintTextProcessor);
    RDSConfig rdsConfig = new RDSConfig();
    rdsConfig.setConnectionPassword("pw");
    rdsConfig.setConnectionUserName("usr");
    rdsConfig.setType(DatabaseType.KNOX_GATEWAY.name());
    rdsConfig.setConnectionURL("jdbc:postgresql://somehost.com:5432/dbName");
    TemplatePreparationObject source = TemplatePreparationObject.Builder.builder().withBlueprintView(blueprintView).withRdsSslCertificateFilePath("file://path").withRdsConfigs(Set.of(rdsConfig)).withProductDetails(new ClouderaManagerRepo().withVersion(cmVersion), List.of(new ClouderaManagerProduct().withVersion(cdhVersion).withName("CDH"))).build();
    when(blueprintTextProcessor.getStackVersion()).thenReturn(cdhVersion);
    List<ApiClusterTemplateConfig> serviceConfigs = underTest.getServiceConfigs(templateProcessor, source);
    Assert.assertTrue(serviceConfigs.size() == numberOfProperties);
}
Also used : TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) BlueprintTextProcessor(com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor) BlueprintView(com.sequenceiq.cloudbreak.template.views.BlueprintView) RDSConfig(com.sequenceiq.cloudbreak.domain.RDSConfig) ClouderaManagerProduct(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct) CmTemplateProcessor(com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor) ApiClusterTemplateConfig(com.cloudera.api.swagger.model.ApiClusterTemplateConfig) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 83 with ClouderaManagerRepo

use of com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo in project cloudbreak by hortonworks.

the class KafkaAuthConfigProviderTest method templatePreparationObject.

private TemplatePreparationObject templatePreparationObject(StackType stackType, String cdhVersion, boolean addLdapView) {
    Builder builder = Builder.builder().withBlueprintView(blueprintView).withLdapConfig(addLdapView ? ldapView() : null).withStackType(stackType);
    if (cdhVersion != null) {
        List<ClouderaManagerProduct> products = KafkaConfigProviderUtilsTest.products("CDH=" + cdhVersion);
        builder.withProductDetails(new ClouderaManagerRepo(), products);
    }
    return builder.build();
}
Also used : ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) Builder(com.sequenceiq.cloudbreak.template.TemplatePreparationObject.Builder) LdapViewBuilder(com.sequenceiq.cloudbreak.dto.LdapView.LdapViewBuilder) ClouderaManagerProduct(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct)

Example 84 with ClouderaManagerRepo

use of com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo in project cloudbreak by hortonworks.

the class KafkaDatahubConfigProviderTest method templatePreparationObject.

private TemplatePreparationObject templatePreparationObject(StackType stackType, String cdhVersion) {
    TemplatePreparationObject.Builder builder = TemplatePreparationObject.Builder.builder().withBlueprintView(blueprintView).withStackType(stackType);
    if (cdhVersion != null) {
        List<ClouderaManagerProduct> products = KafkaConfigProviderUtilsTest.products("CDH=" + cdhVersion);
        builder.withProductDetails(new ClouderaManagerRepo(), products);
    }
    return builder.build();
}
Also used : TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) ClouderaManagerProduct(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct)

Example 85 with ClouderaManagerRepo

use of com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo in project cloudbreak by hortonworks.

the class KafkaMultiAzConfigProviderTest method templatePreparationObject.

private TemplatePreparationObject templatePreparationObject(StackType stackType, String cdhVersion) {
    GeneralClusterConfigs configs = new GeneralClusterConfigs();
    configs.setMultiAzEnabled(true);
    TemplatePreparationObject.Builder builder = TemplatePreparationObject.Builder.builder().withBlueprintView(blueprintView).withStackType(stackType).withGeneralClusterConfigs(configs);
    if (cdhVersion != null) {
        List<ClouderaManagerProduct> products = KafkaConfigProviderUtilsTest.products("CDH=" + cdhVersion);
        builder.withProductDetails(new ClouderaManagerRepo(), products);
    }
    return builder.build();
}
Also used : TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) GeneralClusterConfigs(com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs) ClouderaManagerProduct(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct)

Aggregations

ClouderaManagerRepo (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo)96 TemplatePreparationObject (com.sequenceiq.cloudbreak.template.TemplatePreparationObject)40 Test (org.junit.jupiter.api.Test)38 GeneralClusterConfigs (com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs)28 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)20 ApiClusterTemplateConfig (com.cloudera.api.swagger.model.ApiClusterTemplateConfig)17 ApiClient (com.cloudera.api.swagger.client.ApiClient)15 ApiClusterTemplateService (com.cloudera.api.swagger.model.ApiClusterTemplateService)15 HostgroupView (com.sequenceiq.cloudbreak.template.views.HostgroupView)15 Test (org.junit.Test)15 ClouderaManagerProduct (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct)14 DisplayName (org.junit.jupiter.api.DisplayName)14 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)13 MethodSource (org.junit.jupiter.params.provider.MethodSource)13 ArrayList (java.util.ArrayList)12 HashMap (java.util.HashMap)12 Map (java.util.Map)10 CmTemplateProcessor (com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor)9 BigDecimal (java.math.BigDecimal)9 VirtualGroupRequest (com.sequenceiq.cloudbreak.auth.altus.VirtualGroupRequest)8