Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into fix/enable-default-re…
Browse files Browse the repository at this point in the history
…sources-in-helm-charts
  • Loading branch information
florianrusch-zf committed Jun 11, 2024
2 parents e093a74 + b15e13e commit 94383bb
Show file tree
Hide file tree
Showing 40 changed files with 655 additions and 576 deletions.
2 changes: 1 addition & 1 deletion .github/actions/publish-docker-image/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ inputs:
runs:
using: "composite"
steps:
- uses: actions/checkout@v3.3.0
- uses: actions/checkout@v4

- name: Download OpenTelemetry
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/run-deployment-test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ inputs:
runs:
using: "composite"
steps:
- uses: actions/checkout@v3.3.0
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-java

- name: Setup Helm
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/trivy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Run Trivy vulnerability scanner in repo mode
uses: aquasecurity/trivy-action@0.21.0
uses: aquasecurity/trivy-action@0.22.0
with:
scan-type: "config"
# ignore-unfixed: true
Expand Down Expand Up @@ -102,7 +102,7 @@ jobs:
## the next two steps will only execute if the image exists check was successful
- name: Run Trivy vulnerability scanner
if: success() && steps.imageCheck.outcome != 'failure'
uses: aquasecurity/trivy-action@0.21.0
uses: aquasecurity/trivy-action@0.22.0
with:
image-ref: "tractusx/${{ matrix.image }}:sha-${{ needs.git-sha7.outputs.value }}"
format: "sarif"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/verify.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ jobs:
- name: Run E2E tests (${{ matrix.variant.dir }})
run: |
./gradlew compileJava compileTestJava --refresh-dependencies
./gradlew -p ${{ matrix.variant.dir }} test -DincludeTags="EndToEndTest"
./gradlew -p ${{ matrix.variant.dir }} test -DincludeTags="EndToEndTest" -PverboseTest=true
postgres-tests:
runs-on: ubuntu-latest
Expand Down
439 changes: 220 additions & 219 deletions DEPENDENCIES

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -22,61 +22,32 @@
import com.nimbusds.jose.JOSEException;
import com.nimbusds.jose.jwk.Curve;
import com.nimbusds.jose.jwk.gen.ECKeyGenerator;
import org.eclipse.edc.boot.system.injection.InjectionContainer;
import org.eclipse.edc.junit.extensions.EdcRuntimeExtension;
import org.eclipse.edc.junit.extensions.EmbeddedRuntime;
import org.eclipse.edc.junit.extensions.RuntimePerMethodExtension;
import org.eclipse.edc.spi.security.Vault;
import org.eclipse.edc.spi.system.ServiceExtension;
import org.eclipse.edc.spi.system.ServiceExtensionContext;
import org.junit.jupiter.api.extension.AfterAllCallback;
import org.junit.jupiter.api.extension.BeforeAllCallback;
import org.junit.jupiter.api.extension.ExtensionContext;

import java.util.List;
import java.util.Map;

public class ParticipantRuntime extends EdcRuntimeExtension implements BeforeAllCallback, AfterAllCallback {
public class ParticipantRuntime extends RuntimePerMethodExtension {

private final Map<String, String> properties;
private DataWiper wiper;


public ParticipantRuntime(String moduleName, String runtimeName, Map<String, String> properties) {
super(moduleName, runtimeName, properties);
this.properties = properties;
}

public ParticipantRuntime(String runtimeName, Map<String, String> properties, String... modules) {
super(runtimeName, properties, modules);
super(new EmbeddedRuntime(runtimeName, properties, modules));
this.properties = properties;
}


@Override
public void beforeTestExecution(ExtensionContext extensionContext) {
//do nothing - we only want to start the runtime once
wiper.clearPersistence();
registerConsumerPullKeys(properties);
}

@Override
public void afterTestExecution(ExtensionContext context) {
}

@Override
public void beforeAll(ExtensionContext context) throws Exception {
//only run this once
super.beforeTestExecution(context);
}

@Override
public void afterAll(ExtensionContext context) throws Exception {
super.afterTestExecution(context);
}

@Override
protected void bootExtensions(ServiceExtensionContext context, List<InjectionContainer<ServiceExtension>> serviceExtensions) {
super.bootExtensions(context, serviceExtensions);
wiper = new DataWiper(context);
registerConsumerPullKeys(properties);
var wiper = new DataWiper(runtime.getContext());
wiper.clearPersistence();
}

private void registerConsumerPullKeys(Map<String, String> properties) {
Expand All @@ -85,7 +56,7 @@ private void registerConsumerPullKeys(Map<String, String> properties) {
if (privateAlias != null && publicAlias != null) {
try {
var ecKey = new ECKeyGenerator(Curve.P_256).keyID(publicAlias).generate();
var vault = getContext().getService(Vault.class);
var vault = getService(Vault.class);
vault.storeSecret(privateAlias, ecKey.toJSONString());
vault.storeSecret(publicAlias, ecKey.toPublicJWK().toJSONString());
} catch (JOSEException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
public interface Runtimes {

static ParticipantRuntime dimRuntime(String name, Map<String, String> configuration) {
return new ParticipantRuntime(name, configuration,
":edc-tests:runtime:iatp:runtime-memory-iatp-dim"
);
return new ParticipantRuntime(name, configuration, ":edc-tests:runtime:iatp:runtime-memory-iatp-dim");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@

import org.eclipse.edc.junit.annotations.EndToEndTest;
import org.eclipse.edc.junit.annotations.PostgresqlIntegrationTest;
import org.eclipse.edc.junit.extensions.RuntimeExtension;
import org.eclipse.edc.policy.model.Operator;
import org.eclipse.tractusx.edc.tests.participant.TransferParticipant;
import org.eclipse.tractusx.edc.tests.runtimes.ParticipantRuntime;
import org.eclipse.tractusx.edc.tests.runtimes.PgParticipantRuntime;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -213,10 +212,10 @@ void requestCatalog_of1000Assets_shouldContainAll() {
class InMemory extends Tests {

@RegisterExtension
protected static final ParticipantRuntime CONSUMER_RUNTIME = memoryRuntime(CONSUMER.getName(), CONSUMER.getBpn(), CONSUMER.getConfiguration());
protected static final RuntimeExtension CONSUMER_RUNTIME = memoryRuntime(CONSUMER.getName(), CONSUMER.getBpn(), CONSUMER.getConfiguration());

@RegisterExtension
protected static final ParticipantRuntime PROVIDER_RUNTIME = memoryRuntime(PROVIDER.getName(), PROVIDER.getBpn(), PROVIDER.getConfiguration());
protected static final RuntimeExtension PROVIDER_RUNTIME = memoryRuntime(PROVIDER.getName(), PROVIDER.getBpn(), PROVIDER.getConfiguration());

}

Expand All @@ -225,10 +224,10 @@ class InMemory extends Tests {
class Postgres extends Tests {

@RegisterExtension
protected static final PgParticipantRuntime CONSUMER_RUNTIME = pgRuntime(CONSUMER.getName(), CONSUMER.getBpn(), CONSUMER.getConfiguration());
protected static final RuntimeExtension CONSUMER_RUNTIME = pgRuntime(CONSUMER.getName(), CONSUMER.getBpn(), CONSUMER.getConfiguration());

@RegisterExtension
protected static final PgParticipantRuntime PROVIDER_RUNTIME = pgRuntime(PROVIDER.getName(), PROVIDER.getBpn(), PROVIDER.getConfiguration());
protected static final RuntimeExtension PROVIDER_RUNTIME = pgRuntime(PROVIDER.getName(), PROVIDER.getBpn(), PROVIDER.getConfiguration());

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
import org.eclipse.edc.edr.spi.store.EndpointDataReferenceStore;
import org.eclipse.edc.edr.spi.types.EndpointDataReferenceEntry;
import org.eclipse.edc.junit.annotations.EndToEndTest;
import org.eclipse.edc.junit.extensions.RuntimeExtension;
import org.eclipse.edc.spi.types.domain.DataAddress;
import org.eclipse.tractusx.edc.spi.tokenrefresh.dataplane.model.TokenResponse;
import org.eclipse.tractusx.edc.tests.participant.TransferParticipant;
import org.eclipse.tractusx.edc.tests.runtimes.ParticipantRuntime;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
Expand All @@ -63,6 +63,7 @@
import static org.eclipse.tractusx.edc.edr.spi.CoreConstants.EDR_PROPERTY_REFRESH_TOKEN;
import static org.eclipse.tractusx.edc.tests.TestRuntimeConfiguration.CONSUMER_BPN;
import static org.eclipse.tractusx.edc.tests.TestRuntimeConfiguration.CONSUMER_NAME;
import static org.eclipse.tractusx.edc.tests.runtimes.Runtimes.memoryRuntime;
import static org.mockserver.integration.ClientAndServer.startClientAndServer;
import static org.mockserver.matchers.Times.exactly;
import static org.mockserver.model.HttpRequest.request;
Expand All @@ -81,11 +82,7 @@ public class EdrCacheApiEndToEndTest {
.id(CONSUMER_BPN)
.build();
@RegisterExtension
protected static final ParticipantRuntime CONSUMER_RUNTIME = new ParticipantRuntime(
":edc-tests:runtime:runtime-memory",
CONSUMER.getName(),
CONSUMER.getId(),
with(CONSUMER.getConfiguration(), Map.of("edc.iam.issuer.id", "did:web:consumer")));
protected static final RuntimeExtension CONSUMER_RUNTIME = memoryRuntime(CONSUMER.getName(), CONSUMER.getId(), with(CONSUMER.getConfiguration(), Map.of("edc.iam.issuer.id", "did:web:consumer")));
private final ObjectMapper mapper = new ObjectMapper();
private String refreshEndpoint;
private String refreshAudience;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,12 @@
import org.eclipse.edc.connector.controlplane.transfer.spi.event.TransferProcessStarted;
import org.eclipse.edc.junit.annotations.EndToEndTest;
import org.eclipse.edc.junit.annotations.PostgresqlIntegrationTest;
import org.eclipse.edc.junit.extensions.RuntimeExtension;
import org.eclipse.edc.policy.model.Operator;
import org.eclipse.tractusx.edc.tests.helpers.EdrNegotiationHelperFunctions;
import org.eclipse.tractusx.edc.tests.helpers.PolicyHelperFunctions;
import org.eclipse.tractusx.edc.tests.helpers.ReceivedEvent;
import org.eclipse.tractusx.edc.tests.participant.TransferParticipant;
import org.eclipse.tractusx.edc.tests.runtimes.ParticipantRuntime;
import org.eclipse.tractusx.edc.tests.runtimes.PgParticipantRuntime;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
Expand Down Expand Up @@ -191,10 +190,10 @@ void teardown() throws IOException {
class InMemory extends Tests {

@RegisterExtension
protected static final ParticipantRuntime CONSUMER_RUNTIME = memoryRuntime(CONSUMER.getName(), CONSUMER.getBpn(), CONSUMER.getConfiguration());
protected static final RuntimeExtension CONSUMER_RUNTIME = memoryRuntime(CONSUMER.getName(), CONSUMER.getBpn(), CONSUMER.getConfiguration());

@RegisterExtension
protected static final ParticipantRuntime PROVIDER_RUNTIME = memoryRuntime(PROVIDER.getName(), PROVIDER.getBpn(), PROVIDER.getConfiguration());
protected static final RuntimeExtension PROVIDER_RUNTIME = memoryRuntime(PROVIDER.getName(), PROVIDER.getBpn(), PROVIDER.getConfiguration());

}

Expand All @@ -203,10 +202,10 @@ class InMemory extends Tests {
class Postgres extends Tests {

@RegisterExtension
protected static final PgParticipantRuntime CONSUMER_RUNTIME = pgRuntime(CONSUMER.getName(), CONSUMER.getBpn(), CONSUMER.getConfiguration());
protected static final RuntimeExtension CONSUMER_RUNTIME = pgRuntime(CONSUMER.getName(), CONSUMER.getBpn(), CONSUMER.getConfiguration());

@RegisterExtension
protected static final PgParticipantRuntime PROVIDER_RUNTIME = pgRuntime(PROVIDER.getName(), PROVIDER.getBpn(), PROVIDER.getConfiguration());
protected static final RuntimeExtension PROVIDER_RUNTIME = pgRuntime(PROVIDER.getName(), PROVIDER.getBpn(), PROVIDER.getConfiguration());

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public Map<String, String> iatpConfiguration(TractusxIatpParticipantBase... othe
put("edc.iam.sts.oauth.client.id", stsClientId);
put("edc.iam.sts.oauth.client.secret.alias", "client_secret_alias");
put("edc.ih.iam.id", getDid());
put("tx.vault.seed.secrets", "client_secret_alias:%s".formatted(stsClientSecret));
put("tx.edc.vault.seed.secrets", "client_secret_alias:%s".formatted(stsClientSecret));
put("edc.ih.iam.publickey.alias", getFullKeyId());
put("edc.agent.identity.key", "client_id");
put("edc.iam.trusted-issuer.issuer.id", trustedIssuer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
public abstract class TractusxParticipantBase extends IdentityParticipant {

public static final String MANAGEMENT_API_KEY = "testkey";
public static final Duration ASYNC_TIMEOUT = ofSeconds(60);
public static final Duration ASYNC_TIMEOUT = ofSeconds(120);
public static final Duration ASYNC_POLL_INTERVAL = ofSeconds(1);
private static final String CONSUMER_PROXY_API_KEY = "consumerProxyKey";
protected final URI dataPlaneProxy = URI.create("http://localhost:" + getFreePort());
Expand Down Expand Up @@ -198,7 +198,7 @@ public ValidatableResponse getCatalog(TractusxParticipantBase provider) {
.contentType(JSON)
.when()
.body(requestBodyBuilder.build())
.post("/v2/catalog/request")
.post("/v3/catalog/request")
.then();

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@

package org.eclipse.tractusx.edc.tests.runtimes;

import org.eclipse.edc.junit.extensions.EdcExtension;
import org.eclipse.edc.junit.extensions.EmbeddedRuntime;
import org.eclipse.edc.junit.extensions.RuntimeExtension;

/**
* Callback invoked before the runtime boots with extensions of {@link EdcExtension}. This will allow injecting
* custom mock services directly in the tests rather than extending the {@link EdcExtension} with custom mocks
* Callback invoked before the runtime boots with extensions of {@link RuntimeExtension}. This will allow injecting
* custom mock services directly in the tests rather than extending the {@link RuntimeExtension} with custom mocks
*/
@FunctionalInterface
public interface BeforeInitCallback {

void beforeInit(EdcExtension runtime);
void beforeInit(EmbeddedRuntime runtime);
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
*/
public class DataWiper {

private final ServiceExtensionContext context;
protected final ServiceExtensionContext context;

public DataWiper(ServiceExtensionContext context) {
this.context = context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.eclipse.edc.iam.did.spi.resolution.DidPublicKeyResolver;
import org.eclipse.edc.iam.identitytrust.spi.SecureTokenService;
import org.eclipse.edc.iam.identitytrust.sts.embedded.EmbeddedSecureTokenService;
import org.eclipse.edc.junit.extensions.EdcRuntimeExtension;
import org.eclipse.edc.junit.extensions.EmbeddedRuntime;
import org.eclipse.edc.spi.iam.AudienceResolver;
import org.eclipse.edc.spi.iam.IdentityService;
import org.eclipse.edc.spi.result.Result;
Expand All @@ -38,17 +38,16 @@
import org.eclipse.edc.token.JwtGenerationService;
import org.eclipse.tractusx.edc.spi.identity.mapper.BdrsClient;
import org.eclipse.tractusx.edc.tests.MockBpnIdentityService;
import org.junit.jupiter.api.extension.AfterAllCallback;
import org.junit.jupiter.api.extension.BeforeAllCallback;
import org.junit.jupiter.api.extension.ExtensionContext;

import java.time.Clock;
import java.time.Duration;
import java.util.List;
import java.util.Map;


public class ParticipantRuntime extends EdcRuntimeExtension implements BeforeAllCallback, AfterAllCallback {
/**
* Extends the {@link EmbeddedRuntime} adding a key pair to the runtime as well as adding a facility to purge the database ({@link DataWiper}).
*/
public class ParticipantRuntime extends EmbeddedRuntime {

private final Map<String, String> properties;
private final ECKey runtimeKeyPair;
Expand All @@ -59,7 +58,7 @@ public ParticipantRuntime(String moduleName, String runtimeName, String bpn, Map
}

public ParticipantRuntime(String moduleName, String runtimeName, String bpn, Map<String, String> properties, BeforeInitCallback beforeInitCallback) {
super(moduleName, runtimeName, properties);
super(runtimeName, properties, moduleName);
this.properties = properties;
this.registerServiceMock(IdentityService.class, new MockBpnIdentityService(bpn));
this.registerServiceMock(AudienceResolver.class, RemoteMessage::getCounterPartyAddress);
Expand All @@ -81,25 +80,8 @@ public ParticipantRuntime(String moduleName, String runtimeName, String bpn, Map
}
}

@Override
public void beforeTestExecution(ExtensionContext extensionContext) {
//do nothing - we only want to start the runtime once
wiper.clearPersistence();
}

@Override
public void afterTestExecution(ExtensionContext context) {
}

@Override
public void beforeAll(ExtensionContext context) throws Exception {
//only run this once
super.beforeTestExecution(context);
}

@Override
public void afterAll(ExtensionContext context) throws Exception {
super.afterTestExecution(context);
public DataWiper getWiper() {
return wiper;
}

@Override
Expand Down
Loading

0 comments on commit 94383bb

Please sign in to comment.