diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 86162f6f9..78b91b6f6 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,3 +1,25 @@ +# +# Copyright (c) 2023 ZF Friedrichshafen AG +# Copyright (c) 2023 Mercedes-Benz Tech Innovation GmbH +# Copyright (c) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +# Copyright (c) 2021, 2023 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# 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 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# + --- name: "Build" @@ -20,6 +42,7 @@ on: - '*' workflow_dispatch: + concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true @@ -41,74 +64,9 @@ jobs: [ ! -z "${{ secrets.GPG_PASSPHRASE }}" ] && echo "::set-output name=GPG_PASSPHRASE::true" exit 0 - verify-formatting: - runs-on: ubuntu-latest - steps: - - - name: Checkout - uses: actions/checkout@v3.3.0 - - - - name: Set up JDK 11 - uses: actions/setup-java@v3.10.0 - with: - java-version: '11' - distribution: 'adopt' - cache: 'gradle' - - - name: Verify proper formatting - run: ./gradlew spotlessCheck - - - name: Run Checkstyle - run: | - ./gradlew checkstyleMain checkstyleTest - echo "Running Checkstyle is currently a placeholder" - - sonar: - needs: [ secret-presence, verify-formatting ] - if: | - needs.secret-presence.outputs.SONAR_TOKEN - runs-on: ubuntu-latest - steps: - # Set-Up - - - name: Checkout - uses: actions/checkout@v3.3.0 - with: - fetch-depth: 0 - - - name: Set up JDK 11 - uses: actions/setup-java@v3.10.0 - with: - java-version: '11' - distribution: 'adopt' - cache: 'gradle' - - - name: Cache SonarCloud packages - uses: actions/cache@v3 - with: - path: ~/.sonar/cache - key: ${{ runner.os }}-sonar - restore-keys: ${{ runner.os }}-sonar - # Analyse - - - name: Build with Maven and analyze with Sonar - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - JACOCO: true - run: |- - ./gradlew sonar \ - -Pcoverage,failsafe \ - -Dsonar.projectKey=${GITHUB_REPOSITORY_OWNER}_product-edc \ - -Dsonar.organization=${GITHUB_REPOSITORY_OWNER} \ - -Dsonar.host.url=https://sonarcloud.io \ - -Dsonar.coverage.jacoco.xmlReportPaths=${GITHUB_WORKSPACE}/build/reports/jacoco/testCodeCoverageReport/testCodeCoverageReport.xml \ - -Dsonar.verbose=true - build-extensions: runs-on: ubuntu-latest - needs: [ secret-presence, verify-formatting ] + needs: [ secret-presence] steps: # Set-Up - @@ -135,7 +93,7 @@ jobs: permissions: contents: read packages: write - needs: [ secret-presence, verify-formatting ] + needs: [ secret-presence] strategy: fail-fast: false matrix: @@ -204,7 +162,7 @@ jobs: permissions: contents: read packages: write - needs: [ secret-presence, verify-formatting ] + needs: [ secret-presence] strategy: fail-fast: false matrix: @@ -271,7 +229,7 @@ jobs: permissions: contents: read packages: write - needs: [secret-presence, verify-formatting, build-controlplane, build-dataplane, build-extensions] + needs: [secret-presence, build-controlplane, build-dataplane, build-extensions] # do not run on PR branches, do not run on main if: | diff --git a/.github/workflows/business-tests.yaml b/.github/workflows/business-tests.yaml index df433b648..f55d3d6ba 100644 --- a/.github/workflows/business-tests.yaml +++ b/.github/workflows/business-tests.yaml @@ -1,3 +1,25 @@ +# +# Copyright (c) 2023 ZF Friedrichshafen AG +# Copyright (c) 2023 Mercedes-Benz Tech Innovation GmbH +# Copyright (c) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +# Copyright (c) 2021, 2023 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# 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 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# + --- name: "Business Tests" @@ -133,10 +155,10 @@ jobs: retry_on: error command: |- # Update helm dependencies - helm dependency update edc-tests/src/main/resources/deployment/helm/supporting-infrastructure + helm dependency update edc-tests/cucumber/src/main/resources/deployment/helm/supporting-infrastructure # Install the all-in-one supporting infrastructure environment (daps, vault, pgsql, minio) - helm install infrastructure edc-tests/src/main/resources/deployment/helm/supporting-infrastructure \ + helm install infrastructure edc-tests/cucumber/src/main/resources/deployment/helm/supporting-infrastructure \ --wait-for-jobs --timeout=120s # GH pipelines constrained by cpu, so give helm some time to register all resources \w k8s @@ -240,7 +262,7 @@ jobs: { "args": [ "-c", - "cd /product-edc && ./gradlew edc-tests:test -Dcucumber=true" + "cd /product-edc && ./gradlew edc-tests:cucumber:test -Dcucumber=true" ], "command": [ "/bin/sh" @@ -276,7 +298,7 @@ jobs: cat << EOF >> pod.json "image": "openjdk:11-jdk-slim", - "name": "edc-tests", + "name": "edc-tests-cucumber", "volumeMounts": [ { "mountPath": "/product-edc", @@ -309,7 +331,7 @@ jobs: } EOF - kubectl run -i --image=openjdk:11-jdk-slim --restart=Never --rm edc-tests --overrides="$(cat pod.json)" + kubectl run -i --image=openjdk:11-jdk-slim --restart=Never --rm edc-tests-cucumber --overrides="$(cat pod.json)" ################# ### Tear Down ### diff --git a/.github/workflows/verify.yaml b/.github/workflows/verify.yaml new file mode 100644 index 000000000..adfeb5558 --- /dev/null +++ b/.github/workflows/verify.yaml @@ -0,0 +1,193 @@ +# +# Copyright (c) 2023 Mercedes-Benz Tech Innovation GmbH +# Copyright (c) 2021, 2023 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# 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 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# + +--- +name: "Verify" + +on: + push: + branches: + - main + - develop + tags: + - '[0-9]+.[0-9]+.[0-9]+' + release: + types: + - published + pull_request: + paths-ignore: + - 'charts/**' + - 'docs/**' + - '**/*.md' + branches: + - '*' + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + secret-presence: + runs-on: ubuntu-latest + outputs: + SONAR_TOKEN: ${{ steps.secret-presence.outputs.SONAR_TOKEN }} + steps: + - + name: Check whether secrets exist + id: secret-presence + run: | + [ ! -z "${{ secrets.SONAR_TOKEN }}" ] && echo "::set-output name=SONAR_TOKEN::true" + exit 0 + + verify-formatting: + runs-on: ubuntu-latest + steps: + - + name: Checkout + uses: actions/checkout@v3.3.0 + + - + name: Set up JDK 11 + uses: actions/setup-java@v3.10.0 + with: + java-version: '11' + distribution: 'adopt' + cache: 'gradle' + - + name: Verify proper formatting + run: ./gradlew spotlessCheck + + - name: Run Checkstyle + run: | + ./gradlew checkstyleMain checkstyleTest + echo "Running Checkstyle is currently a placeholder" + + unit-tests: + runs-on: ubuntu-latest + needs: [verify-formatting] + steps: + - name: Checkout + uses: actions/checkout@v3.3.0 + + - name: Set up JDK 11 + uses: actions/setup-java@v3.10.0 + with: + java-version: '11' + distribution: 'adopt' + cache: 'gradle' + + - name: Run Unit tests + run: ./gradlew test + + integration-tests: + runs-on: ubuntu-latest + needs: [verify-formatting] + steps: + - name: Checkout + uses: actions/checkout@v3.3.0 + + - name: Set up JDK 11 + uses: actions/setup-java@v3.10.0 + with: + java-version: '11' + distribution: 'adopt' + cache: 'gradle' + + - name: Run Integration tests + run: ./gradlew test -DincludeTags="ComponentTest" + + api-tests: + runs-on: ubuntu-latest + needs: [verify-formatting] + steps: + - name: Checkout + uses: actions/checkout@v3.3.0 + + - name: Set up JDK 11 + uses: actions/setup-java@v3.10.0 + with: + java-version: '11' + distribution: 'adopt' + cache: 'gradle' + + - name: Run API tests + run: ./gradlew test -DincludeTags="ApiTest" + + end-to-end-tests: + runs-on: ubuntu-latest + needs: [verify-formatting] + steps: + - name: Checkout + uses: actions/checkout@v3.3.0 + + - name: Set up JDK 11 + uses: actions/setup-java@v3.10.0 + with: + java-version: '11' + distribution: 'adopt' + cache: 'gradle' + + - name: Run E2E tests + run: ./gradlew test -DincludeTags="EndToEndTest" + + sonar: + needs: [ secret-presence, verify-formatting ] + if: | + needs.secret-presence.outputs.SONAR_TOKEN + runs-on: ubuntu-latest + steps: + # Set-Up + - + name: Checkout + uses: actions/checkout@v3.3.0 + with: + fetch-depth: 0 + - + name: Set up JDK 11 + uses: actions/setup-java@v3.10.0 + with: + java-version: '11' + distribution: 'adopt' + cache: 'gradle' + - + name: Cache SonarCloud packages + uses: actions/cache@v3 + with: + path: ~/.sonar/cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + # Analyse + - + name: Build with Maven and analyze with Sonar + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + JACOCO: true + run: |- + ./gradlew sonar \ + -Pcoverage,failsafe \ + -Dsonar.projectKey=${GITHUB_REPOSITORY_OWNER}_product-edc \ + -Dsonar.organization=${GITHUB_REPOSITORY_OWNER} \ + -Dsonar.host.url=https://sonarcloud.io \ + -Dsonar.coverage.jacoco.xmlReportPaths=${GITHUB_WORKSPACE}/build/reports/jacoco/testCodeCoverageReport/testCodeCoverageReport.xml \ + -Dsonar.verbose=true + + diff --git a/build.gradle.kts b/build.gradle.kts index 46e8a3b55..04e7ff7cc 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -59,6 +59,9 @@ allprojects { dependencies { implementation("org.projectlombok:lombok:1.18.26") implementation("org.slf4j:slf4j-api:2.0.5") + // this is used to counter version conflicts between the JUnit version pulled in by the plugin, + // and the one expected by IntelliJ + testImplementation(platform("org.junit:junit-bom:5.9.2")) } // configure which version of the annotation processor to use. defaults to the same version as the plugin @@ -120,6 +123,13 @@ allprojects { } } + // EdcRuntimeExtension uses this to determine the runtime classpath of the module to run. + tasks.register("printClasspath") { + doLast { + println(sourceSets["main"].runtimeClasspath.asPath) + } + } + } // the "dockerize" task is added to all projects that use the `shadowJar` plugin diff --git a/edc-extensions/business-partner-validation/src/main/java/org/eclipse/tractusx/edc/validation/businesspartner/BusinessPartnerValidationExtension.java b/edc-extensions/business-partner-validation/src/main/java/org/eclipse/tractusx/edc/validation/businesspartner/BusinessPartnerValidationExtension.java index f0edd6be2..ee076406f 100644 --- a/edc-extensions/business-partner-validation/src/main/java/org/eclipse/tractusx/edc/validation/businesspartner/BusinessPartnerValidationExtension.java +++ b/edc-extensions/business-partner-validation/src/main/java/org/eclipse/tractusx/edc/validation/businesspartner/BusinessPartnerValidationExtension.java @@ -20,8 +20,6 @@ package org.eclipse.tractusx.edc.validation.businesspartner; -import static org.eclipse.edc.policy.engine.spi.PolicyEngine.ALL_SCOPES; - import org.eclipse.edc.policy.engine.spi.PolicyEngine; import org.eclipse.edc.policy.engine.spi.RuleBindingRegistry; import org.eclipse.edc.policy.model.Duty; @@ -35,6 +33,8 @@ import org.eclipse.tractusx.edc.validation.businesspartner.functions.BusinessPartnerPermissionFunction; import org.eclipse.tractusx.edc.validation.businesspartner.functions.BusinessPartnerProhibitionFunction; +import static org.eclipse.edc.policy.engine.spi.PolicyEngine.ALL_SCOPES; + public class BusinessPartnerValidationExtension implements ServiceExtension { /** diff --git a/edc-extensions/business-partner-validation/src/test/java/org/eclipse/tractusx/edc/validation/businesspartner/BusinessPartnerValidationExtensionTest.java b/edc-extensions/business-partner-validation/src/test/java/org/eclipse/tractusx/edc/validation/businesspartner/BusinessPartnerValidationExtensionTest.java index 732379fc2..0240dc9ef 100644 --- a/edc-extensions/business-partner-validation/src/test/java/org/eclipse/tractusx/edc/validation/businesspartner/BusinessPartnerValidationExtensionTest.java +++ b/edc-extensions/business-partner-validation/src/test/java/org/eclipse/tractusx/edc/validation/businesspartner/BusinessPartnerValidationExtensionTest.java @@ -31,71 +31,78 @@ import org.junit.jupiter.api.Test; import org.mockito.Mockito; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + class BusinessPartnerValidationExtensionTest { - private BusinessPartnerValidationExtension extension; + private BusinessPartnerValidationExtension extension; - // mocks - private ServiceExtensionContext serviceExtensionContext; - private PolicyEngine policyEngine; - private RuleBindingRegistry ruleBindingRegistry; + // mocks + private ServiceExtensionContext serviceExtensionContext; + private PolicyEngine policyEngine; + private RuleBindingRegistry ruleBindingRegistry; - @BeforeEach - void setup() { + @BeforeEach + void setup() { - policyEngine = Mockito.mock(PolicyEngine.class); - ruleBindingRegistry = Mockito.mock(RuleBindingRegistry.class); + policyEngine = mock(PolicyEngine.class); + ruleBindingRegistry = mock(RuleBindingRegistry.class); - final Monitor monitor = Mockito.mock(Monitor.class); - serviceExtensionContext = Mockito.mock(ServiceExtensionContext.class); + var monitor = mock(Monitor.class); + serviceExtensionContext = mock(ServiceExtensionContext.class); - Mockito.when(serviceExtensionContext.getMonitor()).thenReturn(monitor); + when(serviceExtensionContext.getMonitor()).thenReturn(monitor); - extension = new BusinessPartnerValidationExtension(ruleBindingRegistry, policyEngine); - } + extension = new BusinessPartnerValidationExtension(ruleBindingRegistry, policyEngine); + } - @Test - void testRegisterDutyFunction() { + @Test + void testRegisterDutyFunction() { - // invoke - extension.initialize(serviceExtensionContext); + // invoke + extension.initialize(serviceExtensionContext); - // verify - Mockito.verify(policyEngine, Mockito.times(1)) - .registerFunction( - Mockito.anyString(), - Mockito.eq(Duty.class), - Mockito.eq(BusinessPartnerValidationExtension.BUSINESS_PARTNER_CONSTRAINT_KEY), - Mockito.any()); - } + // verify + verify(policyEngine) + .registerFunction( + anyString(), + eq(Duty.class), + eq(BusinessPartnerValidationExtension.BUSINESS_PARTNER_CONSTRAINT_KEY), + any()); + } - @Test - void testRegisterPermissionFunction() { + @Test + void testRegisterPermissionFunction() { - // invoke - extension.initialize(serviceExtensionContext); + // invoke + extension.initialize(serviceExtensionContext); - // verify - Mockito.verify(policyEngine, Mockito.times(1)) - .registerFunction( - Mockito.anyString(), - Mockito.eq(Permission.class), - Mockito.eq(BusinessPartnerValidationExtension.BUSINESS_PARTNER_CONSTRAINT_KEY), - Mockito.any()); - } + // verify + verify(policyEngine, Mockito.times(1)) + .registerFunction( + anyString(), + eq(Permission.class), + eq(BusinessPartnerValidationExtension.BUSINESS_PARTNER_CONSTRAINT_KEY), + any()); + } - @Test - void testRegisterProhibitionFunction() { + @Test + void testRegisterProhibitionFunction() { - // invoke - extension.initialize(serviceExtensionContext); + // invoke + extension.initialize(serviceExtensionContext); - // verify - Mockito.verify(policyEngine, Mockito.times(1)) - .registerFunction( - Mockito.anyString(), - Mockito.eq(Prohibition.class), - Mockito.eq(BusinessPartnerValidationExtension.BUSINESS_PARTNER_CONSTRAINT_KEY), - Mockito.any()); - } + // verify + verify(policyEngine, Mockito.times(1)) + .registerFunction( + anyString(), + eq(Prohibition.class), + eq(BusinessPartnerValidationExtension.BUSINESS_PARTNER_CONSTRAINT_KEY), + any()); + } } diff --git a/edc-extensions/control-plane-adapter/build.gradle.kts b/edc-extensions/control-plane-adapter/build.gradle.kts index 715b5da74..02f7b0339 100644 --- a/edc-extensions/control-plane-adapter/build.gradle.kts +++ b/edc-extensions/control-plane-adapter/build.gradle.kts @@ -22,4 +22,5 @@ dependencies { implementation(edc.spi.aggregateservices) + testImplementation(libs.awaitility) } diff --git a/edc-extensions/dataplane-selector-configuration/src/test/java/org/eclipse/tractusx/edc/dataplane/selector/configuration/DataPlaneSelectorConfigurationServiceExtensionEdcExtensionTest.java b/edc-extensions/dataplane-selector-configuration/src/test/java/org/eclipse/tractusx/edc/dataplane/selector/configuration/DataPlaneSelectorConfigurationServiceExtensionEdcExtensionTest.java index fef84076a..278e2493e 100644 --- a/edc-extensions/dataplane-selector-configuration/src/test/java/org/eclipse/tractusx/edc/dataplane/selector/configuration/DataPlaneSelectorConfigurationServiceExtensionEdcExtensionTest.java +++ b/edc-extensions/dataplane-selector-configuration/src/test/java/org/eclipse/tractusx/edc/dataplane/selector/configuration/DataPlaneSelectorConfigurationServiceExtensionEdcExtensionTest.java @@ -20,9 +20,8 @@ package org.eclipse.tractusx.edc.dataplane.selector.configuration; -import java.util.HashMap; -import java.util.Map; import org.eclipse.edc.connector.dataplane.selector.spi.DataPlaneSelectorService; +import org.eclipse.edc.junit.annotations.ComponentTest; import org.eclipse.edc.junit.extensions.EdcExtension; import org.eclipse.edc.runtime.metamodel.annotation.Provides; import org.eclipse.edc.spi.system.ServiceExtension; @@ -33,6 +32,10 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mockito; +import java.util.HashMap; +import java.util.Map; + +@ComponentTest @ExtendWith(EdcExtension.class) class DataPlaneSelectorConfigurationServiceExtensionEdcExtensionTest { diff --git a/edc-extensions/hashicorp-vault/src/test/java/org/eclipse/tractusx/edc/hashicorpvault/AbstractHashicorpIT.java b/edc-extensions/hashicorp-vault/src/test/java/org/eclipse/tractusx/edc/hashicorpvault/AbstractHashicorpIT.java index e196cd27d..084cc158a 100644 --- a/edc-extensions/hashicorp-vault/src/test/java/org/eclipse/tractusx/edc/hashicorpvault/AbstractHashicorpIT.java +++ b/edc-extensions/hashicorp-vault/src/test/java/org/eclipse/tractusx/edc/hashicorpvault/AbstractHashicorpIT.java @@ -20,17 +20,8 @@ package org.eclipse.tractusx.edc.hashicorpvault; -import static org.eclipse.tractusx.edc.hashicorpvault.HashicorpVaultClient.VAULT_DATA_ENTRY_NAME; -import static org.eclipse.tractusx.edc.hashicorpvault.HashicorpVaultVaultExtension.VAULT_TOKEN; -import static org.eclipse.tractusx.edc.hashicorpvault.HashicorpVaultVaultExtension.VAULT_URL; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import java.util.stream.Collectors; import lombok.Getter; +import org.eclipse.edc.junit.annotations.ComponentTest; import org.eclipse.edc.junit.extensions.EdcExtension; import org.eclipse.edc.spi.security.CertificateResolver; import org.eclipse.edc.spi.security.Vault; @@ -50,6 +41,18 @@ import org.testcontainers.utility.DockerImageName; import org.testcontainers.vault.VaultContainer; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.stream.Collectors; + +import static org.eclipse.tractusx.edc.hashicorpvault.HashicorpVaultClient.VAULT_DATA_ENTRY_NAME; +import static org.eclipse.tractusx.edc.hashicorpvault.HashicorpVaultVaultExtension.VAULT_TOKEN; +import static org.eclipse.tractusx.edc.hashicorpvault.HashicorpVaultVaultExtension.VAULT_URL; + +@ComponentTest @Testcontainers @ExtendWith(EdcExtension.class) class AbstractHashicorpIT { diff --git a/edc-extensions/observability-api-customization/src/test/java/org/eclipse/tractusx/edc/api/observability/TxObservabilityApiControllerTest.java b/edc-extensions/observability-api-customization/src/test/java/org/eclipse/tractusx/edc/api/observability/TxObservabilityApiControllerTest.java index 2b2ba0596..2d0c1f570 100644 --- a/edc-extensions/observability-api-customization/src/test/java/org/eclipse/tractusx/edc/api/observability/TxObservabilityApiControllerTest.java +++ b/edc-extensions/observability-api-customization/src/test/java/org/eclipse/tractusx/edc/api/observability/TxObservabilityApiControllerTest.java @@ -22,6 +22,7 @@ import org.eclipse.edc.connector.spi.contractnegotiation.ContractNegotiationService; import org.eclipse.edc.connector.spi.policydefinition.PolicyDefinitionService; import org.eclipse.edc.connector.spi.transferprocess.TransferProcessService; +import org.eclipse.edc.junit.annotations.ApiTest; import org.eclipse.edc.junit.extensions.EdcExtension; import org.eclipse.edc.spi.asset.DataAddressResolver; import org.junit.jupiter.api.BeforeEach; @@ -38,8 +39,7 @@ import static org.hamcrest.Matchers.notNullValue; import static org.mockito.Mockito.mock; -//todo: uncomment after test refactoring -//@ApiTest +@ApiTest @ExtendWith(EdcExtension.class) public class TxObservabilityApiControllerTest { diff --git a/edc-extensions/observability-api-customization/src/test/java/org/eclipse/tractusx/edc/api/observability/TxObservabilityApiExtensionTest.java b/edc-extensions/observability-api-customization/src/test/java/org/eclipse/tractusx/edc/api/observability/TxObservabilityApiExtensionTest.java index c6a2d2d7f..85a1dba77 100644 --- a/edc-extensions/observability-api-customization/src/test/java/org/eclipse/tractusx/edc/api/observability/TxObservabilityApiExtensionTest.java +++ b/edc-extensions/observability-api-customization/src/test/java/org/eclipse/tractusx/edc/api/observability/TxObservabilityApiExtensionTest.java @@ -14,6 +14,7 @@ package org.eclipse.tractusx.edc.api.observability; +import org.eclipse.edc.junit.annotations.ComponentTest; import org.eclipse.edc.junit.extensions.DependencyInjectionExtension; import org.eclipse.edc.spi.system.ServiceExtensionContext; import org.eclipse.edc.spi.system.health.HealthCheckService; @@ -32,6 +33,7 @@ import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.when; +@ComponentTest @ExtendWith(DependencyInjectionExtension.class) class TxObservabilityApiExtensionTest { diff --git a/edc-extensions/provision-additional-headers/src/test/java/org/eclipse/tractusx/edc/provision/additionalheaders/ProvisionAdditionalHeadersExtensionTest.java b/edc-extensions/provision-additional-headers/src/test/java/org/eclipse/tractusx/edc/provision/additionalheaders/ProvisionAdditionalHeadersExtensionTest.java index 205b3c75c..72d68b631 100644 --- a/edc-extensions/provision-additional-headers/src/test/java/org/eclipse/tractusx/edc/provision/additionalheaders/ProvisionAdditionalHeadersExtensionTest.java +++ b/edc-extensions/provision-additional-headers/src/test/java/org/eclipse/tractusx/edc/provision/additionalheaders/ProvisionAdditionalHeadersExtensionTest.java @@ -20,14 +20,11 @@ package org.eclipse.tractusx.edc.provision.additionalheaders; -import static org.assertj.core.api.AssertionsForClassTypes.assertThat; -import static org.awaitility.Awaitility.await; -import static org.mockito.Mockito.*; - import org.eclipse.edc.connector.transfer.spi.TransferProcessManager; import org.eclipse.edc.connector.transfer.spi.flow.DataFlowController; import org.eclipse.edc.connector.transfer.spi.flow.DataFlowManager; import org.eclipse.edc.connector.transfer.spi.types.DataRequest; +import org.eclipse.edc.junit.annotations.ComponentTest; import org.eclipse.edc.junit.extensions.EdcExtension; import org.eclipse.edc.spi.asset.AssetIndex; import org.eclipse.edc.spi.response.StatusResult; @@ -37,6 +34,15 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; +import static org.awaitility.Awaitility.await; +import static org.mockito.Mockito.any; +import static org.mockito.Mockito.argThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +@ComponentTest @ExtendWith(EdcExtension.class) class ProvisionAdditionalHeadersExtensionTest { diff --git a/edc-tests/README.md b/edc-tests/cucumber/README.md similarity index 85% rename from edc-tests/README.md rename to edc-tests/cucumber/README.md index afb62c89a..a9424a5b0 100644 --- a/edc-tests/README.md +++ b/edc-tests/cucumber/README.md @@ -1,5 +1,7 @@ # Invoke Business-Tests via Maven +THIS MODULE IS DEPRECATED AND WILL NOT BE MAINTAINED ANYMORE. + ```shell ./gradlew :edc-tests:test -Dcucumber=true ``` diff --git a/edc-tests/build.gradle.kts b/edc-tests/cucumber/build.gradle.kts similarity index 100% rename from edc-tests/build.gradle.kts rename to edc-tests/cucumber/build.gradle.kts diff --git a/edc-tests/src/main/resources/deployment/helm/omejdn/.helmignore b/edc-tests/cucumber/src/main/resources/deployment/helm/omejdn/.helmignore similarity index 100% rename from edc-tests/src/main/resources/deployment/helm/omejdn/.helmignore rename to edc-tests/cucumber/src/main/resources/deployment/helm/omejdn/.helmignore diff --git a/edc-tests/src/main/resources/deployment/helm/omejdn/Chart.yaml b/edc-tests/cucumber/src/main/resources/deployment/helm/omejdn/Chart.yaml similarity index 100% rename from edc-tests/src/main/resources/deployment/helm/omejdn/Chart.yaml rename to edc-tests/cucumber/src/main/resources/deployment/helm/omejdn/Chart.yaml diff --git a/edc-tests/src/main/resources/deployment/helm/omejdn/README.md b/edc-tests/cucumber/src/main/resources/deployment/helm/omejdn/README.md similarity index 100% rename from edc-tests/src/main/resources/deployment/helm/omejdn/README.md rename to edc-tests/cucumber/src/main/resources/deployment/helm/omejdn/README.md diff --git a/edc-tests/src/main/resources/deployment/helm/omejdn/templates/_helpers.tpl b/edc-tests/cucumber/src/main/resources/deployment/helm/omejdn/templates/_helpers.tpl similarity index 100% rename from edc-tests/src/main/resources/deployment/helm/omejdn/templates/_helpers.tpl rename to edc-tests/cucumber/src/main/resources/deployment/helm/omejdn/templates/_helpers.tpl diff --git a/edc-tests/src/main/resources/deployment/helm/omejdn/templates/configmap.yaml b/edc-tests/cucumber/src/main/resources/deployment/helm/omejdn/templates/configmap.yaml similarity index 100% rename from edc-tests/src/main/resources/deployment/helm/omejdn/templates/configmap.yaml rename to edc-tests/cucumber/src/main/resources/deployment/helm/omejdn/templates/configmap.yaml diff --git a/edc-tests/src/main/resources/deployment/helm/omejdn/templates/deployment.yaml b/edc-tests/cucumber/src/main/resources/deployment/helm/omejdn/templates/deployment.yaml similarity index 100% rename from edc-tests/src/main/resources/deployment/helm/omejdn/templates/deployment.yaml rename to edc-tests/cucumber/src/main/resources/deployment/helm/omejdn/templates/deployment.yaml diff --git a/edc-tests/src/main/resources/deployment/helm/omejdn/templates/hpa.yaml b/edc-tests/cucumber/src/main/resources/deployment/helm/omejdn/templates/hpa.yaml similarity index 100% rename from edc-tests/src/main/resources/deployment/helm/omejdn/templates/hpa.yaml rename to edc-tests/cucumber/src/main/resources/deployment/helm/omejdn/templates/hpa.yaml diff --git a/edc-tests/src/main/resources/deployment/helm/omejdn/templates/imagepullsecret.yaml b/edc-tests/cucumber/src/main/resources/deployment/helm/omejdn/templates/imagepullsecret.yaml similarity index 100% rename from edc-tests/src/main/resources/deployment/helm/omejdn/templates/imagepullsecret.yaml rename to edc-tests/cucumber/src/main/resources/deployment/helm/omejdn/templates/imagepullsecret.yaml diff --git a/edc-tests/src/main/resources/deployment/helm/omejdn/templates/service.yaml b/edc-tests/cucumber/src/main/resources/deployment/helm/omejdn/templates/service.yaml similarity index 100% rename from edc-tests/src/main/resources/deployment/helm/omejdn/templates/service.yaml rename to edc-tests/cucumber/src/main/resources/deployment/helm/omejdn/templates/service.yaml diff --git a/edc-tests/src/main/resources/deployment/helm/omejdn/templates/serviceaccount.yaml b/edc-tests/cucumber/src/main/resources/deployment/helm/omejdn/templates/serviceaccount.yaml similarity index 100% rename from edc-tests/src/main/resources/deployment/helm/omejdn/templates/serviceaccount.yaml rename to edc-tests/cucumber/src/main/resources/deployment/helm/omejdn/templates/serviceaccount.yaml diff --git a/edc-tests/src/main/resources/deployment/helm/omejdn/values.yaml b/edc-tests/cucumber/src/main/resources/deployment/helm/omejdn/values.yaml similarity index 100% rename from edc-tests/src/main/resources/deployment/helm/omejdn/values.yaml rename to edc-tests/cucumber/src/main/resources/deployment/helm/omejdn/values.yaml diff --git a/edc-tests/src/main/resources/deployment/helm/supporting-infrastructure/.gitignore b/edc-tests/cucumber/src/main/resources/deployment/helm/supporting-infrastructure/.gitignore similarity index 100% rename from edc-tests/src/main/resources/deployment/helm/supporting-infrastructure/.gitignore rename to edc-tests/cucumber/src/main/resources/deployment/helm/supporting-infrastructure/.gitignore diff --git a/edc-tests/src/main/resources/deployment/helm/supporting-infrastructure/.helmignore b/edc-tests/cucumber/src/main/resources/deployment/helm/supporting-infrastructure/.helmignore similarity index 100% rename from edc-tests/src/main/resources/deployment/helm/supporting-infrastructure/.helmignore rename to edc-tests/cucumber/src/main/resources/deployment/helm/supporting-infrastructure/.helmignore diff --git a/edc-tests/src/main/resources/deployment/helm/supporting-infrastructure/Chart.yaml b/edc-tests/cucumber/src/main/resources/deployment/helm/supporting-infrastructure/Chart.yaml similarity index 100% rename from edc-tests/src/main/resources/deployment/helm/supporting-infrastructure/Chart.yaml rename to edc-tests/cucumber/src/main/resources/deployment/helm/supporting-infrastructure/Chart.yaml diff --git a/edc-tests/src/main/resources/deployment/helm/supporting-infrastructure/README.md b/edc-tests/cucumber/src/main/resources/deployment/helm/supporting-infrastructure/README.md similarity index 100% rename from edc-tests/src/main/resources/deployment/helm/supporting-infrastructure/README.md rename to edc-tests/cucumber/src/main/resources/deployment/helm/supporting-infrastructure/README.md diff --git a/edc-tests/src/main/resources/deployment/helm/supporting-infrastructure/diagrams/deployed_components.png b/edc-tests/cucumber/src/main/resources/deployment/helm/supporting-infrastructure/diagrams/deployed_components.png similarity index 100% rename from edc-tests/src/main/resources/deployment/helm/supporting-infrastructure/diagrams/deployed_components.png rename to edc-tests/cucumber/src/main/resources/deployment/helm/supporting-infrastructure/diagrams/deployed_components.png diff --git a/edc-tests/src/main/resources/deployment/helm/supporting-infrastructure/diagrams/deployed_components.puml b/edc-tests/cucumber/src/main/resources/deployment/helm/supporting-infrastructure/diagrams/deployed_components.puml similarity index 100% rename from edc-tests/src/main/resources/deployment/helm/supporting-infrastructure/diagrams/deployed_components.puml rename to edc-tests/cucumber/src/main/resources/deployment/helm/supporting-infrastructure/diagrams/deployed_components.puml diff --git a/edc-tests/src/main/resources/deployment/helm/supporting-infrastructure/values.yaml b/edc-tests/cucumber/src/main/resources/deployment/helm/supporting-infrastructure/values.yaml similarity index 100% rename from edc-tests/src/main/resources/deployment/helm/supporting-infrastructure/values.yaml rename to edc-tests/cucumber/src/main/resources/deployment/helm/supporting-infrastructure/values.yaml diff --git a/edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/AssetStepDefs.java b/edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/AssetStepDefs.java similarity index 100% rename from edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/AssetStepDefs.java rename to edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/AssetStepDefs.java diff --git a/edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/BackendServiceBackendAPI.java b/edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/BackendServiceBackendAPI.java similarity index 100% rename from edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/BackendServiceBackendAPI.java rename to edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/BackendServiceBackendAPI.java diff --git a/edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/BackendServiceSteps.java b/edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/BackendServiceSteps.java similarity index 100% rename from edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/BackendServiceSteps.java rename to edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/BackendServiceSteps.java diff --git a/edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/CatalogStepDefs.java b/edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/CatalogStepDefs.java similarity index 100% rename from edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/CatalogStepDefs.java rename to edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/CatalogStepDefs.java diff --git a/edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/Connector.java b/edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/Connector.java similarity index 100% rename from edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/Connector.java rename to edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/Connector.java diff --git a/edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/ConnectorFactory.java b/edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/ConnectorFactory.java similarity index 100% rename from edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/ConnectorFactory.java rename to edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/ConnectorFactory.java diff --git a/edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/ConnectorSteps.java b/edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/ConnectorSteps.java similarity index 100% rename from edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/ConnectorSteps.java rename to edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/ConnectorSteps.java diff --git a/edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/Constants.java b/edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/Constants.java similarity index 100% rename from edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/Constants.java rename to edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/Constants.java diff --git a/edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/ContractDefinitionStepDefs.java b/edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/ContractDefinitionStepDefs.java similarity index 100% rename from edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/ContractDefinitionStepDefs.java rename to edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/ContractDefinitionStepDefs.java diff --git a/edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/ControlPlaneAdapterSteps.java b/edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/ControlPlaneAdapterSteps.java similarity index 100% rename from edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/ControlPlaneAdapterSteps.java rename to edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/ControlPlaneAdapterSteps.java diff --git a/edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/DataManagementAPI.java b/edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/DataManagementAPI.java similarity index 100% rename from edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/DataManagementAPI.java rename to edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/DataManagementAPI.java diff --git a/edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/Environment.java b/edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/Environment.java similarity index 100% rename from edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/Environment.java rename to edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/Environment.java diff --git a/edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/HttpProxyTransferSteps.java b/edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/HttpProxyTransferSteps.java similarity index 100% rename from edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/HttpProxyTransferSteps.java rename to edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/HttpProxyTransferSteps.java diff --git a/edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/NegotiationSteps.java b/edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/NegotiationSteps.java similarity index 100% rename from edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/NegotiationSteps.java rename to edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/NegotiationSteps.java diff --git a/edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/PolicyStepDefs.java b/edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/PolicyStepDefs.java similarity index 100% rename from edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/PolicyStepDefs.java rename to edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/PolicyStepDefs.java diff --git a/edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/S3FileTransferStepsDefs.java b/edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/S3FileTransferStepsDefs.java similarity index 100% rename from edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/S3FileTransferStepsDefs.java rename to edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/S3FileTransferStepsDefs.java diff --git a/edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/data/Asset.java b/edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/data/Asset.java similarity index 100% rename from edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/data/Asset.java rename to edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/data/Asset.java diff --git a/edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/data/BusinessPartnerNumberConstraint.java b/edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/data/BusinessPartnerNumberConstraint.java similarity index 100% rename from edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/data/BusinessPartnerNumberConstraint.java rename to edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/data/BusinessPartnerNumberConstraint.java diff --git a/edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/data/Constraint.java b/edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/data/Constraint.java similarity index 100% rename from edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/data/Constraint.java rename to edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/data/Constraint.java diff --git a/edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/data/ContractDefinition.java b/edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/data/ContractDefinition.java similarity index 100% rename from edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/data/ContractDefinition.java rename to edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/data/ContractDefinition.java diff --git a/edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/data/ContractNegotiation.java b/edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/data/ContractNegotiation.java similarity index 100% rename from edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/data/ContractNegotiation.java rename to edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/data/ContractNegotiation.java diff --git a/edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/data/ContractNegotiationState.java b/edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/data/ContractNegotiationState.java similarity index 100% rename from edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/data/ContractNegotiationState.java rename to edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/data/ContractNegotiationState.java diff --git a/edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/data/ContractOffer.java b/edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/data/ContractOffer.java similarity index 100% rename from edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/data/ContractOffer.java rename to edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/data/ContractOffer.java diff --git a/edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/data/DataAddress.java b/edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/data/DataAddress.java similarity index 100% rename from edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/data/DataAddress.java rename to edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/data/DataAddress.java diff --git a/edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/data/HttpProxySinkDataAddress.java b/edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/data/HttpProxySinkDataAddress.java similarity index 100% rename from edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/data/HttpProxySinkDataAddress.java rename to edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/data/HttpProxySinkDataAddress.java diff --git a/edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/data/HttpProxySourceDataAddress.java b/edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/data/HttpProxySourceDataAddress.java similarity index 100% rename from edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/data/HttpProxySourceDataAddress.java rename to edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/data/HttpProxySourceDataAddress.java diff --git a/edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/data/Negotiation.java b/edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/data/Negotiation.java similarity index 100% rename from edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/data/Negotiation.java rename to edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/data/Negotiation.java diff --git a/edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/data/NullDataAddress.java b/edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/data/NullDataAddress.java similarity index 100% rename from edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/data/NullDataAddress.java rename to edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/data/NullDataAddress.java diff --git a/edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/data/OrConstraint.java b/edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/data/OrConstraint.java similarity index 100% rename from edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/data/OrConstraint.java rename to edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/data/OrConstraint.java diff --git a/edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/data/PayMeConstraint.java b/edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/data/PayMeConstraint.java similarity index 100% rename from edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/data/PayMeConstraint.java rename to edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/data/PayMeConstraint.java diff --git a/edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/data/Permission.java b/edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/data/Permission.java similarity index 100% rename from edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/data/Permission.java rename to edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/data/Permission.java diff --git a/edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/data/Policy.java b/edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/data/Policy.java similarity index 100% rename from edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/data/Policy.java rename to edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/data/Policy.java diff --git a/edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/data/S3DataAddress.java b/edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/data/S3DataAddress.java similarity index 100% rename from edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/data/S3DataAddress.java rename to edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/data/S3DataAddress.java diff --git a/edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/data/Transfer.java b/edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/data/Transfer.java similarity index 100% rename from edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/data/Transfer.java rename to edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/data/Transfer.java diff --git a/edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/data/TransferProcess.java b/edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/data/TransferProcess.java similarity index 100% rename from edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/data/TransferProcess.java rename to edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/data/TransferProcess.java diff --git a/edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/data/TransferProcessState.java b/edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/data/TransferProcessState.java similarity index 100% rename from edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/data/TransferProcessState.java rename to edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/data/TransferProcessState.java diff --git a/edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/features/ParameterTypes.java b/edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/features/ParameterTypes.java similarity index 100% rename from edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/features/ParameterTypes.java rename to edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/features/ParameterTypes.java diff --git a/edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/features/RunCucumberTest.java b/edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/features/RunCucumberTest.java similarity index 100% rename from edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/features/RunCucumberTest.java rename to edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/features/RunCucumberTest.java diff --git a/edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/util/DatabaseCleaner.java b/edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/util/DatabaseCleaner.java similarity index 100% rename from edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/util/DatabaseCleaner.java rename to edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/util/DatabaseCleaner.java diff --git a/edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/util/S3Client.java b/edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/util/S3Client.java similarity index 100% rename from edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/util/S3Client.java rename to edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/util/S3Client.java diff --git a/edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/util/Timeouts.java b/edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/util/Timeouts.java similarity index 100% rename from edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/util/Timeouts.java rename to edc-tests/cucumber/src/test/java/org/eclipse/tractusx/edc/tests/util/Timeouts.java diff --git a/edc-tests/src/test/resources/junit-platform.properties b/edc-tests/cucumber/src/test/resources/junit-platform.properties similarity index 100% rename from edc-tests/src/test/resources/junit-platform.properties rename to edc-tests/cucumber/src/test/resources/junit-platform.properties diff --git a/edc-tests/src/test/resources/logback-test.xml b/edc-tests/cucumber/src/test/resources/logback-test.xml similarity index 100% rename from edc-tests/src/test/resources/logback-test.xml rename to edc-tests/cucumber/src/test/resources/logback-test.xml diff --git a/edc-tests/src/test/resources/org/eclipse/tractusx/edc/tests/features/ContractNegotiation.feature b/edc-tests/cucumber/src/test/resources/org/eclipse/tractusx/edc/tests/features/ContractNegotiation.feature similarity index 100% rename from edc-tests/src/test/resources/org/eclipse/tractusx/edc/tests/features/ContractNegotiation.feature rename to edc-tests/cucumber/src/test/resources/org/eclipse/tractusx/edc/tests/features/ContractNegotiation.feature diff --git a/edc-tests/src/test/resources/org/eclipse/tractusx/edc/tests/features/ContractOffers.feature b/edc-tests/cucumber/src/test/resources/org/eclipse/tractusx/edc/tests/features/ContractOffers.feature similarity index 100% rename from edc-tests/src/test/resources/org/eclipse/tractusx/edc/tests/features/ContractOffers.feature rename to edc-tests/cucumber/src/test/resources/org/eclipse/tractusx/edc/tests/features/ContractOffers.feature diff --git a/edc-tests/src/test/resources/org/eclipse/tractusx/edc/tests/features/EndToEndTransfer.feature b/edc-tests/cucumber/src/test/resources/org/eclipse/tractusx/edc/tests/features/EndToEndTransfer.feature similarity index 100% rename from edc-tests/src/test/resources/org/eclipse/tractusx/edc/tests/features/EndToEndTransfer.feature rename to edc-tests/cucumber/src/test/resources/org/eclipse/tractusx/edc/tests/features/EndToEndTransfer.feature diff --git a/edc-tests/src/test/resources/org/eclipse/tractusx/edc/tests/features/HttpProxyDataTransfer.feature b/edc-tests/cucumber/src/test/resources/org/eclipse/tractusx/edc/tests/features/HttpProxyDataTransfer.feature similarity index 100% rename from edc-tests/src/test/resources/org/eclipse/tractusx/edc/tests/features/HttpProxyDataTransfer.feature rename to edc-tests/cucumber/src/test/resources/org/eclipse/tractusx/edc/tests/features/HttpProxyDataTransfer.feature diff --git a/edc-tests/src/test/resources/org/eclipse/tractusx/edc/tests/features/S3FileTransfer.feature b/edc-tests/cucumber/src/test/resources/org/eclipse/tractusx/edc/tests/features/S3FileTransfer.feature similarity index 100% rename from edc-tests/src/test/resources/org/eclipse/tractusx/edc/tests/features/S3FileTransfer.feature rename to edc-tests/cucumber/src/test/resources/org/eclipse/tractusx/edc/tests/features/S3FileTransfer.feature diff --git a/edc-tests/e2e-tests/README.md b/edc-tests/e2e-tests/README.md new file mode 100644 index 000000000..cdde986b0 --- /dev/null +++ b/edc-tests/e2e-tests/README.md @@ -0,0 +1,3 @@ +# E2E-Tests + +This module contains JUnit tests that spin up multiple runtimes in one JVM. \ No newline at end of file diff --git a/edc-tests/e2e-tests/build.gradle.kts b/edc-tests/e2e-tests/build.gradle.kts new file mode 100644 index 000000000..b456d3e59 --- /dev/null +++ b/edc-tests/e2e-tests/build.gradle.kts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * + * 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: + * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation + * + */ + +plugins { + `java-library` +} + +dependencies { + testImplementation(libs.restAssured) + testImplementation(libs.postgres) + testImplementation(libs.awaitility) + testImplementation(libs.aws.s3) + testImplementation(edc.spi.core) + testImplementation(edc.junit) + testImplementation(edc.spi.policy) + testImplementation(edc.spi.contract) + testImplementation(edc.core.api) + testImplementation(edc.spi.catalog) + testImplementation(edc.api.catalog) + testImplementation(testFixtures(edc.junit)) +} diff --git a/edc-tests/e2e-tests/src/test/java/org/eclipse/tractusx/edc/lifecycle/DataWiper.java b/edc-tests/e2e-tests/src/test/java/org/eclipse/tractusx/edc/lifecycle/DataWiper.java new file mode 100644 index 000000000..e99cf0989 --- /dev/null +++ b/edc-tests/e2e-tests/src/test/java/org/eclipse/tractusx/edc/lifecycle/DataWiper.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * + * 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: + * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation + * + */ + +package org.eclipse.tractusx.edc.lifecycle; + +import org.eclipse.edc.connector.contract.spi.offer.store.ContractDefinitionStore; +import org.eclipse.edc.connector.policy.spi.store.PolicyDefinitionStore; +import org.eclipse.edc.spi.asset.AssetIndex; +import org.eclipse.edc.spi.query.QuerySpec; +import org.eclipse.edc.spi.system.ServiceExtensionContext; + +import java.util.stream.Collectors; + +/** + * Helper class to delete all objects from a runtime's data stores. + */ +public class DataWiper { + + private final ServiceExtensionContext context; + + public DataWiper(ServiceExtensionContext context) { + this.context = context; + } + + public void clearPersistence() { + clearAssetIndex(); + clearPolicies(); + clearContractDefinitions(); + } + + public void clearContractDefinitions() { + var cds = context.getService(ContractDefinitionStore.class); + cds.findAll(QuerySpec.max()).forEach(cd -> cds.deleteById(cd.getId())); + } + + public void clearPolicies() { + var ps = context.getService(PolicyDefinitionStore.class); + // must .collect() here, otherwise we'll get a ConcurrentModificationException + ps.findAll(QuerySpec.max()).collect(Collectors.toList()).forEach(p -> ps.deleteById(p.getId())); + } + + public void clearAssetIndex() { + var index = context.getService(AssetIndex.class); + index.queryAssets(QuerySpec.max()).forEach(asset -> index.deleteById(asset.getId())); + } +} diff --git a/edc-tests/e2e-tests/src/test/java/org/eclipse/tractusx/edc/lifecycle/MultiRuntimeTest.java b/edc-tests/e2e-tests/src/test/java/org/eclipse/tractusx/edc/lifecycle/MultiRuntimeTest.java new file mode 100644 index 000000000..e007a824d --- /dev/null +++ b/edc-tests/e2e-tests/src/test/java/org/eclipse/tractusx/edc/lifecycle/MultiRuntimeTest.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * + * 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: + * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation + * + */ + +package org.eclipse.tractusx.edc.lifecycle; + + +import org.junit.jupiter.api.extension.RegisterExtension; + +import java.util.Map; + +import static java.lang.String.format; +import static org.eclipse.edc.junit.testfixtures.TestUtils.tempDirectory; +import static org.eclipse.tractusx.edc.lifecycle.TestRuntimeConfiguration.IDS_PATH; +import static org.eclipse.tractusx.edc.lifecycle.TestRuntimeConfiguration.PLATO_CONNECTOR_PATH; +import static org.eclipse.tractusx.edc.lifecycle.TestRuntimeConfiguration.PLATO_CONNECTOR_PORT; +import static org.eclipse.tractusx.edc.lifecycle.TestRuntimeConfiguration.PLATO_IDS_API; +import static org.eclipse.tractusx.edc.lifecycle.TestRuntimeConfiguration.PLATO_IDS_API_PORT; +import static org.eclipse.tractusx.edc.lifecycle.TestRuntimeConfiguration.PLATO_MANAGEMENT_PATH; +import static org.eclipse.tractusx.edc.lifecycle.TestRuntimeConfiguration.PLATO_MANAGEMENT_PORT; +import static org.eclipse.tractusx.edc.lifecycle.TestRuntimeConfiguration.SOKRATES_ASSET_FILE; +import static org.eclipse.tractusx.edc.lifecycle.TestRuntimeConfiguration.SOKRATES_CONNECTOR_PATH; +import static org.eclipse.tractusx.edc.lifecycle.TestRuntimeConfiguration.SOKRATES_CONNECTOR_PORT; +import static org.eclipse.tractusx.edc.lifecycle.TestRuntimeConfiguration.SOKRATES_IDS_API; +import static org.eclipse.tractusx.edc.lifecycle.TestRuntimeConfiguration.SOKRATES_IDS_API_PORT; +import static org.eclipse.tractusx.edc.lifecycle.TestRuntimeConfiguration.SOKRATES_MANAGEMENT_PATH; +import static org.eclipse.tractusx.edc.lifecycle.TestRuntimeConfiguration.SOKRATES_MANAGEMENT_PORT; + + +public class MultiRuntimeTest { + + public static final String SOKRATES_ASSET_PATH = format("%s/%s.txt", tempDirectory(), SOKRATES_ASSET_FILE); + + @RegisterExtension + protected static Participant sokrates = new Participant( + ":edc-tests:runtime", + "SOKRATES", + Map.of( + "edc.ids.id", "urn:connector:sokrates", + "web.http.port", String.valueOf(SOKRATES_CONNECTOR_PORT), + "web.http.path", SOKRATES_CONNECTOR_PATH, + "edc.test.asset.path", SOKRATES_ASSET_PATH, + "web.http.management.port", String.valueOf(SOKRATES_MANAGEMENT_PORT), + "web.http.management.path", SOKRATES_MANAGEMENT_PATH, + "web.http.ids.port", String.valueOf(SOKRATES_IDS_API_PORT), + "web.http.ids.path", IDS_PATH, + "edc.api.auth.key", "testkey", + "ids.webhook.address", SOKRATES_IDS_API)); + @RegisterExtension + protected static Participant plato = new Participant( + ":edc-tests:runtime", + "PLATO", + Map.of( + "edc.ids.id", "urn:connector:plato", + "web.http.default.port", String.valueOf(PLATO_CONNECTOR_PORT), + "web.http.default.path", PLATO_CONNECTOR_PATH, + "web.http.management.port", String.valueOf(PLATO_MANAGEMENT_PORT), + "web.http.management.path", PLATO_MANAGEMENT_PATH, + "web.http.ids.port", String.valueOf(PLATO_IDS_API_PORT), + "web.http.ids.path", IDS_PATH, + "edc.api.auth.key", "testkey", + "ids.webhook.address", PLATO_IDS_API)); + + +} diff --git a/edc-tests/e2e-tests/src/test/java/org/eclipse/tractusx/edc/lifecycle/Participant.java b/edc-tests/e2e-tests/src/test/java/org/eclipse/tractusx/edc/lifecycle/Participant.java new file mode 100644 index 000000000..7f17696ba --- /dev/null +++ b/edc-tests/e2e-tests/src/test/java/org/eclipse/tractusx/edc/lifecycle/Participant.java @@ -0,0 +1,202 @@ +/* + * Copyright (c) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * + * 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: + * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation + * + */ + +package org.eclipse.tractusx.edc.lifecycle; + +import io.restassured.specification.RequestSpecification; +import org.eclipse.edc.api.query.QuerySpecDto; +import org.eclipse.edc.catalog.spi.Catalog; +import org.eclipse.edc.connector.api.management.catalog.model.CatalogRequestDto; +import org.eclipse.edc.connector.policy.spi.PolicyDefinition; +import org.eclipse.edc.junit.extensions.EdcRuntimeExtension; +import org.eclipse.edc.spi.asset.AssetSelectorExpression; +import org.eclipse.edc.spi.iam.IdentityService; +import org.eclipse.edc.spi.system.ServiceExtension; +import org.eclipse.edc.spi.system.ServiceExtensionContext; +import org.eclipse.edc.spi.system.injection.InjectionContainer; +import org.eclipse.edc.spi.types.TypeManager; +import org.eclipse.tractusx.edc.token.MockDapsService; +import org.junit.jupiter.api.extension.AfterAllCallback; +import org.junit.jupiter.api.extension.BeforeAllCallback; +import org.junit.jupiter.api.extension.ExtensionContext; + +import java.net.URI; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static io.restassured.RestAssured.given; +import static io.restassured.http.ContentType.JSON; +import static java.lang.String.format; +import static org.assertj.core.api.Assertions.assertThat; + +public class Participant extends EdcRuntimeExtension implements BeforeAllCallback, AfterAllCallback { + + private final String managementUrl; + private final String apiKey; + private final String idsEndpoint; + private final TypeManager typeManager = new TypeManager(); + private final String idsId; + private DataWiper wiper; + private final String bpn; + + public Participant(String moduleName, String runtimeName, Map properties) { + super(moduleName, runtimeName, properties); + this.managementUrl = URI.create(format("http://localhost:%s%s", properties.get("web.http.management.port"), properties.get("web.http.management.path"))).toString(); + this.idsEndpoint = URI.create(format("http://localhost:%s%s", properties.get("web.http.ids.port"), properties.get("web.http.ids.path"))).toString(); + this.apiKey = properties.get("edc.api.auth.key"); + this.idsId = properties.get("edc.ids.id"); + this.bpn = runtimeName + "-BPN"; + this.registerServiceMock(IdentityService.class, new MockDapsService(getBpn())); + } + + @Override + public void beforeTestExecution(ExtensionContext extensionContext) throws Exception { + //do nothing - we only want to start the runtime once + wiper.clearPersistence(); + } + + @Override + public void afterTestExecution(ExtensionContext context) throws Exception { + } + + @Override + protected void bootExtensions(ServiceExtensionContext context, List> serviceExtensions) { + super.bootExtensions(context, serviceExtensions); + wiper = new DataWiper(context); + } + + /** + * Creates an asset with the given ID and props using the participant's Data Management API + */ + public void createAsset(String id, Map properties) { + properties = new HashMap<>(properties); + properties.put("asset:prop:id", id); + properties.put("asset:prop:description", "test description"); + + var asset = Map.of( + "asset", Map.of( + "id", id, + "properties", properties + ), + "dataAddress", Map.of( + "properties", Map.of("type", "test-type") + + ) + ); + + baseRequest() + .body(asset) + .when() + .post("/assets") + .then() + .statusCode(200) + .contentType(JSON); + + } + + /** + * Creates a {@link org.eclipse.edc.connector.contract.spi.types.offer.ContractDefinition} using the participant's Data Management API + */ + public void createContractDefinition(String assetId, String definitionId, String accessPolicyId, String contractPolicyId, long contractValidityDurationSeconds) { + var contractDefinition = Map.of( + "id", definitionId, + "accessPolicyId", accessPolicyId, + "validity", String.valueOf(contractValidityDurationSeconds), + "contractPolicyId", contractPolicyId, + "criteria", AssetSelectorExpression.Builder.newInstance().constraint("asset:prop:id", "=", assetId).build().getCriteria() + ); + + baseRequest() + .body(contractDefinition) + .when() + .post("/contractdefinitions") + .then() + .statusCode(200) + .contentType(JSON).contentType(JSON); + } + + /** + * Creates a {@link PolicyDefinition} using the participant's Data Management API + */ + public void createPolicy(PolicyDefinition policyDefinition) { + baseRequest() + .body(policyDefinition) + .when() + .post("/policydefinitions") + .then() + .statusCode(200) + .contentType(JSON).contentType(JSON); + } + + /** + * Requests the {@link Catalog} from another participant using this participant's Data Management API + */ + public Catalog requestCatalog(Participant other) { + return requestCatalog(other, QuerySpecDto.Builder.newInstance().build()); + } + + /** + * Requests the {@link Catalog} from another participant using this participant's Data Management API + */ + public Catalog requestCatalog(Participant other, QuerySpecDto query) { + var response = baseRequest() + .when() + .body(CatalogRequestDto.Builder.newInstance() + .providerUrl(other.idsEndpoint + "/data") + .querySpec(query) + .build()) + .post("/catalog/request") + .then(); + + var code = response.extract().statusCode(); + var body = response.extract().body().asString(); + + // doing an assertJ style assertion will allow us to use the body as fail message if the return code != 200 + assertThat(code).withFailMessage(body).isEqualTo(200); + return typeManager.readValue(body, Catalog.class); + } + + /** + * Returns this participant's IDS ID + */ + public String idsId() { + return idsId; + } + + /** + * Returns this participant's BusinessPartnerNumber (=BPN). This is constructed of the runtime name plus "-BPN" + */ + public String getBpn() { + return bpn; + } + + @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); + } + + private RequestSpecification baseRequest() { + return given() + .baseUri(managementUrl) + .header("x-api-key", apiKey) + .contentType(JSON); + } +} diff --git a/edc-tests/e2e-tests/src/test/java/org/eclipse/tractusx/edc/lifecycle/TestRuntimeConfiguration.java b/edc-tests/e2e-tests/src/test/java/org/eclipse/tractusx/edc/lifecycle/TestRuntimeConfiguration.java new file mode 100644 index 000000000..145ae476f --- /dev/null +++ b/edc-tests/e2e-tests/src/test/java/org/eclipse/tractusx/edc/lifecycle/TestRuntimeConfiguration.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * + * 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: + * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation + * + */ + +package org.eclipse.tractusx.edc.lifecycle; + +import java.util.concurrent.TimeUnit; + +import static org.eclipse.edc.junit.testfixtures.TestUtils.getFreePort; + +public class TestRuntimeConfiguration { + + + public static final String IDS_PATH = "/api/v1/ids"; + + + public static final int PLATO_CONNECTOR_PORT = getFreePort(); + public static final int PLATO_MANAGEMENT_PORT = getFreePort(); + public static final String PLATO_CONNECTOR_PATH = "/api"; + public static final String PLATO_MANAGEMENT_PATH = "/api/v1/management"; + public static final String CONSUMER_CONNECTOR_MANAGEMENT_URL = "http://localhost:" + PLATO_MANAGEMENT_PORT + PLATO_MANAGEMENT_PATH; + public static final int PLATO_IDS_API_PORT = getFreePort(); + public static final String PLATO_IDS_API = "http://localhost:" + PLATO_IDS_API_PORT; + + public static final int SOKRATES_CONNECTOR_PORT = getFreePort(); + public static final int SOKRATES_MANAGEMENT_PORT = getFreePort(); + public static final String SOKRATES_CONNECTOR_PATH = "/api"; + public static final String SOKRATES_MANAGEMENT_PATH = "/api/v1/management"; + public static final int SOKRATES_IDS_API_PORT = getFreePort(); + public static final String SOKRATES_IDS_API = "http://localhost:" + SOKRATES_IDS_API_PORT; + + public static final String PROVIDER_IDS_API_DATA = "http://localhost:" + SOKRATES_IDS_API_PORT + IDS_PATH + "/data"; + + public static final String PROVIDER_ASSET_ID = "test-document"; + public static final long CONTRACT_VALIDITY = TimeUnit.HOURS.toSeconds(1); + + public static final String SOKRATES_ASSET_FILE = "text-document.txt"; + + public static final String PROVIDER_CONNECTOR_MANAGEMENT_URL = "http://localhost:" + SOKRATES_MANAGEMENT_PORT + SOKRATES_MANAGEMENT_PATH; + + +} diff --git a/edc-tests/e2e-tests/src/test/java/org/eclipse/tractusx/edc/policy/PolicyHelperFunctions.java b/edc-tests/e2e-tests/src/test/java/org/eclipse/tractusx/edc/policy/PolicyHelperFunctions.java new file mode 100644 index 000000000..b255aa078 --- /dev/null +++ b/edc-tests/e2e-tests/src/test/java/org/eclipse/tractusx/edc/policy/PolicyHelperFunctions.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * + * 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: + * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation + * + */ + +package org.eclipse.tractusx.edc.policy; + + +import org.eclipse.edc.connector.policy.spi.PolicyDefinition; +import org.eclipse.edc.policy.model.Action; +import org.eclipse.edc.policy.model.AtomicConstraint; +import org.eclipse.edc.policy.model.Constraint; +import org.eclipse.edc.policy.model.LiteralExpression; +import org.eclipse.edc.policy.model.Operator; +import org.eclipse.edc.policy.model.OrConstraint; +import org.eclipse.edc.policy.model.Permission; +import org.eclipse.edc.policy.model.Policy; + +import java.util.stream.Collectors; +import java.util.stream.Stream; + +public class PolicyHelperFunctions { + /** + * Creates a {@link PolicyDefinition} using the given ID, that contains equality constraints for each of the given BusinessPartnerNumbers: + * each BPN is converted into an {@link AtomicConstraint} {@code BusinessPartnerNumber EQ [BPN]}. + */ + public static PolicyDefinition businessPartnerNumberPolicy(String id, String... bpns) { + + var bpnConstraints = Stream.of(bpns) + .map(bpn -> (Constraint) AtomicConstraint.Builder.newInstance() + .leftExpression(new LiteralExpression("BusinessPartnerNumber")) + .operator(Operator.EQ) + .rightExpression(new LiteralExpression(bpn)) + .build()) + .collect(Collectors.toList()); + + return PolicyDefinition.Builder.newInstance() + .id(id) + .policy(Policy.Builder.newInstance() + .permission(Permission.Builder.newInstance() + .action(Action.Builder.newInstance().type("USE").build()) + .constraint(OrConstraint.Builder.newInstance() + .constraints(bpnConstraints) + .build()) + .build()).build()).build(); + } +} diff --git a/edc-tests/e2e-tests/src/test/java/org/eclipse/tractusx/edc/tests/CatalogTest.java b/edc-tests/e2e-tests/src/test/java/org/eclipse/tractusx/edc/tests/CatalogTest.java new file mode 100644 index 000000000..b7812ae4a --- /dev/null +++ b/edc-tests/e2e-tests/src/test/java/org/eclipse/tractusx/edc/tests/CatalogTest.java @@ -0,0 +1,148 @@ +/* + * Copyright (c) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * + * 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: + * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation + * + */ + +package org.eclipse.tractusx.edc.tests; + + +import org.eclipse.edc.api.query.QuerySpecDto; +import org.eclipse.edc.connector.policy.spi.PolicyDefinition; +import org.eclipse.edc.junit.annotations.EndToEndTest; +import org.eclipse.edc.policy.model.Action; +import org.eclipse.edc.policy.model.Permission; +import org.eclipse.edc.policy.model.Policy; +import org.eclipse.edc.policy.model.PolicyType; +import org.eclipse.tractusx.edc.lifecycle.MultiRuntimeTest; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +import java.util.Map; + +import static java.util.stream.IntStream.range; +import static org.assertj.core.api.Assertions.assertThat; +import static org.eclipse.tractusx.edc.policy.PolicyHelperFunctions.businessPartnerNumberPolicy; + +@EndToEndTest +public class CatalogTest extends MultiRuntimeTest { + + + @BeforeAll + static void setup() { + + } + + @Test + void requestCatalog_fulfillsPolicy_shouldReturnOffer() { + // arrange + sokrates.createAsset("test-asset", Map.of("fooprop", "fooval")); + var accessPolicy = noConstraintPolicy("test-ap1"); + var contractPolicy = noConstraintPolicy("test-cp1"); + sokrates.createPolicy(accessPolicy); + sokrates.createPolicy(contractPolicy); + sokrates.createContractDefinition("test-asset", "test-def", "test-ap1", "test-cp1", 60); + + // act + var catalog = plato.requestCatalog(sokrates); + + // assert + assertThat(catalog.getContractOffers()).isNotEmpty() + .hasSize(1) + .allSatisfy(co -> { + assertThat(co.getAsset().getId()).isEqualTo("test-asset"); + assertThat(co.getProvider().toString()).isEqualTo(sokrates.idsId()); + assertThat(co.getConsumer().toString()).isEqualTo(plato.idsId()); + }); + + } + + @Test + @DisplayName("Verify that Plato receives only the offers he is permitted to") + void requestCatalog_filteredByBpn_shouldReject() { + var onlyPlatoPolicy = businessPartnerNumberPolicy("ap", "BPN1", "BPN2", plato.getBpn()); + var onlyDiogenesPolicy = businessPartnerNumberPolicy("dp", "ARISTOTELES-BPN"); + var noConstraintPolicyId = "no-constraint"; + + sokrates.createPolicy(onlyPlatoPolicy); + sokrates.createPolicy(noConstraintPolicy(noConstraintPolicyId)); + + sokrates.createAsset("test-asset1", Map.of("canSee", "true")); + sokrates.createAsset("test-asset2", Map.of("canSee", "true")); + sokrates.createAsset("test-asset3", Map.of("canSee", "false")); + + sokrates.createContractDefinition("test-asset1", "def1", noConstraintPolicyId, noConstraintPolicyId, 60); + sokrates.createContractDefinition("test-asset2", "def2", onlyPlatoPolicy.getId(), noConstraintPolicyId, 60); + sokrates.createContractDefinition("test-asset3", "def3", onlyDiogenesPolicy.getId(), noConstraintPolicyId, 60); + + + // act + var catalog = plato.requestCatalog(sokrates); + assertThat(catalog.getContractOffers()).hasSize(2); + } + + @Test + @DisplayName("Multiple ContractDefinitions exist for one Asset") + void requestCatalog_multipleOffersForAsset() { + sokrates.createAsset("asset-1", Map.of("test-key", "test-val")); + sokrates.createPolicy(noConstraintPolicy("policy-1")); + sokrates.createPolicy(businessPartnerNumberPolicy("policy-2", plato.getBpn())); + + sokrates.createContractDefinition("asset-1", "def1", "policy-1", "policy-1", 60); + sokrates.createContractDefinition("asset-1", "def2", "policy-2", "policy-1", 60); + + var catalog = plato.requestCatalog(sokrates); + assertThat(catalog.getContractOffers()).hasSize(2) + .allSatisfy(cd -> assertThat(cd.getAsset().getId()).isEqualTo("asset-1")) + // .hasToString is advisable as it handles NPEs better: + .allSatisfy(cd -> assertThat(cd.getConsumer()).hasToString(plato.idsId())) + .allSatisfy(cd -> assertThat(cd.getProvider()).hasToString(sokrates.idsId())); + } + + @Test + @DisplayName("Catalog with 1000 offers") + void requestCatalog_of1000Assets_shouldContainAll() { + var policy = businessPartnerNumberPolicy("policy-1", plato.getBpn()); + sokrates.createPolicy(policy); + sokrates.createPolicy(noConstraintPolicy("noconstraint")); + + range(0, 1000) + .forEach(i -> { + var assetId = "asset-" + i; + sokrates.createAsset(assetId, Map.of()); + sokrates.createContractDefinition(assetId, "def-" + i, policy.getId(), "noconstraint", 60); + }); + + // request all at once + var o = plato.requestCatalog(sokrates, QuerySpecDto.Builder.newInstance().limit(1000).offset(0).build()).getContractOffers(); + assertThat(o).hasSize(1000); + + // request in chunks + var o2 = plato.requestCatalog(sokrates, QuerySpecDto.Builder.newInstance().limit(500).offset(0).build()).getContractOffers(); + var o3 = plato.requestCatalog(sokrates, QuerySpecDto.Builder.newInstance().limit(500).offset(500).build()).getContractOffers(); + assertThat(o2).doesNotContainAnyElementsOf(o3); + + } + + private PolicyDefinition noConstraintPolicy(String id) { + return PolicyDefinition.Builder.newInstance() + .id(id) + .policy(Policy.Builder.newInstance() + .permission(Permission.Builder.newInstance() + .action(Action.Builder.newInstance().type("USE").build()) + .build()) + .type(PolicyType.SET) + .build()) + .build(); + } +} + diff --git a/edc-tests/e2e-tests/src/test/java/org/eclipse/tractusx/edc/token/MockDapsService.java b/edc-tests/e2e-tests/src/test/java/org/eclipse/tractusx/edc/token/MockDapsService.java new file mode 100644 index 000000000..c833b5c8a --- /dev/null +++ b/edc-tests/e2e-tests/src/test/java/org/eclipse/tractusx/edc/token/MockDapsService.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * + * 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: + * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation + * + */ + +package org.eclipse.tractusx.edc.token; + +import org.eclipse.edc.spi.iam.ClaimToken; +import org.eclipse.edc.spi.iam.IdentityService; +import org.eclipse.edc.spi.iam.TokenParameters; +import org.eclipse.edc.spi.iam.TokenRepresentation; +import org.eclipse.edc.spi.result.Result; +import org.eclipse.edc.spi.types.TypeManager; + +import java.util.Map; + +import static java.lang.String.format; + +/** + * An {@link IdentityService} that will mimic the behaviour of DAPS by inserting the "referringConnector" claim into any token. + * Please only use in testing scenarios! + */ +public class MockDapsService implements IdentityService { + + private static final String BUSINESS_PARTNER_NUMBER_CLAIM = "BusinessPartnerNumber"; + private static final String REFERRING_CONNECTOR_CLAIM = "referringConnector"; + private final String businessPartnerNumber; + private TypeManager typeManager = new TypeManager(); + + public MockDapsService(String businessPartnerNumber) { + this.businessPartnerNumber = businessPartnerNumber; + } + + @Override + public Result obtainClientCredentials(TokenParameters parameters) { + var token = Map.of(BUSINESS_PARTNER_NUMBER_CLAIM, businessPartnerNumber); + + TokenRepresentation tokenRepresentation = TokenRepresentation.Builder.newInstance() + .token(typeManager.writeValueAsString(token)) + .build(); + return Result.success(tokenRepresentation); + } + + @Override + public Result verifyJwtToken(TokenRepresentation tokenRepresentation, String audience) { + + var token = typeManager.readValue(tokenRepresentation.getToken(), Map.class); + if (token.containsKey(BUSINESS_PARTNER_NUMBER_CLAIM)) { + return Result.success(ClaimToken.Builder.newInstance() + .claim(BUSINESS_PARTNER_NUMBER_CLAIM, token.get(BUSINESS_PARTNER_NUMBER_CLAIM)) + .claim(REFERRING_CONNECTOR_CLAIM, token.get(BUSINESS_PARTNER_NUMBER_CLAIM)).build()); + } + return Result.failure(format("Expected %s and %s claims, but token did not contain them", BUSINESS_PARTNER_NUMBER_CLAIM, REFERRING_CONNECTOR_CLAIM)); + } + +} diff --git a/edc-tests/runtime/README.md b/edc-tests/runtime/README.md new file mode 100644 index 000000000..703963687 --- /dev/null +++ b/edc-tests/runtime/README.md @@ -0,0 +1,3 @@ +# In-Memory Runtime for Testing Purposes + +This module provides a very small, purely in-mem runtime to execute tests against. Not intended for anything other than testing! \ No newline at end of file diff --git a/edc-tests/runtime/build.gradle.kts b/edc-tests/runtime/build.gradle.kts new file mode 100644 index 000000000..b18b123ef --- /dev/null +++ b/edc-tests/runtime/build.gradle.kts @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * + * 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: + * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation + * + */ + +plugins { + `java-library` + id("application") + id("com.github.johnrengelman.shadow") version "8.0.0" +} + + +dependencies { + + runtimeOnly(project(":edc-controlplane:edc-controlplane-base")){ + exclude("org.eclipse.edc", "oauth2-core") + exclude("org.eclipse.edc", "oauth2-daps") + exclude(module= "data-encryption") + exclude(module= "control-plane-adapter") + } +} + +application { + mainClass.set("org.eclipse.edc.boot.system.runtime.BaseRuntime") +} + +tasks.withType { + mergeServiceFiles() + archiveFileName.set("app.jar") +} diff --git a/settings.gradle.kts b/settings.gradle.kts index 3c465f3c5..35ea70b69 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -12,7 +12,9 @@ include(":edc-extensions:observability-api-customization") include(":edc-extensions:transferprocess-sftp-client") include(":edc-extensions:transferprocess-sftp-common") include(":edc-extensions:transferprocess-sftp-provisioner") -include(":edc-tests") +include(":edc-tests:e2e-tests") +include(":edc-tests:runtime") +include(":edc-tests:cucumber") // modules for controlplane artifacts include(":edc-controlplane") @@ -28,6 +30,9 @@ include(":edc-dataplane:edc-dataplane-azure-vault") include(":edc-dataplane:edc-dataplane-base") include(":edc-dataplane:edc-dataplane-hashicorp-vault") +// for testing +include(":launchers:simple") + // this is needed to have access to snapshot builds of plugins pluginManagement { repositories { @@ -62,6 +67,7 @@ dependencyResolutionManagement { library("spi-transfer", "org.eclipse.edc", "transfer-spi").versionRef("edc") library("spi-core", "org.eclipse.edc", "core-spi").versionRef("edc") library("spi-policy", "org.eclipse.edc", "policy-spi").versionRef("edc") + library("spi-contract", "org.eclipse.edc", "contract-spi").versionRef("edc") library("spi-policyengine", "org.eclipse.edc", "policy-engine-spi").versionRef("edc") library("spi-transaction-datasource", "org.eclipse.edc", "transaction-datasource-spi").versionRef("edc") library("spi-transactionspi", "org.eclipse.edc", "transaction-spi").versionRef("edc") @@ -72,13 +78,16 @@ dependencyResolutionManagement { library("util", "org.eclipse.edc", "util").versionRef("edc") library("boot", "org.eclipse.edc", "boot").versionRef("edc") library("config-filesystem", "org.eclipse.edc", "configuration-filesystem").versionRef("edc") + library("vault-filesystem", "org.eclipse.edc", "vault-filesystem").versionRef("edc") library("core-controlplane", "org.eclipse.edc", "control-plane-core").versionRef("edc") library("core-connector", "org.eclipse.edc", "connector-core").versionRef("edc") library("core-jetty", "org.eclipse.edc", "jetty-core").versionRef("edc") library("core-jersey", "org.eclipse.edc", "jersey-core").versionRef("edc") + library("core-api", "org.eclipse.edc", "api-core").versionRef("edc") library("junit", "org.eclipse.edc", "junit").versionRef("edc") library("api-management-config", "org.eclipse.edc", "management-api-configuration").versionRef("edc") library("api-management", "org.eclipse.edc", "management-api").versionRef("edc") + library("api-catalog", "org.eclipse.edc", "catalog-api").versionRef("edc") library("api-observability", "org.eclipse.edc", "api-observability").versionRef("edc") library("ext-http", "org.eclipse.edc", "http").versionRef("edc") library("spi-ids", "org.eclipse.edc", "ids-spi").versionRef("edc")