Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: extract e2e-fixtures module #1635

Merged
merged 1 commit into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions DEPENDENCIES
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ maven/mavencentral/com.fasterxml.jackson.core/jackson-databind/2.17.1, Apache-2.
maven/mavencentral/com.fasterxml.jackson.core/jackson-databind/2.17.2, Apache-2.0, approved, #13671
maven/mavencentral/com.fasterxml.jackson.core/jackson-databind/2.18.0, Apache-2.0, approved, #16372
maven/mavencentral/com.fasterxml.jackson.dataformat/jackson-dataformat-toml/2.15.2, Apache-2.0, approved, #15241
maven/mavencentral/com.fasterxml.jackson.dataformat/jackson-dataformat-toml/2.18.0, , restricted, clearlydefined
maven/mavencentral/com.fasterxml.jackson.dataformat/jackson-dataformat-toml/2.18.0, Apache-2.0, approved, #16800
maven/mavencentral/com.fasterxml.jackson.dataformat/jackson-dataformat-yaml/2.14.0, Apache-2.0, approved, #5933
maven/mavencentral/com.fasterxml.jackson.dataformat/jackson-dataformat-yaml/2.16.2, Apache-2.0, approved, #11855
maven/mavencentral/com.fasterxml.jackson.dataformat/jackson-dataformat-yaml/2.18.0, Apache-2.0, approved, #16370
Expand Down Expand Up @@ -324,7 +324,6 @@ maven/mavencentral/org.bouncycastle/bcpkix-jdk18on/1.72, MIT, approved, #3789
maven/mavencentral/org.bouncycastle/bcpkix-jdk18on/1.78.1, MIT, approved, #14434
maven/mavencentral/org.bouncycastle/bcprov-jdk18on/1.72, MIT AND CC0-1.0, approved, #3538
maven/mavencentral/org.bouncycastle/bcprov-jdk18on/1.78.1, MIT AND CC0-1.0, approved, #14433
maven/mavencentral/org.bouncycastle/bcutil-jdk18on/1.72, MIT, approved, #3790
maven/mavencentral/org.bouncycastle/bcutil-jdk18on/1.78.1, MIT, approved, #14435
maven/mavencentral/org.ccil.cowan.tagsoup/tagsoup/1.2.1, Apache-2.0, approved, clearlydefined
maven/mavencentral/org.checkerframework/checker-qual/3.12.0, MIT, approved, clearlydefined
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
* Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
Expand All @@ -23,42 +23,40 @@ plugins {
}

dependencies {
// api modules that the test classes may need
testFixturesApi(project(":spi:edr-spi"))
testFixturesApi(project(":edc-extensions:edr:edr-api-v2"))
testFixturesApi(project(":spi:core-spi"))
testFixturesApi(project(":spi:tokenrefresh-spi"))
testFixturesApi(project(":spi:bdrs-client-spi"))
testFixturesApi(project(":spi:core-spi"))
testFixturesApi(project(":spi:edr-spi"))
testFixturesApi(project(":edc-extensions:agreements:retirement-evaluation-spi"))
testFixturesApi(project(":edc-extensions:bpn-validation:bpn-validation-spi"))

testFixturesApi(libs.edc.spi.core)

testFixturesApi(libs.edc.core.token)
testFixturesApi(libs.edc.identity.trust.sts.embedded)
testFixturesApi(libs.edc.junit)
testFixturesApi(libs.edc.lib.cryptocommon)
testFixturesApi(libs.edc.lib.jws2020)
testFixturesApi(libs.edc.lib.util)
testFixturesApi(libs.edc.aws.s3.core)
testFixturesApi(libs.edc.spi.edrstore)
testFixturesApi(libs.edc.spi.jsonld)
testFixturesApi(libs.edc.spi.policy)
testFixturesApi(libs.edc.spi.contract)
testFixturesApi(libs.edc.spi.transfer)
testFixturesApi(testFixtures(libs.edc.api.management.test.fixtures))
testFixturesApi(libs.edc.spi.edrstore)
testFixturesApi(libs.edc.lib.cryptocommon)
testFixturesApi(libs.edc.lib.boot)

// api modules for some test utils
testFixturesApi(libs.assertj)
testFixturesApi(libs.awaitility)
testFixturesApi(libs.aws.s3)
testFixturesApi(libs.azure.storage.blob)
testFixturesApi(libs.jakartaJson)
testFixturesApi(libs.junit.jupiter.api)
testFixturesApi(libs.junit.jupiter.params)
testFixturesApi(libs.netty.mockserver)
testFixturesApi(libs.edc.junit)
testFixturesApi(libs.postgres)
testFixturesApi(libs.restAssured)
testFixturesApi(libs.awaitility)

testFixturesImplementation(libs.edc.identity.trust.sts.embedded)
testFixturesImplementation(libs.edc.core.token)
testFixturesImplementation(libs.edc.spi.identity.did)
testFixturesImplementation(libs.postgres)
testFixturesImplementation(libs.testcontainers.postgres)
testFixturesImplementation(libs.assertj)
testFixturesImplementation(libs.junit.jupiter.api)
testFixturesImplementation(project(":edc-extensions:bpn-validation:bpn-validation-spi"))
testFixturesImplementation(project(":edc-extensions:agreements:retirement-evaluation-spi"))

testCompileOnly(project(":edc-tests:runtime:runtime-memory"))
testCompileOnly(project(":edc-tests:runtime:runtime-postgresql"))
testFixturesApi(libs.testcontainers.junit)
testFixturesApi(libs.testcontainers.postgres)
}

// do not publish
edcBuild {
publish.set(false)
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

package org.eclipse.tractusx.edc.tests.transfer;
package org.eclipse.tractusx.edc.tests.aws;

import org.testcontainers.containers.GenericContainer;
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
* Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
Expand All @@ -17,7 +17,7 @@
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

package org.eclipse.tractusx.edc.dataplane.transfer.test;
package org.eclipse.tractusx.edc.tests.azure;

import com.azure.core.util.BinaryData;
import com.azure.storage.blob.BlobContainerClient;
Expand All @@ -43,7 +43,7 @@ public class AzureBlobHelper {
private final int port;
private BlobServiceClient blobServiceClient;

public AzureBlobHelper(String accountName, String key, String host, int port) {
AzureBlobHelper(String accountName, String key, String host, int port) {
this.accountName = accountName;
this.key = key;
this.host = host;
Expand All @@ -54,25 +54,14 @@ public BlobContainerClient createContainer(String containerName) {
return blobClient().createBlobContainer(containerName);
}

private BlobServiceClient blobClient() {
if (blobServiceClient == null) {
var endpoint = "http://%s:%s/%s".formatted(host, port, accountName);
blobServiceClient = new BlobServiceClientBuilder()
.credential(new StorageSharedKeyCredential(accountName, key))
.endpoint(endpoint)
.buildClient();
}
return blobServiceClient;
public void uploadBlob(BlobContainerClient client, BinaryData data, String targetBlobName) {
client.getBlobClient(targetBlobName).upload(data, true);
}

public void uploadBlob(BlobContainerClient client, InputStream inputStream, String targetBlobName) {
client.getBlobClient(targetBlobName).upload(inputStream, true);
}

public void uploadBlob(BlobContainerClient client, BinaryData data, String targetBlobName) {
client.getBlobClient(targetBlobName).upload(data, true);
}

public List<String> listBlobs(String container) {
if (blobClient().listBlobContainers().stream().noneMatch(bci -> bci.getName().equalsIgnoreCase(container))) {
return List.of();
Expand All @@ -84,11 +73,22 @@ public List<String> listBlobs(String container) {
.toList();
}

private BlobServiceClient blobClient() {
if (blobServiceClient == null) {
var endpoint = "http://%s:%s/%s".formatted(host, port, accountName);
blobServiceClient = new BlobServiceClientBuilder()
.credential(new StorageSharedKeyCredential(accountName, key))
.endpoint(endpoint)
.buildClient();
}
return blobServiceClient;
}

public String generateAccountSas(String containerName) {
var expiry = OffsetDateTime.MAX.minusDays(1);
var permissions = BlobContainerSasPermission.parse("w");
var vals = new BlobServiceSasSignatureValues(expiry, permissions);
return blobClient().getBlobContainerClient(containerName).generateSas(vals);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,23 @@
* SPDX-License-Identifier: Apache-2.0
*/

package org.eclipse.tractusx.edc.tests.transfer;
package org.eclipse.tractusx.edc.tests.azure;

import org.testcontainers.containers.GenericContainer;

import java.util.Arrays;
import java.util.List;

import static java.util.Arrays.stream;
import static java.util.stream.Collectors.joining;
import static org.eclipse.tractusx.edc.tests.transfer.AzureToAzureEndToEndTest.AZURITE_DOCKER_IMAGE;

public class AzuriteContainer extends GenericContainer<AzuriteContainer> {

private static final String IMAGE_NAME = "mcr.microsoft.com/azure-storage/azurite";
private final int containerPort = 10_000;

public AzuriteContainer(int azuriteHostPort, Account... accounts) {
super(AZURITE_DOCKER_IMAGE);
var azuriteAccounts = Arrays.stream(accounts).map(it -> "%s:%s".formatted(it.name, it.key)).collect(joining(";"));
addEnv("AZURITE_ACCOUNTS", azuriteAccounts);
super(IMAGE_NAME);
addEnv("AZURITE_ACCOUNTS", stream(accounts).map(it -> "%s:%s".formatted(it.name, it.key)).collect(joining(";")));
setPortBindings(List.of("%d:%d".formatted(azuriteHostPort, containerPort)));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ void httpPushDataTransfer() {

var destination = httpDataAddress(consumerUrl);

var transferProcessId = consumer().requestAsset(provider(), assetId, createObjectBuilder().build(), destination, "HttpData-PUSH");
var transferProcessId = consumer()
.requestAssetFrom(assetId, provider())
.withDestination(destination)
.withTransferType("HttpData-PUSH")
.execute();
await().atMost(ASYNC_TIMEOUT).untilAsserted(() -> {
var state = consumer().getTransferProcessState(transferProcessId);
assertThat(state).isEqualTo(COMPLETED.name());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ plugins {
}

dependencies {
testImplementation(testFixtures(project(":edc-tests:edc-controlplane:fixtures")))
testImplementation(testFixtures(project(":edc-tests:e2e-fixtures")))

testImplementation(libs.netty.mockserver)
testImplementation(libs.edc.junit)
Expand Down
2 changes: 1 addition & 1 deletion edc-tests/edc-controlplane/catalog-tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ plugins {
}

dependencies {
testImplementation(testFixtures(project(":edc-tests:edc-controlplane:fixtures")))
testImplementation(testFixtures(project(":edc-tests:e2e-fixtures")))

testImplementation(libs.netty.mockserver)
testImplementation(libs.edc.junit)
Expand Down
5 changes: 4 additions & 1 deletion edc-tests/edc-controlplane/edr-api-tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ plugins {
}

dependencies {
testImplementation(testFixtures(project(":edc-tests:edc-controlplane:fixtures")))
testImplementation(project(":spi:tokenrefresh-spi"))

testImplementation(testFixtures(project(":edc-tests:e2e-fixtures")))
testImplementation(libs.edc.spi.edrstore)

testImplementation(libs.netty.mockserver)
testImplementation(libs.edc.junit)
Expand Down
2 changes: 1 addition & 1 deletion edc-tests/edc-controlplane/iatp-tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ plugins {
}

dependencies {
testImplementation(testFixtures(project(":edc-tests:edc-controlplane:fixtures")))
testImplementation(testFixtures(project(":edc-tests:e2e-fixtures")))
testImplementation(libs.edc.identity.trust.sts.embedded)
testImplementation(libs.edc.ih.did)
testImplementation(libs.edc.ih.spi)
Expand Down
2 changes: 1 addition & 1 deletion edc-tests/edc-controlplane/policy-tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ plugins {
}

dependencies {
testImplementation(testFixtures(project(":edc-tests:edc-controlplane:fixtures")))
testImplementation(testFixtures(project(":edc-tests:e2e-fixtures")))

testImplementation(libs.netty.mockserver)
testImplementation(libs.edc.junit)
Expand Down
2 changes: 1 addition & 1 deletion edc-tests/edc-controlplane/transfer-tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ plugins {

dependencies {
testImplementation(project(":spi:bdrs-client-spi"))
testImplementation(testFixtures(project(":edc-tests:edc-controlplane:fixtures")))
testImplementation(testFixtures(project(":edc-tests:e2e-fixtures")))

testImplementation(libs.netty.mockserver)
testImplementation(libs.edc.junit)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ plugins {
}

dependencies {
testImplementation(testFixtures(project(":edc-tests:e2e-fixtures")))

testImplementation(libs.edc.junit)
testImplementation(libs.restAssured)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import org.eclipse.edc.spi.monitor.ConsoleMonitor;
import org.eclipse.edc.spi.monitor.Monitor;
import org.eclipse.edc.spi.security.Vault;
import org.eclipse.tractusx.edc.tests.azure.AzureBlobHelper;
import org.eclipse.tractusx.edc.tests.azure.AzuriteContainer;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
import org.eclipse.edc.junit.extensions.RuntimePerClassExtension;
import org.eclipse.edc.junit.testfixtures.TestUtils;
import org.eclipse.edc.spi.security.Vault;
import org.eclipse.tractusx.edc.tests.aws.MinioContainer;
import org.eclipse.tractusx.edc.tests.azure.AzureBlobHelper;
import org.eclipse.tractusx.edc.tests.azure.AzuriteContainer;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
Expand Down
Loading
Loading