Skip to content

Commit

Permalink
refactor: remove data-plane-public-v2 deprecated module from dataplan…
Browse files Browse the repository at this point in the history
…e-base-bom
  • Loading branch information
ndr-brt committed Feb 25, 2025
1 parent a69e955 commit 0fadff3
Show file tree
Hide file tree
Showing 9 changed files with 117 additions and 282 deletions.
1 change: 0 additions & 1 deletion dist/bom/dataplane-base-bom/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ dependencies {
api(project(":extensions:data-plane:data-plane-self-registration"))
api(project(":extensions:data-plane:data-plane-http"))
api(project(":extensions:data-plane:data-plane-http-oauth2"))
api(project(":extensions:data-plane:data-plane-public-api-v2"))
api(project(":extensions:data-plane:data-plane-signaling:data-plane-signaling-api"))
api(project(":extensions:data-plane:data-plane-iam"))
api(project(":extensions:data-plane-selector:data-plane-selector-client"))
Expand Down
1 change: 0 additions & 1 deletion resources/openapi/sts-accounts-api.version

This file was deleted.

1 change: 0 additions & 1 deletion resources/openapi/sts-api.version

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import org.eclipse.edc.connector.api.signaling.transform.to.JsonObjectToDataFlowResponseMessageTransformer;
import org.eclipse.edc.connector.dataplane.spi.DataFlow;
import org.eclipse.edc.connector.dataplane.spi.DataFlowStates;
import org.eclipse.edc.connector.dataplane.spi.Endpoint;
import org.eclipse.edc.connector.dataplane.spi.iam.PublicEndpointGeneratorService;
import org.eclipse.edc.connector.dataplane.spi.store.DataPlaneStore;
import org.eclipse.edc.jsonld.spi.JsonLd;
import org.eclipse.edc.jsonld.util.JacksonJsonLd;
Expand Down Expand Up @@ -62,7 +64,7 @@
@EndToEndTest
public class DataPlaneSignalingApiEndToEndTest extends AbstractDataPlaneTest {

private static final String DATAPLANE_PUBLIC_ENDPOINT_URL = DATAPLANE.publicEndpointUrl();
private static final String DATAPLANE_PUBLIC_ENDPOINT_URL = "http://public/endpoint";
private final TypeTransformerRegistry registry = new TypeTransformerRegistryImpl();
private final TypeManager typeManager = mock();
private ObjectMapper mapper;
Expand All @@ -76,6 +78,10 @@ void setup() {
registry.register(new JsonObjectToDataAddressDspaceTransformer());
registry.register(new JsonObjectToDataFlowResponseMessageTransformer());
when(typeManager.getMapper("test")).thenReturn(mapper);
runtime.getService(PublicEndpointGeneratorService.class)
.addGeneratorFunction("HttpData", address -> Endpoint.url(DATAPLANE_PUBLIC_ENDPOINT_URL));
runtime.getService(PublicEndpointGeneratorService.class)
.addGeneratorFunction("HttpData", () -> Endpoint.url(DATAPLANE_PUBLIC_ENDPOINT_URL + "/responseChannel"));
}

@DisplayName("Verify the POST /v1/dataflows endpoint returns the correct EDR (PULL)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,6 @@ public RequestSpecification baseControlRequest() {
return given().baseUri(dataPlaneControl.get().toString());
}

public RequestSpecification basePublicRequest() {
return given().baseUri(dataPlanePublic.get().toString());
}

public String publicEndpointUrl() {
return dataPlanePublic.get().toString();
}

public Config dataPlaneConfig() {
return ConfigFactory.fromMap(dataPlaneConfiguration());
}
Expand All @@ -62,8 +54,6 @@ public Map<String, String> dataPlaneConfiguration() {
put("edc.component.id", UUID.randomUUID().toString());
put("web.http.port", String.valueOf(getFreePort()));
put("web.http.path", "/api");
put("web.http.public.port", String.valueOf(dataPlanePublic.get().getPort()));
put("web.http.public.path", "/public");
put("web.http.control.port", String.valueOf(dataPlaneControl.get().getPort()));
put("web.http.control.path", dataPlaneControl.get().getPath());
put("edc.keystore", resourceAbsolutePath("certs/cert.pfx"));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/*
* Copyright (c) 2025 Cofinity-X
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* Cofinity-X - initial API and implementation
*
*/

package org.eclipse.edc.test.e2e;

import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.container.ContainerRequestContext;
import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.core.HttpHeaders;
import jakarta.ws.rs.core.Response;
import org.eclipse.edc.connector.dataplane.spi.Endpoint;
import org.eclipse.edc.connector.dataplane.spi.iam.DataPlaneAuthorizationService;
import org.eclipse.edc.connector.dataplane.spi.iam.PublicEndpointGeneratorService;
import org.eclipse.edc.runtime.metamodel.annotation.Inject;
import org.eclipse.edc.spi.system.ServiceExtension;
import org.eclipse.edc.spi.system.ServiceExtensionContext;
import org.eclipse.edc.web.spi.WebService;
import org.eclipse.edc.web.spi.configuration.PortMapping;
import org.eclipse.edc.web.spi.configuration.PortMappingRegistry;

import static jakarta.ws.rs.core.MediaType.WILDCARD;
import static jakarta.ws.rs.core.Response.Status.FORBIDDEN;
import static jakarta.ws.rs.core.Response.Status.UNAUTHORIZED;
import static java.util.Collections.emptyMap;
import static org.eclipse.edc.util.io.Ports.getFreePort;

/**
* Extension that provides a dummy proxy that always return a hardcoded successful response when the token validation
* succeeds.
*/
public class HttpProxyDataPlaneExtension implements ServiceExtension {

private static final String API_CONTEXT = "proxy";

@Inject
private DataPlaneAuthorizationService authorizationService;
@Inject
private PublicEndpointGeneratorService generatorService;
@Inject
private PortMappingRegistry portMappingRegistry;
@Inject
private WebService webService;

@Override
public void initialize(ServiceExtensionContext context) {
var portMapping = new PortMapping(API_CONTEXT, getFreePort(), "/proxy");
portMappingRegistry.register(portMapping);

var proxyUrl = "http://localhost:%d%s".formatted(portMapping.port(), portMapping.path());
generatorService.addGeneratorFunction("HttpData", address -> Endpoint.url(proxyUrl));

webService.registerResource(API_CONTEXT, new Controller(authorizationService));
}

@Path("{any:.*}")
@Consumes(WILDCARD)
@Produces(WILDCARD)
public static class Controller {

private final DataPlaneAuthorizationService authorizationService;

Controller(DataPlaneAuthorizationService authorizationService) {
this.authorizationService = authorizationService;
}

@GET
public Response get(@Context ContainerRequestContext requestContext) {
var token = requestContext.getHeaderString(HttpHeaders.AUTHORIZATION);
if (token == null) {
return Response.status(UNAUTHORIZED).build();
}

var sourceDataAddress = authorizationService.authorize(token, emptyMap());
if (sourceDataAddress.failed()) {
return Response.status(FORBIDDEN).build();
}

return Response.ok("data").build();
}
}
}
Loading

0 comments on commit 0fadff3

Please sign in to comment.