Skip to content

Commit 4e161e3

Browse files
committed
get rid of the backend service
1 parent e890053 commit 4e161e3

12 files changed

+158
-282
lines changed

settings.gradle.kts

-1
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,6 @@ include(":spi:policy-monitor:policy-monitor-spi")
267267
include(":tests:junit-base")
268268

269269
// modules for system tests ------------------------------------------------------------------------
270-
include(":system-tests:e2e-transfer-test:backend-service")
271270
include(":system-tests:e2e-transfer-test:control-plane")
272271
include(":system-tests:e2e-transfer-test:data-plane")
273272
include(":system-tests:e2e-transfer-test:runner")

system-tests/e2e-transfer-test/README.md

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ This tests verifies some complete scenarios of contract negotiation and data tra
44

55
## Modules detail
66

7-
* [backend-service](./backend-service): it represents an external application that interacts with the EDC.
87
* [control-plane](./control-plane): it's responsible for handling the contract negotiation phase using in-memory persistence
98
* [data-plane](./data-plane): it handles the data transfer phase acting as a proxy
109
* [runner](./runner): it contains the test implementation

system-tests/e2e-transfer-test/backend-service/src/main/java/org/eclipse/edc/test/e2e/BackendServiceTestExtension.java

-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ public void initialize(ServiceExtensionContext context) {
4343
var exposedHttpPort = context.getConfig().getInteger("web.http.port");
4444
webService.registerResource(new ProviderBackendApiController());
4545
webService.registerResource(new ConsumerBackendServiceController(context.getMonitor()));
46-
webService.registerResource(new BackendServiceHttpProvisionerController(context.getMonitor(), httpClient, typeManager, exposedHttpPort));
47-
webService.registerResource(new Oauth2TokenController(context.getMonitor()));
4846
webService.registerResource(new EdcApiExceptionMapper());
4947
}
5048
}

system-tests/e2e-transfer-test/backend-service/src/main/java/org/eclipse/edc/test/e2e/Oauth2TokenController.java

-78
This file was deleted.

system-tests/e2e-transfer-test/backend-service/src/main/java/org/eclipse/edc/test/e2e/ProviderBackendApiController.java

-29
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,13 @@
1414

1515
package org.eclipse.edc.test.e2e;
1616

17-
import com.nimbusds.jwt.SignedJWT;
1817
import jakarta.ws.rs.DefaultValue;
1918
import jakarta.ws.rs.GET;
20-
import jakarta.ws.rs.HeaderParam;
2119
import jakarta.ws.rs.Path;
2220
import jakarta.ws.rs.Produces;
2321
import jakarta.ws.rs.QueryParam;
2422
import jakarta.ws.rs.core.MediaType;
25-
import org.eclipse.edc.web.spi.exception.NotAuthorizedException;
2623

27-
import java.text.ParseException;
2824
import java.util.Map;
2925

3026
@Path("/provider")
@@ -37,29 +33,4 @@ public Map<String, String> getData(@DefaultValue("some information") @QueryParam
3733
return Map.of("message", message);
3834
}
3935

40-
@Path("/oauth2data")
41-
@GET
42-
@Produces(MediaType.APPLICATION_JSON)
43-
public Map<String, String> getOauth2Data(@DefaultValue("some information") @QueryParam("message") String message, @HeaderParam("Authorization") String authorization) {
44-
if (authorization == null || !isAuthorized(authorization)) {
45-
throw new NotAuthorizedException("The authorization token is not valid: " + authorization);
46-
} else {
47-
return Map.of("message", message);
48-
}
49-
}
50-
51-
private boolean isAuthorized(String authorization) {
52-
if (!authorization.startsWith("Bearer ")) {
53-
return false;
54-
}
55-
56-
var token = authorization.replace("Bearer ", "");
57-
58-
try {
59-
SignedJWT.parse(token);
60-
return true;
61-
} catch (ParseException e) {
62-
return false;
63-
}
64-
}
6536
}

system-tests/e2e-transfer-test/control-plane/build.gradle.kts

-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ dependencies {
3939
implementation(project(":extensions:data-plane-selector:data-plane-selector-control-api"))
4040

4141
implementation(project(":extensions:control-plane:provision:provision-http"))
42-
implementation(project(":extensions:control-plane:transfer:transfer-pull-http-receiver"))
4342
implementation(project(":extensions:control-plane:transfer:transfer-pull-http-dynamic-receiver"))
4443

4544
implementation(project(":core:policy-monitor:policy-monitor-core"))

system-tests/e2e-transfer-test/runner/build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ dependencies {
2424
testImplementation(project(":spi:common:web-spi"))
2525
testImplementation(project(":core:common:connector-core"))
2626
testImplementation(project(":core:common:junit"))
27+
testImplementation(testFixtures(project(":core:common:lib:http-lib")))
2728
testImplementation(testFixtures(project(":extensions:common:sql:sql-core")))
2829
testImplementation(testFixtures(project(":extensions:control-plane:api:management-api:management-api-test-fixtures")))
2930
testImplementation(project(":extensions:common:json-ld"))
@@ -39,7 +40,6 @@ dependencies {
3940
testImplementation(libs.testcontainers.junit)
4041
testImplementation(libs.testcontainers.kafka)
4142

42-
testCompileOnly(project(":system-tests:e2e-transfer-test:backend-service"))
4343
testCompileOnly(project(":system-tests:e2e-transfer-test:control-plane"))
4444
testCompileOnly(project(":system-tests:e2e-transfer-test:data-plane"))
4545
}

system-tests/e2e-transfer-test/runner/src/test/java/org/eclipse/edc/test/e2e/Runtimes.java

-4
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@
2727
*/
2828
public enum Runtimes {
2929

30-
BACKEND_SERVICE(
31-
":system-tests:e2e-transfer-test:backend-service"
32-
),
33-
3430
IN_MEMORY_CONTROL_PLANE(
3531
":system-tests:e2e-transfer-test:control-plane",
3632
":extensions:data-plane:data-plane-signaling:data-plane-signaling-client"

system-tests/e2e-transfer-test/runner/src/test/java/org/eclipse/edc/test/e2e/TransferEndToEndParticipant.java

+12-30
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@
1616

1717
import io.restassured.common.mapper.TypeRef;
1818
import jakarta.json.Json;
19-
import jakarta.json.JsonObject;
19+
import org.assertj.core.api.ThrowingConsumer;
2020
import org.eclipse.edc.connector.controlplane.test.system.utils.Participant;
2121
import org.eclipse.edc.spi.types.domain.DataAddress;
22-
import org.hamcrest.Matcher;
2322
import org.jetbrains.annotations.NotNull;
2423

2524
import java.net.URI;
@@ -33,6 +32,7 @@
3332
import static jakarta.json.Json.createArrayBuilder;
3433
import static jakarta.json.Json.createObjectBuilder;
3534
import static java.io.File.separator;
35+
import static org.assertj.core.api.Assertions.assertThat;
3636
import static org.eclipse.edc.boot.BootServicesExtension.PARTICIPANT_ID;
3737
import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.CONTEXT;
3838
import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.ID;
@@ -48,25 +48,14 @@ public class TransferEndToEndParticipant extends Participant {
4848
private final URI dataPlaneDefault = URI.create("http://localhost:" + getFreePort());
4949
private final URI dataPlaneControl = URI.create("http://localhost:" + getFreePort() + "/control");
5050
private final URI dataPlanePublic = URI.create("http://localhost:" + getFreePort() + "/public");
51-
private final URI backendService = URI.create("http://localhost:" + getFreePort());
51+
private final int httpProvisionerPort = getFreePort();
5252

5353
protected TransferEndToEndParticipant() {
5454
super();
5555
}
5656

57-
/**
58-
* Get private properties to configure a dynamic http receiver for EDR.
59-
*
60-
* @return the receiver properties.
61-
*/
62-
public JsonObject dynamicReceiverPrivateProperties() {
63-
return Json.createObjectBuilder()
64-
.add("receiverHttpEndpoint", backendService + "/api/consumer/dataReference")
65-
.build();
66-
}
67-
68-
public URI backendService() {
69-
return backendService;
57+
public int getHttpProvisionerPort() {
58+
return httpProvisionerPort;
7059
}
7160

7261
/**
@@ -125,7 +114,6 @@ public Map<String, String> controlPlaneConfiguration() {
125114
put("edc.vault", resourceAbsolutePath(getName() + "-vault.properties"));
126115
put("edc.keystore", resourceAbsolutePath("certs/cert.pfx"));
127116
put("edc.keystore.password", "123456");
128-
put("edc.receiver.http.endpoint", backendService + "/api/consumer/dataReference");
129117
put("edc.transfer.proxy.endpoint", dataPlanePublic.toString());
130118
put("edc.transfer.send.retry.limit", "1");
131119
put("edc.transfer.send.retry.base-delay.ms", "100");
@@ -135,7 +123,7 @@ public Map<String, String> controlPlaneConfiguration() {
135123
put("edc.negotiation.provider.send.retry.base-delay.ms", "100");
136124

137125
put("provisioner.http.entries.default.provisioner.type", "provider");
138-
put("provisioner.http.entries.default.endpoint", backendService + "/api/provision");
126+
put("provisioner.http.entries.default.endpoint", "http://localhost:%d/provision".formatted(httpProvisionerPort));
139127
put("provisioner.http.entries.default.data.address.type", "HttpProvision");
140128
}
141129
};
@@ -181,14 +169,6 @@ public Map<String, String> dataPlanePostgresConfiguration() {
181169
return baseConfiguration;
182170
}
183171

184-
public Map<String, String> backendServiceConfiguration() {
185-
return new HashMap<>() {
186-
{
187-
put("web.http.port", String.valueOf(backendService.getPort()));
188-
}
189-
};
190-
}
191-
192172
/**
193173
* Get the EDR from the EDR cache by transfer process id.
194174
*
@@ -219,10 +199,10 @@ public DataAddress getEdr(String transferProcessId) {
219199
*
220200
* @param edr endpoint data reference
221201
* @param queryParams query parameters
222-
* @param bodyMatcher matcher for response body
202+
* @param bodyAssertion assertion to be verified on the body
223203
*/
224-
public void pullData(DataAddress edr, Map<String, String> queryParams, Matcher<String> bodyMatcher) {
225-
given()
204+
public void pullData(DataAddress edr, Map<String, String> queryParams, ThrowingConsumer<String> bodyAssertion) {
205+
var data = given()
226206
.baseUri(edr.getStringProperty("endpoint"))
227207
.header("Authorization", edr.getStringProperty("authorization"))
228208
.queryParams(queryParams)
@@ -231,7 +211,9 @@ public void pullData(DataAddress edr, Map<String, String> queryParams, Matcher<S
231211
.then()
232212
.log().ifError()
233213
.statusCode(200)
234-
.body("message", bodyMatcher);
214+
.extract().body().asString();
215+
216+
assertThat(data).satisfies(bodyAssertion);
235217
}
236218

237219
@NotNull

0 commit comments

Comments
 (0)