use of com.sequenceiq.cloudbreak.template.views.BlueprintView 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));
}
use of com.sequenceiq.cloudbreak.template.views.BlueprintView 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);
}
use of com.sequenceiq.cloudbreak.template.views.BlueprintView in project cloudbreak by hortonworks.
the class KuduVolumeConfigProviderTest method getTemplatePreparationObject.
private TemplatePreparationObject getTemplatePreparationObject(HostgroupView hostGroup) {
String inputJson = FileReaderUtils.readFileFromClasspathQuietly("input/cdp-data-mart.bp");
TemplatePreparationObject preparationObject = TemplatePreparationObject.Builder.builder().withHostgroupViews(Set.of(hostGroup)).withBlueprintView(new BlueprintView(inputJson, "CDP", "1.0", new CmTemplateProcessor(inputJson))).build();
return preparationObject;
}
use of com.sequenceiq.cloudbreak.template.views.BlueprintView in project cloudbreak by hortonworks.
the class NifiRegistryRoleConfigProviderTest method getTemplatePreparationObject.
private TemplatePreparationObject getTemplatePreparationObject(CmTemplateProcessor cmTemplateProcessor) {
HostgroupView master = new HostgroupView("master", 1, InstanceGroupType.GATEWAY, 1);
HostgroupView worker = new HostgroupView("worker", 2, InstanceGroupType.CORE, 3);
BlueprintView blueprintView = new BlueprintView(null, null, null, cmTemplateProcessor);
RDSConfig rdsConfig = new RDSConfig();
rdsConfig.setType(DatabaseType.NIFIREGISTRY.toString());
rdsConfig.setDatabaseEngine(DatabaseVendor.POSTGRES);
rdsConfig.setConnectionDriver(DatabaseVendor.POSTGRES.connectionDriver());
rdsConfig.setConnectionURL("jdbc:postgresql://testhost:5432/nifi_registry");
rdsConfig.setConnectionUserName("nifi_registry_server_user");
rdsConfig.setConnectionPassword("nifi_registry_server_password");
return TemplatePreparationObject.Builder.builder().withBlueprintView(blueprintView).withHostgroupViews(Set.of(master, worker)).withRdsConfigs(Set.of(rdsConfig)).build();
}
use of com.sequenceiq.cloudbreak.template.views.BlueprintView in project cloudbreak by hortonworks.
the class HueConfigProviderTest method getServiceConfigVariablesWhenKnoxConfiguredToExternalDomainWhenNoSafetyValve.
@Test
public void getServiceConfigVariablesWhenKnoxConfiguredToExternalDomainWhenNoSafetyValve() {
BlueprintView blueprintView = mock(BlueprintView.class);
when(blueprintView.getVersion()).thenReturn("7.1.0");
CmTemplateProcessor templateProcessor = mock(CmTemplateProcessor.class);
when(templateProcessor.getVersion()).thenReturn(Optional.ofNullable("7.1.0"));
when(blueprintView.getProcessor()).thenReturn(templateProcessor);
RDSConfig rdsConfig = new RDSConfig();
rdsConfig.setType(HUE);
rdsConfig.setConnectionURL(String.format("jdbc:%s://%s:%s/%s", DB_PROVIDER, HOST, PORT, DB_NAME));
rdsConfig.setConnectionUserName(USER_NAME);
rdsConfig.setConnectionPassword(PASSWORD);
String expectedExternalFQDN = "myaddress.cloudera.site";
String expectedInternalFQDN = "private-gateway.cloudera.site";
GeneralClusterConfigs generalClusterConfigs = new GeneralClusterConfigs();
generalClusterConfigs.setExternalFQDN(expectedExternalFQDN);
generalClusterConfigs.setKnoxUserFacingCertConfigured(true);
generalClusterConfigs.setPrimaryGatewayInstanceDiscoveryFQDN(Optional.of(expectedInternalFQDN));
TemplatePreparationObject tpo = new Builder().withGeneralClusterConfigs(generalClusterConfigs).withGateway(new Gateway(), "", new HashSet<>()).withBlueprintView(blueprintView).withRdsConfigs(Set.of(rdsConfig)).build();
List<ApiClusterTemplateVariable> result = underTest.getServiceConfigVariables(tpo);
Map<String, String> paramToVariable = result.stream().collect(Collectors.toMap(ApiClusterTemplateVariable::getName, ApiClusterTemplateVariable::getValue));
String proxyHostsExpected1 = String.join(",", expectedInternalFQDN, expectedExternalFQDN);
String proxyHostsExpected2 = String.join(",", expectedExternalFQDN, expectedInternalFQDN);
assertEquals(7, paramToVariable.size());
assertThat(paramToVariable).contains(new SimpleEntry<>("hue-hue_database_host", HOST), new SimpleEntry<>("hue-hue_database_port", PORT), new SimpleEntry<>("hue-hue_database_name", DB_NAME), new SimpleEntry<>("hue-hue_database_type", DB_PROVIDER), new SimpleEntry<>("hue-hue_database_user", USER_NAME), new SimpleEntry<>("hue-hue_database_password", PASSWORD));
assertThat(paramToVariable).containsAnyOf(new SimpleEntry<>("hue-knox_proxyhosts", proxyHostsExpected1), new SimpleEntry<>("hue-knox_proxyhosts", proxyHostsExpected2));
}
Aggregations