-
Notifications
You must be signed in to change notification settings - Fork 252
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: remove data-plane-public-v2 deprecated module from dataplan…
…e-base-bom
- Loading branch information
Showing
9 changed files
with
117 additions
and
282 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
236 changes: 0 additions & 236 deletions
236
...ne-tests/tests/src/test/java/org/eclipse/edc/test/e2e/DataPlanePublicApiEndToEndTest.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
...nsfer-test/runner/src/test/java/org/eclipse/edc/test/e2e/HttpProxyDataPlaneExtension.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} |
Oops, something went wrong.