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

chore: Rework E2E test extension to be used in the EDC EE #1011

Merged
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
4 changes: 2 additions & 2 deletions docs/api/sovity-edc-api-wrapper.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -584,11 +584,11 @@ components:
DataSourceType:
type: string
description: Supported Data Source Types by UiDataSource
default: CUSTOM
enum:
- HTTP_DATA
- ON_REQUEST
- CUSTOM
default: CUSTOM
SecretValue:
type: object
properties:
Expand Down Expand Up @@ -796,14 +796,14 @@ components:
UiDataSourceHttpDataMethod:
type: string
description: Supported HTTP Methods by UiDataSource
default: GET
enum:
- GET
- POST
- PUT
- PATCH
- DELETE
- OPTIONS
default: GET
UiDataSourceOnRequest:
required:
- contactEmail
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class CrawlerE2eTest {
private static EdcClient connectorClient;

@RegisterExtension
static EdcRuntimeExtensionWithTestDatabase providerExtension = new EdcRuntimeExtensionWithTestDatabase(
private static EdcRuntimeExtensionWithTestDatabase providerExtension = new EdcRuntimeExtensionWithTestDatabase(
":launchers:connectors:sovity-dev",
"provider",
testDatabase -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,16 @@
import de.sovity.edc.extension.utils.junit.DisabledOnGithub;
import lombok.val;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.extension.RegisterExtension;

import static org.assertj.core.api.Assertions.assertThat;
import static org.eclipse.edc.connector.contract.spi.types.negotiation.ContractNegotiation.Type.CONSUMER;


@ExtendWith(E2eTestExtension.class)
class ContractAgreementTerminationDetailsQueryTest {

@RegisterExtension
private static E2eTestExtension e2eTestExtension = new E2eTestExtension(":launchers:connectors:sovity-dev");

@DisabledOnGithub
@Test
void fetchAgreementDetailsOrThrow_whenAgreementIsPresent_shouldReturnTheAgreementDetails(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,21 @@
import lombok.val;
import org.eclipse.edc.connector.contract.spi.types.negotiation.ContractNegotiation;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.extension.RegisterExtension;

import java.time.OffsetDateTime;
import java.time.temporal.ChronoUnit;

import static de.sovity.edc.ext.db.jooq.enums.ContractTerminatedBy.COUNTERPARTY;
import static de.sovity.edc.extension.e2e.extension.Helpers.defaultE2eTestExtension;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.within;

@ExtendWith(E2eTestExtension.class)
class TerminateContractQueryTest {

@RegisterExtension
private static E2eTestExtension e2eTestExtension = defaultE2eTestExtension();

@DisabledOnGithub
@Test
void terminateConsumerAgreementOrThrow_shouldInsertRowInTerminationTable(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,19 @@
import org.mockserver.integration.ClientAndServer;

import static de.sovity.edc.e2e.AlwaysTrueMigrationTest.testTransfer;
import static de.sovity.edc.extension.e2e.extension.CeE2eTestExtensionConfigFactory.defaultBuilder;

class AlwaysTrueMigrationTestReversed {
class AlwaysTrueMigrationReversedTest {

@RegisterExtension
private static final E2eTestExtension E2E_TEST_EXTENSION = E2eTestExtension.builder()
.additionalConsumerMigrationLocation("classpath:db/additional-test-data/always-true-policy-legacy")
.additionalProviderMigrationLocation("classpath:db/additional-test-data/always-true-policy-migrated")
.build();
private static final E2eTestExtension E2E_TEST_EXTENSION = new E2eTestExtension(
defaultBuilder().toBuilder()
.consumerConfigCustomizer(config -> config.getProperties()
.put("edc.flyway.additional.migration.locations", "classpath:db/additional-test-data/always-true-policy-legacy"))
.providerConfigCustomizer(config -> config.getProperties()
.put("edc.flyway.additional.migration.locations", "classpath:db/additional-test-data/always-true-policy-migrated"))
.build()
);

@Test
@DisabledOnGithub
Expand Down
27 changes: 23 additions & 4 deletions tests/src/test/java/de/sovity/edc/e2e/AlwaysTrueMigrationTest.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
/*
* Copyright (c) 2024 sovity GmbH
*
* 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:
* sovity GmbH - initial API and implementation
*
*/

package de.sovity.edc.e2e;

import de.sovity.edc.client.EdcClient;
Expand All @@ -23,15 +37,20 @@

import java.util.Map;

import static de.sovity.edc.extension.e2e.extension.CeE2eTestExtensionConfigFactory.withModule;
import static org.assertj.core.api.Assertions.assertThat;

class AlwaysTrueMigrationTest {

@RegisterExtension
private static final E2eTestExtension E2E_TEST_EXTENSION = E2eTestExtension.builder()
.additionalConsumerMigrationLocation("classpath:db/additional-test-data/always-true-policy-migrated")
.additionalProviderMigrationLocation("classpath:db/additional-test-data/always-true-policy-legacy")
.build();
private static final E2eTestExtension E2E_TEST_EXTENSION = new E2eTestExtension(
withModule(":launchers:connectors:sovity-dev").toBuilder()
.consumerConfigCustomizer(config -> config.getProperties()
.put("edc.flyway.additional.migration.locations", "classpath:db/additional-test-data/always-true-policy-migrated"))
.providerConfigCustomizer(config -> config.getProperties()
.put("edc.flyway.additional.migration.locations", "classpath:db/additional-test-data/always-true-policy-legacy"))
.build()
);

@Test
@DisabledOnGithub
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import org.junit.jupiter.api.DynamicTest;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestFactory;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.mockserver.integration.ClientAndServer;
import org.mockserver.model.HttpRequest;
import org.mockserver.model.HttpResponse;
Expand All @@ -52,16 +52,19 @@
import static de.sovity.edc.client.gen.model.ContractTerminatedBy.SELF;
import static de.sovity.edc.client.gen.model.ContractTerminationStatus.ONGOING;
import static de.sovity.edc.client.gen.model.ContractTerminationStatus.TERMINATED;
import static de.sovity.edc.extension.e2e.extension.Helpers.defaultE2eTestExtension;
import static java.time.Duration.ofSeconds;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.within;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.DynamicTest.dynamicTest;

@ExtendWith(E2eTestExtension.class)
public class ContractTerminationTest {

@RegisterExtension
private static E2eTestExtension e2eTestExtension = defaultE2eTestExtension();

@Test
@DisabledOnGithub
void canGetAgreementPageForNonTerminatedContract(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.mockserver.integration.ClientAndServer;
import org.mockserver.model.HttpRequest;
import org.mockserver.model.HttpResponse;
Expand All @@ -77,6 +77,7 @@
import javax.annotation.Nullable;

import static de.sovity.edc.client.gen.model.TransferProcessSimplifiedState.OK;
import static de.sovity.edc.extension.e2e.extension.Helpers.defaultE2eTestExtension;
import static java.time.Duration.ofSeconds;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Fail.fail;
Expand All @@ -91,9 +92,12 @@
import static org.mockserver.model.HttpRequest.request;
import static org.mockserver.stop.Stop.stopQuietly;

@ExtendWith(E2eTestExtension.class)

class DataSourceParameterizationTest {

@RegisterExtension
private static E2eTestExtension e2eTestExtension = defaultE2eTestExtension();

private final int port = getFreePort();
private final String sourcePath = "/source/some/path/";
private final String destinationPath = "/destination/some/path/";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,18 @@
import lombok.val;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.extension.RegisterExtension;

import java.util.HashMap;

import static de.sovity.edc.extension.e2e.connector.DataTransferTestUtil.validateDataTransferred;
import static de.sovity.edc.extension.e2e.extension.Helpers.defaultE2eTestExtension;

@ExtendWith(E2eTestExtension.class)
class DataSourceQueryParamsTest {

@RegisterExtension
private static E2eTestExtension e2eTestExtension = defaultE2eTestExtension();

private MockDataAddressRemote dataAddress;
private final String encodedParam = "a=%25"; // Unencoded param "a=%"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,18 @@
import de.sovity.edc.extension.e2e.extension.Provider;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.extension.RegisterExtension;

import java.util.UUID;

import static de.sovity.edc.extension.e2e.connector.DataTransferTestUtil.validateDataTransferred;
import static de.sovity.edc.extension.e2e.extension.Helpers.defaultE2eTestExtension;

@ExtendWith(E2eTestExtension.class)
class ManagementApiTransferTest {

@RegisterExtension
private static E2eTestExtension e2eTestExtension = defaultE2eTestExtension();

private MockDataAddressRemote dataAddress;
private static final String TEST_BACKEND_TEST_DATA = UUID.randomUUID().toString();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import lombok.SneakyThrows;
import lombok.val;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.mockserver.integration.ClientAndServer;
import org.mockserver.model.HttpRequest;
import org.mockserver.model.HttpResponse;
Expand All @@ -37,12 +37,15 @@
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;

import static de.sovity.edc.extension.e2e.extension.Helpers.defaultE2eTestExtension;
import static org.assertj.core.api.Assertions.assertThat;
import static org.eclipse.edc.spi.CoreConstants.EDC_NAMESPACE;

@ExtendWith(E2eTestExtension.class)
class PlaceholderDataSourceExtensionTest {

@RegisterExtension
private static E2eTestExtension e2eTestExtension = defaultE2eTestExtension();

@SneakyThrows
@Test
void shouldAccessDummyEndpoint(
Expand Down
3 changes: 2 additions & 1 deletion tests/src/test/java/de/sovity/edc/e2e/UiApiWrapperTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
import static de.sovity.edc.client.gen.model.ContractAgreementDirection.CONSUMING;
import static de.sovity.edc.client.gen.model.ContractAgreementDirection.PROVIDING;
import static de.sovity.edc.extension.e2e.connector.DataTransferTestUtil.validateDataTransferred;
import static de.sovity.edc.extension.e2e.extension.Helpers.defaultE2eTestExtension;
import static net.javacrumbs.jsonunit.assertj.JsonAssertions.assertThatJson;
import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await;
Expand All @@ -80,7 +81,7 @@ class UiApiWrapperTest {
private static final String CONSUMER_PARTICIPANT_ID = "consumer";

@RegisterExtension
private static E2eTestExtension e2eTestExtension = new E2eTestExtension(CONSUMER_PARTICIPANT_ID, PROVIDER_PARTICIPANT_ID);
private static E2eTestExtension e2eTestExtension = defaultE2eTestExtension();

private MockDataAddressRemote dataAddress;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,19 @@
import de.sovity.edc.utils.jsonld.vocab.Prop;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.extension.RegisterExtension;

import java.time.OffsetDateTime;
import java.util.List;

import static de.sovity.edc.extension.e2e.extension.Helpers.defaultE2eTestExtension;
import static org.assertj.core.api.Assertions.assertThat;

@ExtendWith(E2eTestExtension.class)
class UseCaseApiWrapperTest {

@RegisterExtension
private static E2eTestExtension e2eTestExtension = defaultE2eTestExtension();

private MockDataAddressRemote dataAddress;
private final String dataOfferData = "expected data 123";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
* {@link AfterTestExecutionCallback} lifecycle hooks. Parameter injection of runtime services is supported.
*/
public class EdcRuntimeExtensionFixed extends EdcExtension {

private static final Monitor MONITOR = loadMonitor();

private final String moduleName;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright (c) 2024 sovity GmbH
*
* 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:
* sovity GmbH - initial API and implementation
*
*/

package de.sovity.edc.extension.e2e.extension;

import lombok.experimental.UtilityClass;

@UtilityClass
public class CeE2eTestExtensionConfigFactory {

public static E2eTestExtensionConfig defaultBuilder() {
return E2eTestExtensionConfig.builder().moduleName(":launchers:connectors:sovity-dev").build();
}

public static E2eTestExtensionConfig withModule(String module) {
return defaultBuilder().toBuilder().moduleName(module).build();
}
}
Loading
Loading