Search in sources :

Example 1 with GatewayTopology

use of com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.GatewayTopology in project cloudbreak by hortonworks.

the class ClusterHostServiceRunner method getTopologies.

private List<Map<String, Object>> getTopologies(Gateway clusterGateway, String version) throws IOException {
    if (!CollectionUtils.isEmpty(clusterGateway.getTopologies())) {
        List<Map<String, Object>> topologyMaps = new ArrayList<>();
        for (GatewayTopology topology : clusterGateway.getTopologies()) {
            Map<String, Object> topologyAndExposed = mapTopologyToMap(topology, Optional.ofNullable(version));
            topologyMaps.add(topologyAndExposed);
        }
        return topologyMaps;
    }
    return Collections.emptyList();
}
Also used : ArrayList(java.util.ArrayList) GatewayTopology(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.GatewayTopology) Map(java.util.Map) ServiceLocationMap(com.sequenceiq.cloudbreak.cluster.model.ServiceLocationMap) HashMap(java.util.HashMap) Collections.singletonMap(java.util.Collections.singletonMap)

Example 2 with GatewayTopology

use of com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.GatewayTopology in project cloudbreak by hortonworks.

the class GatewayTopologyV4RequestToGatewayTopologyConverterTest method testConvert.

@Test
public void testConvert() throws IOException {
    GatewayTopologyV4Request gatewayTopologyJson = new GatewayTopologyV4Request();
    gatewayTopologyJson.setTopologyName(TOPOLOGY_NAME);
    List<String> allServices = Collections.singletonList("ALL");
    ExposedServices exposedServices = new ExposedServices();
    exposedServices.setServices(allServices);
    gatewayTopologyJson.setExposedServices(allServices);
    when(gatewayTopologyV4RequestValidator.validate(any(GatewayTopologyV4Request.class))).thenReturn(new ValidationResultBuilder().build());
    when(gatewayTopologyV4RequestToExposedServicesConverter.convert(any(GatewayTopologyV4Request.class))).thenReturn(exposedServices);
    GatewayTopology result = underTest.convert(gatewayTopologyJson);
    assertEquals(TOPOLOGY_NAME, result.getTopologyName());
    assertTrue(result.getExposedServices().get(ExposedServices.class).getServices().contains("ALL"));
// assertTrue(result.getExposedServices().get(ExposedServices.class).getFullServiceList().containsAll(ExposedService.getAllKnoxExposed()));
}
Also used : ValidationResultBuilder(com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder) GatewayTopologyV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.topology.GatewayTopologyV4Request) ExposedServices(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.ExposedServices) GatewayTopology(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.GatewayTopology) Test(org.junit.Test)

Example 3 with GatewayTopology

use of com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.GatewayTopology in project cloudbreak by hortonworks.

the class GatewayTopologyToGatewayTopologyV4ResponseConverterTest method testConvertWithNoServicesAndException.

@Test
public void testConvertWithNoServicesAndException() throws IOException {
    GatewayTopology source = mock(GatewayTopology.class);
    when(source.getTopologyName()).thenReturn(TOPOLOGY);
    Json json = mock(Json.class);
    when(source.getExposedServices()).thenReturn(json);
    when(json.getValue()).thenReturn("{}");
    when(json.get(ExposedServices.class)).thenThrow(new IOException("Foo"));
    GatewayTopologyV4Response result = underTest.convert(source);
    assertNotNull(result);
    assertEquals(TOPOLOGY, result.getTopologyName());
    assertNull(result.getExposedServices());
}
Also used : GatewayTopology(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.GatewayTopology) Json(com.sequenceiq.cloudbreak.common.json.Json) IOException(java.io.IOException) GatewayTopologyV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.gateway.topology.GatewayTopologyV4Response) Test(org.junit.Test)

Example 4 with GatewayTopology

use of com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.GatewayTopology in project cloudbreak by hortonworks.

the class GatewayTopologyToGatewayTopologyV4ResponseConverterTest method testConvertWithSomeServices.

@Test
public void testConvertWithSomeServices() throws IOException {
    GatewayTopology source = mock(GatewayTopology.class);
    when(source.getTopologyName()).thenReturn(TOPOLOGY);
    ExposedServices exposedServices = mock(ExposedServices.class);
    List<String> services = List.of("SERVICE1", "SERVICE2");
    when(exposedServices.getServices()).thenReturn(services);
    Json json = mock(Json.class);
    when(source.getExposedServices()).thenReturn(json);
    when(json.getValue()).thenReturn("{}");
    when(json.get(ExposedServices.class)).thenReturn(exposedServices);
    GatewayTopologyV4Response result = underTest.convert(source);
    assertNotNull(result);
    assertEquals(TOPOLOGY, result.getTopologyName());
    assertEquals(services, result.getExposedServices());
}
Also used : ExposedServices(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.ExposedServices) GatewayTopology(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.GatewayTopology) Json(com.sequenceiq.cloudbreak.common.json.Json) GatewayTopologyV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.gateway.topology.GatewayTopologyV4Response) Test(org.junit.Test)

Example 5 with GatewayTopology

use of com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.GatewayTopology in project cloudbreak by hortonworks.

the class KnoxGatewayConfigProviderTest method roleConfigsWithGateway.

@Test
public void roleConfigsWithGateway() {
    GatewayTopology topology = new GatewayTopology();
    topology.setTopologyName("my-topology");
    topology.setExposedServices(Json.silent(new ExposedServices()));
    Gateway gateway = new Gateway();
    gateway.setKnoxMasterSecret("admin");
    gateway.setPath("/a/b/c");
    gateway.setTopologies(Set.of(topology));
    GeneralClusterConfigs generalClusterConfigs = new GeneralClusterConfigs();
    generalClusterConfigs.setAccountId(Optional.of("1234"));
    IdBroker idBroker = new IdBroker();
    idBroker.setMasterSecret("supersecret");
    BlueprintTextProcessor blueprintTextProcessor = mock(BlueprintTextProcessor.class);
    BlueprintView blueprintView = new BlueprintView("text", "7.2.11", "CDH", blueprintTextProcessor);
    TemplatePreparationObject source = Builder.builder().withGateway(gateway, "key", new HashSet<>()).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("");
    when(entitlementService.isOjdbcTokenDhOneHour(anyString())).thenReturn(true);
    assertEquals(List.of(config("idbroker_master_secret", "supersecret"), config("idbroker_gateway_knox_admin_groups", ""), 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", gateway.getTopologies().iterator().next().getTopologyName()), config("gateway_knox_admin_groups", ""), 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_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) ExposedServices(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.ExposedServices) ClouderaManagerProduct(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct) GatewayTopology(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.GatewayTopology) IdBroker(com.sequenceiq.cloudbreak.domain.stack.cluster.IdBroker) Test(org.junit.Test)

Aggregations

GatewayTopology (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.GatewayTopology)23 Test (org.junit.Test)11 ExposedServices (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.ExposedServices)9 Json (com.sequenceiq.cloudbreak.common.json.Json)7 Gateway (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway)7 GatewayTopologyV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.topology.GatewayTopologyV4Request)5 GatewayTopologyV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.gateway.topology.GatewayTopologyV4Response)3 ExposedService (com.sequenceiq.cloudbreak.api.service.ExposedService)3 BlueprintTextProcessor (com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor)3 GatewayV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.GatewayV4Request)2 VirtualGroupRequest (com.sequenceiq.cloudbreak.auth.altus.VirtualGroupRequest)2 ClouderaManagerProduct (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct)2 ClouderaManagerRepo (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo)2 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)2 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)2 IdBroker (com.sequenceiq.cloudbreak.domain.stack.cluster.IdBroker)2 TemplatePreparationObject (com.sequenceiq.cloudbreak.template.TemplatePreparationObject)2 GeneralClusterConfigs (com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs)2 BlueprintView (com.sequenceiq.cloudbreak.template.views.BlueprintView)2 Tenant (com.sequenceiq.cloudbreak.workspace.model.Tenant)2