use of com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.ExposedServices in project cloudbreak by hortonworks.
the class GatewayTopologyV4RequestToGatewayTopologyConverter method convertExposedServices.
private void convertExposedServices(GatewayTopology gatewayTopology, GatewayTopologyV4Request source) {
try {
if (!CollectionUtils.isEmpty(source.getExposedServices())) {
ExposedServices exposedServices = gatewayTopologyV4RequestToExposedServicesConverter.convert(source);
gatewayTopology.setExposedServices(new Json(exposedServices));
}
} catch (IllegalArgumentException e) {
throw new BadRequestException("Invalid exposedServices in request. Could not be parsed to JSON.", e);
}
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.ExposedServices 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()));
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.ExposedServices 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());
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.ExposedServices 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));
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.ExposedServices in project cloudbreak by hortonworks.
the class GatewayViewTest method gatewayTopology.
private GatewayTopology gatewayTopology(String... services) {
GatewayTopology gatewayTopology = new GatewayTopology();
gatewayTopology.setTopologyName("topology");
ExposedServices exposedServices = new ExposedServices();
exposedServices.setServices(List.of(services));
gatewayTopology.setExposedServices(Json.silent(exposedServices));
return gatewayTopology;
}
Aggregations