diff --git a/DEPENDENCIES b/DEPENDENCIES index 7fc8b6d47..c2ca208c7 100644 --- a/DEPENDENCIES +++ b/DEPENDENCIES @@ -6,7 +6,7 @@ maven/mavencentral/com.apicatalog/iron-verifiable-credentials/0.14.0, Apache-2.0 maven/mavencentral/com.apicatalog/titanium-json-ld/1.0.0, Apache-2.0, approved, clearlydefined maven/mavencentral/com.apicatalog/titanium-json-ld/1.4.0, Apache-2.0, approved, #15200 maven/mavencentral/com.apicatalog/titanium-json-ld/1.4.1, Apache-2.0, approved, #15200 -maven/mavencentral/com.apicatalog/titanium-json-ld/1.5.0, , restricted, clearlydefined +maven/mavencentral/com.apicatalog/titanium-json-ld/1.5.0, Apache-2.0, approved, #19372 maven/mavencentral/com.azure/azure-core-http-netty/1.15.6, MIT AND Apache-2.0, approved, #16697 maven/mavencentral/com.azure/azure-core-http-netty/1.15.7, MIT AND Apache-2.0, approved, #16697 maven/mavencentral/com.azure/azure-core/1.54.0, MIT, approved, clearlydefined @@ -135,34 +135,41 @@ maven/mavencentral/io.micrometer/micrometer-core/1.14.2, Apache-2.0 AND (Apache- maven/mavencentral/io.micrometer/micrometer-observation/1.14.2, Apache-2.0, approved, #17270 maven/mavencentral/io.netty/netty-buffer/4.1.112.Final, Apache-2.0, approved, CQ21842 maven/mavencentral/io.netty/netty-buffer/4.1.115.Final, Apache-2.0, approved, CQ21842 +maven/mavencentral/io.netty/netty-buffer/4.1.118.Final, Apache-2.0, approved, CQ21842 maven/mavencentral/io.netty/netty-buffer/4.1.86.Final, Apache-2.0, approved, CQ21842 maven/mavencentral/io.netty/netty-codec-dns/4.1.112.Final, Apache-2.0 AND BSD-3-Clause AND MIT, approved, CQ20926 maven/mavencentral/io.netty/netty-codec-http/4.1.112.Final, Apache-2.0 AND BSD-3-Clause AND MIT, approved, CQ20926 maven/mavencentral/io.netty/netty-codec-http/4.1.115.Final, Apache-2.0 AND BSD-3-Clause AND MIT, approved, CQ20926 +maven/mavencentral/io.netty/netty-codec-http/4.1.118.Final, Apache-2.0 AND BSD-3-Clause AND MIT, approved, CQ20926 maven/mavencentral/io.netty/netty-codec-http/4.1.86.Final, Apache-2.0 AND BSD-3-Clause AND MIT, approved, CQ20926 maven/mavencentral/io.netty/netty-codec-http2/4.1.112.Final, Apache-2.0 AND BSD-3-Clause AND MIT, approved, CQ20926 maven/mavencentral/io.netty/netty-codec-http2/4.1.115.Final, Apache-2.0 AND BSD-3-Clause AND MIT, approved, CQ20926 +maven/mavencentral/io.netty/netty-codec-http2/4.1.118.Final, Apache-2.0 AND BSD-3-Clause AND MIT, approved, CQ20926 maven/mavencentral/io.netty/netty-codec-http2/4.1.86.Final, Apache-2.0 AND BSD-3-Clause AND MIT, approved, CQ20926 maven/mavencentral/io.netty/netty-codec-socks/4.1.112.Final, Apache-2.0 AND BSD-3-Clause AND MIT, approved, CQ20926 maven/mavencentral/io.netty/netty-codec-socks/4.1.115.Final, Apache-2.0 AND BSD-3-Clause AND MIT, approved, CQ20926 maven/mavencentral/io.netty/netty-codec-socks/4.1.86.Final, Apache-2.0 AND BSD-3-Clause AND MIT, approved, CQ20926 maven/mavencentral/io.netty/netty-codec/4.1.112.Final, Apache-2.0 AND BSD-3-Clause AND MIT, approved, CQ20926 maven/mavencentral/io.netty/netty-codec/4.1.115.Final, Apache-2.0 AND BSD-3-Clause AND MIT, approved, CQ20926 +maven/mavencentral/io.netty/netty-codec/4.1.118.Final, Apache-2.0 AND BSD-3-Clause AND MIT, approved, CQ20926 maven/mavencentral/io.netty/netty-codec/4.1.86.Final, Apache-2.0 AND BSD-3-Clause AND MIT, approved, CQ20926 maven/mavencentral/io.netty/netty-common/4.1.112.Final, Apache-2.0 AND MIT AND CC0-1.0, approved, CQ21843 maven/mavencentral/io.netty/netty-common/4.1.115.Final, Apache-2.0 AND MIT AND CC0-1.0, approved, CQ21843 +maven/mavencentral/io.netty/netty-common/4.1.118.Final, Apache-2.0 AND MIT AND CC0-1.0, approved, CQ21843 maven/mavencentral/io.netty/netty-common/4.1.86.Final, Apache-2.0 AND MIT AND CC0-1.0, approved, CQ21843 maven/mavencentral/io.netty/netty-handler-proxy/4.1.112.Final, Apache-2.0 AND BSD-3-Clause AND MIT, approved, CQ20926 maven/mavencentral/io.netty/netty-handler-proxy/4.1.115.Final, Apache-2.0 AND BSD-3-Clause AND MIT, approved, CQ20926 maven/mavencentral/io.netty/netty-handler-proxy/4.1.86.Final, Apache-2.0 AND BSD-3-Clause AND MIT, approved, CQ20926 maven/mavencentral/io.netty/netty-handler/4.1.112.Final, Apache-2.0 AND BSD-3-Clause AND MIT, approved, CQ20926 maven/mavencentral/io.netty/netty-handler/4.1.115.Final, Apache-2.0 AND BSD-3-Clause AND MIT, approved, CQ20926 +maven/mavencentral/io.netty/netty-handler/4.1.118.Final, Apache-2.0 AND BSD-3-Clause AND MIT, approved, CQ20926 maven/mavencentral/io.netty/netty-handler/4.1.86.Final, Apache-2.0 AND BSD-3-Clause AND MIT, approved, CQ20926 maven/mavencentral/io.netty/netty-resolver-dns-classes-macos/4.1.112.Final, Apache-2.0, approved, #6367 maven/mavencentral/io.netty/netty-resolver-dns-native-macos/4.1.112.Final, Apache-2.0, approved, #7004 maven/mavencentral/io.netty/netty-resolver-dns/4.1.112.Final, Apache-2.0 AND BSD-3-Clause AND MIT, approved, CQ20926 maven/mavencentral/io.netty/netty-resolver/4.1.112.Final, Apache-2.0 AND BSD-3-Clause AND MIT, approved, CQ20926 maven/mavencentral/io.netty/netty-resolver/4.1.115.Final, Apache-2.0 AND BSD-3-Clause AND MIT, approved, CQ20926 +maven/mavencentral/io.netty/netty-resolver/4.1.118.Final, Apache-2.0 AND BSD-3-Clause AND MIT, approved, CQ20926 maven/mavencentral/io.netty/netty-resolver/4.1.86.Final, Apache-2.0 AND BSD-3-Clause AND MIT, approved, CQ20926 maven/mavencentral/io.netty/netty-tcnative-boringssl-static/2.0.56.Final, Apache-2.0 OR LicenseRef-Public-Domain OR BSD-2-Clause OR MIT, approved, CQ15280 maven/mavencentral/io.netty/netty-tcnative-boringssl-static/2.0.65.Final, Apache-2.0 OR LicenseRef-Public-Domain OR BSD-2-Clause OR MIT, approved, CQ15280 @@ -172,6 +179,7 @@ maven/mavencentral/io.netty/netty-tcnative-classes/2.0.65.Final, Apache-2.0, app maven/mavencentral/io.netty/netty-tcnative-classes/2.0.69.Final, Apache-2.0, approved, clearlydefined maven/mavencentral/io.netty/netty-transport-classes-epoll/4.1.112.Final, Apache-2.0, approved, #6366 maven/mavencentral/io.netty/netty-transport-classes-epoll/4.1.115.Final, Apache-2.0, approved, #6366 +maven/mavencentral/io.netty/netty-transport-classes-epoll/4.1.118.Final, Apache-2.0, approved, #6366 maven/mavencentral/io.netty/netty-transport-classes-kqueue/4.1.112.Final, Apache-2.0, approved, #4107 maven/mavencentral/io.netty/netty-transport-classes-kqueue/4.1.115.Final, Apache-2.0, approved, #4107 maven/mavencentral/io.netty/netty-transport-native-epoll/4.1.112.Final, Apache-2.0 AND BSD-3-Clause AND MIT, approved, CQ20926 @@ -180,9 +188,11 @@ maven/mavencentral/io.netty/netty-transport-native-kqueue/4.1.112.Final, Apache- maven/mavencentral/io.netty/netty-transport-native-kqueue/4.1.115.Final, Apache-2.0 AND BSD-3-Clause AND MIT, approved, CQ20926 maven/mavencentral/io.netty/netty-transport-native-unix-common/4.1.112.Final, Apache-2.0 AND BSD-3-Clause AND MIT, approved, CQ20926 maven/mavencentral/io.netty/netty-transport-native-unix-common/4.1.115.Final, Apache-2.0 AND BSD-3-Clause AND MIT, approved, CQ20926 +maven/mavencentral/io.netty/netty-transport-native-unix-common/4.1.118.Final, Apache-2.0 AND BSD-3-Clause AND MIT, approved, CQ20926 maven/mavencentral/io.netty/netty-transport-native-unix-common/4.1.86.Final, Apache-2.0 AND BSD-3-Clause AND MIT, approved, CQ20926 maven/mavencentral/io.netty/netty-transport/4.1.112.Final, Apache-2.0 AND BSD-3-Clause AND MIT, approved, CQ20926 maven/mavencentral/io.netty/netty-transport/4.1.115.Final, Apache-2.0 AND BSD-3-Clause AND MIT, approved, CQ20926 +maven/mavencentral/io.netty/netty-transport/4.1.118.Final, Apache-2.0 AND BSD-3-Clause AND MIT, approved, CQ20926 maven/mavencentral/io.netty/netty-transport/4.1.86.Final, Apache-2.0 AND BSD-3-Clause AND MIT, approved, CQ20926 maven/mavencentral/io.opentelemetry.instrumentation/opentelemetry-instrumentation-annotations/1.32.0, Apache-2.0, approved, #11684 maven/mavencentral/io.opentelemetry.javaagent/opentelemetry-javaagent/2.12.0, Apache-2.0, restricted, clearlydefined @@ -261,10 +271,10 @@ maven/mavencentral/net.java.dev.jna/jna-platform/5.13.0, Apache-2.0 OR LGPL-2.1- maven/mavencentral/net.java.dev.jna/jna/5.13.0, Apache-2.0 AND LGPL-2.1-or-later, approved, #15196 maven/mavencentral/net.javacrumbs.json-unit/json-unit-core/2.36.0, Apache-2.0, approved, clearlydefined maven/mavencentral/net.minidev/accessors-smart/2.4.7, Apache-2.0, approved, #7515 -maven/mavencentral/net.minidev/accessors-smart/2.5.1, Apache-2.0, approved, clearlydefined +maven/mavencentral/net.minidev/accessors-smart/2.5.1, Apache-2.0, approved, #19432 maven/mavencentral/net.minidev/json-smart/2.4.7, Apache-2.0, approved, #3288 -maven/mavencentral/net.minidev/json-smart/2.5.0, Apache-2.0, approved, clearlydefined -maven/mavencentral/net.minidev/json-smart/2.5.1, Apache-2.0, approved, clearlydefined +maven/mavencentral/net.minidev/json-smart/2.5.0, Apache-2.0, approved, #19431 +maven/mavencentral/net.minidev/json-smart/2.5.1, Apache-2.0, approved, #19431 maven/mavencentral/net.sf.jopt-simple/jopt-simple/5.0.4, MIT, approved, CQ13174 maven/mavencentral/net.sf.saxon/Saxon-HE/12.5, W3C-19980720 AND MPL-2.0 AND MPL-1.0, approved, #16061 maven/mavencentral/org.antlr/antlr4-runtime/4.13.2, BSD-3-Clause, approved, #10767 @@ -645,64 +655,64 @@ maven/mavencentral/org.yaml/snakeyaml/1.33, Apache-2.0, approved, clearlydefined maven/mavencentral/org.yaml/snakeyaml/2.2, Apache-2.0 AND (Apache-2.0 OR BSD-3-Clause OR EPL-1.0 OR GPL-2.0-or-later OR LGPL-2.1-or-later), approved, #10232 maven/mavencentral/org.yaml/snakeyaml/2.3, Apache-2.0 AND (Apache-2.0 OR BSD-3-Clause OR EPL-1.0 OR GPL-2.0-or-later OR LGPL-2.1-or-later), approved, #16046 maven/mavencentral/software.amazon.awssdk/annotations/2.29.50, Apache-2.0, approved, #17015 -maven/mavencentral/software.amazon.awssdk/annotations/2.30.16, Apache-2.0, approved, #19166 +maven/mavencentral/software.amazon.awssdk/annotations/2.30.17, Apache-2.0, approved, #19166 maven/mavencentral/software.amazon.awssdk/apache-client/2.29.50, Apache-2.0, approved, #17627 -maven/mavencentral/software.amazon.awssdk/apache-client/2.30.16, , restricted, clearlydefined +maven/mavencentral/software.amazon.awssdk/apache-client/2.30.17, , restricted, clearlydefined maven/mavencentral/software.amazon.awssdk/arns/2.29.50, Apache-2.0, approved, #16994 -maven/mavencentral/software.amazon.awssdk/arns/2.30.16, , restricted, clearlydefined +maven/mavencentral/software.amazon.awssdk/arns/2.30.17, , restricted, clearlydefined maven/mavencentral/software.amazon.awssdk/auth/2.29.50, Apache-2.0, approved, #17626 -maven/mavencentral/software.amazon.awssdk/auth/2.30.16, , restricted, clearlydefined +maven/mavencentral/software.amazon.awssdk/auth/2.30.17, , restricted, clearlydefined maven/mavencentral/software.amazon.awssdk/aws-core/2.29.50, Apache-2.0, approved, #17095 -maven/mavencentral/software.amazon.awssdk/aws-core/2.30.16, , restricted, clearlydefined +maven/mavencentral/software.amazon.awssdk/aws-core/2.30.17, , restricted, clearlydefined maven/mavencentral/software.amazon.awssdk/aws-query-protocol/2.29.50, Apache-2.0, approved, #16999 -maven/mavencentral/software.amazon.awssdk/aws-query-protocol/2.30.16, Apache-2.0, approved, #19170 +maven/mavencentral/software.amazon.awssdk/aws-query-protocol/2.30.17, Apache-2.0, approved, #19170 maven/mavencentral/software.amazon.awssdk/aws-xml-protocol/2.29.50, Apache-2.0, approved, #17004 -maven/mavencentral/software.amazon.awssdk/aws-xml-protocol/2.30.16, , restricted, clearlydefined +maven/mavencentral/software.amazon.awssdk/aws-xml-protocol/2.30.17, , restricted, clearlydefined maven/mavencentral/software.amazon.awssdk/checksums-spi/2.29.50, Apache-2.0, approved, #17010 -maven/mavencentral/software.amazon.awssdk/checksums-spi/2.30.16, , restricted, clearlydefined +maven/mavencentral/software.amazon.awssdk/checksums-spi/2.30.17, , restricted, clearlydefined maven/mavencentral/software.amazon.awssdk/checksums/2.29.50, Apache-2.0, approved, #17003 -maven/mavencentral/software.amazon.awssdk/checksums/2.30.16, , restricted, clearlydefined +maven/mavencentral/software.amazon.awssdk/checksums/2.30.17, , restricted, clearlydefined maven/mavencentral/software.amazon.awssdk/crt-core/2.29.50, Apache-2.0, approved, #17002 -maven/mavencentral/software.amazon.awssdk/crt-core/2.30.16, Apache-2.0, approved, clearlydefined +maven/mavencentral/software.amazon.awssdk/crt-core/2.30.17, , restricted, clearlydefined maven/mavencentral/software.amazon.awssdk/endpoints-spi/2.29.50, Apache-2.0, approved, #16996 -maven/mavencentral/software.amazon.awssdk/endpoints-spi/2.30.16, , restricted, clearlydefined +maven/mavencentral/software.amazon.awssdk/endpoints-spi/2.30.17, , restricted, clearlydefined maven/mavencentral/software.amazon.awssdk/http-auth-aws-eventstream/2.29.50, Apache-2.0, approved, #16995 -maven/mavencentral/software.amazon.awssdk/http-auth-aws-eventstream/2.30.16, , restricted, clearlydefined +maven/mavencentral/software.amazon.awssdk/http-auth-aws-eventstream/2.30.17, , restricted, clearlydefined maven/mavencentral/software.amazon.awssdk/http-auth-aws/2.29.50, Apache-2.0, approved, #17001 -maven/mavencentral/software.amazon.awssdk/http-auth-aws/2.30.16, , restricted, clearlydefined +maven/mavencentral/software.amazon.awssdk/http-auth-aws/2.30.17, , restricted, clearlydefined maven/mavencentral/software.amazon.awssdk/http-auth-spi/2.29.50, Apache-2.0, approved, #17005 -maven/mavencentral/software.amazon.awssdk/http-auth-spi/2.30.16, , restricted, clearlydefined +maven/mavencentral/software.amazon.awssdk/http-auth-spi/2.30.17, , restricted, clearlydefined maven/mavencentral/software.amazon.awssdk/http-auth/2.29.50, Apache-2.0, approved, #16998 -maven/mavencentral/software.amazon.awssdk/http-auth/2.30.16, , restricted, clearlydefined +maven/mavencentral/software.amazon.awssdk/http-auth/2.30.17, , restricted, clearlydefined maven/mavencentral/software.amazon.awssdk/http-client-spi/2.29.50, Apache-2.0, approved, #17014 -maven/mavencentral/software.amazon.awssdk/http-client-spi/2.30.16, Apache-2.0, approved, #19169 +maven/mavencentral/software.amazon.awssdk/http-client-spi/2.30.17, Apache-2.0, approved, #19169 maven/mavencentral/software.amazon.awssdk/iam/2.29.50, Apache-2.0, approved, #16993 maven/mavencentral/software.amazon.awssdk/identity-spi/2.29.50, Apache-2.0, approved, #17007 -maven/mavencentral/software.amazon.awssdk/identity-spi/2.30.16, , restricted, clearlydefined +maven/mavencentral/software.amazon.awssdk/identity-spi/2.30.17, , restricted, clearlydefined maven/mavencentral/software.amazon.awssdk/json-utils/2.29.50, Apache-2.0, approved, #17013 -maven/mavencentral/software.amazon.awssdk/json-utils/2.30.16, , restricted, clearlydefined +maven/mavencentral/software.amazon.awssdk/json-utils/2.30.17, , restricted, clearlydefined maven/mavencentral/software.amazon.awssdk/metrics-spi/2.29.50, Apache-2.0, approved, #17006 -maven/mavencentral/software.amazon.awssdk/metrics-spi/2.30.16, , restricted, clearlydefined +maven/mavencentral/software.amazon.awssdk/metrics-spi/2.30.17, , restricted, clearlydefined maven/mavencentral/software.amazon.awssdk/netty-nio-client/2.29.50, Apache-2.0, approved, #17094 -maven/mavencentral/software.amazon.awssdk/netty-nio-client/2.30.16, Apache-2.0, approved, #19163 +maven/mavencentral/software.amazon.awssdk/netty-nio-client/2.30.17, Apache-2.0, approved, #19163 maven/mavencentral/software.amazon.awssdk/profiles/2.29.50, Apache-2.0, approved, #17012 -maven/mavencentral/software.amazon.awssdk/profiles/2.30.16, Apache-2.0, approved, #19171 +maven/mavencentral/software.amazon.awssdk/profiles/2.30.17, Apache-2.0, approved, #19171 maven/mavencentral/software.amazon.awssdk/protocol-core/2.29.50, Apache-2.0, approved, #17000 -maven/mavencentral/software.amazon.awssdk/protocol-core/2.30.16, Apache-2.0, approved, #19168 +maven/mavencentral/software.amazon.awssdk/protocol-core/2.30.17, Apache-2.0, approved, #19168 maven/mavencentral/software.amazon.awssdk/regions/2.29.50, Apache-2.0, approved, #17631 -maven/mavencentral/software.amazon.awssdk/regions/2.30.16, Apache-2.0, approved, #19164 +maven/mavencentral/software.amazon.awssdk/regions/2.30.17, Apache-2.0, approved, #19164 maven/mavencentral/software.amazon.awssdk/retries-spi/2.29.50, Apache-2.0, approved, #16997 -maven/mavencentral/software.amazon.awssdk/retries-spi/2.30.16, , restricted, clearlydefined +maven/mavencentral/software.amazon.awssdk/retries-spi/2.30.17, , restricted, clearlydefined maven/mavencentral/software.amazon.awssdk/retries/2.29.50, Apache-2.0, approved, #17009 -maven/mavencentral/software.amazon.awssdk/retries/2.30.16, , restricted, clearlydefined -maven/mavencentral/software.amazon.awssdk/s3-transfer-manager/2.30.16, , restricted, clearlydefined +maven/mavencentral/software.amazon.awssdk/retries/2.30.17, , restricted, clearlydefined +maven/mavencentral/software.amazon.awssdk/s3-transfer-manager/2.30.17, , restricted, clearlydefined maven/mavencentral/software.amazon.awssdk/s3/2.29.50, Apache-2.0, approved, #17629 -maven/mavencentral/software.amazon.awssdk/s3/2.30.16, , restricted, clearlydefined +maven/mavencentral/software.amazon.awssdk/s3/2.30.17, , restricted, clearlydefined maven/mavencentral/software.amazon.awssdk/sdk-core/2.29.50, Apache-2.0, approved, #17016 -maven/mavencentral/software.amazon.awssdk/sdk-core/2.30.16, Apache-2.0, approved, #19167 +maven/mavencentral/software.amazon.awssdk/sdk-core/2.30.17, Apache-2.0, approved, #19167 maven/mavencentral/software.amazon.awssdk/sts/2.29.50, Apache-2.0, approved, #17630 maven/mavencentral/software.amazon.awssdk/third-party-jackson-core/2.29.50, Apache-2.0, approved, #17008 -maven/mavencentral/software.amazon.awssdk/third-party-jackson-core/2.30.16, , restricted, clearlydefined +maven/mavencentral/software.amazon.awssdk/third-party-jackson-core/2.30.17, , restricted, clearlydefined maven/mavencentral/software.amazon.awssdk/utils/2.29.50, Apache-2.0, approved, #17625 -maven/mavencentral/software.amazon.awssdk/utils/2.30.16, , restricted, clearlydefined +maven/mavencentral/software.amazon.awssdk/utils/2.30.17, , restricted, clearlydefined maven/mavencentral/software.amazon.eventstream/eventstream/1.0.1, Apache-2.0, approved, clearlydefined diff --git a/edc-controlplane/edc-controlplane-base/build.gradle.kts b/edc-controlplane/edc-controlplane-base/build.gradle.kts index 6a8862c5d..da3ea6f8e 100644 --- a/edc-controlplane/edc-controlplane-base/build.gradle.kts +++ b/edc-controlplane/edc-controlplane-base/build.gradle.kts @@ -31,6 +31,7 @@ dependencies { runtimeOnly(project(":edc-extensions:edr:edr-callback")) runtimeOnly(project(":edc-extensions:tokenrefresh-handler")) runtimeOnly(project(":edc-extensions:agreements")) + runtimeOnly(project(":edc-extensions:validators:empty-asset-selector")) runtimeOnly(libs.edc.core.edrstore) runtimeOnly(libs.edc.edr.store.receiver) @@ -92,4 +93,5 @@ dependencies { runtimeOnly(libs.edc.fc.core) runtimeOnly(libs.edc.fc.api) + } diff --git a/edc-extensions/validators/empty-asset-selector/build.gradle.kts b/edc-extensions/validators/empty-asset-selector/build.gradle.kts new file mode 100644 index 000000000..ffb2c5327 --- /dev/null +++ b/edc-extensions/validators/empty-asset-selector/build.gradle.kts @@ -0,0 +1,30 @@ +/******************************************************************************** + * Copyright (c) 2025 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * + * 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 + ********************************************************************************/ + +plugins { + `maven-publish` + `java-library` +} + +dependencies { + api(libs.edc.spi.controlplane) + implementation(libs.edc.lib.validator) + + testImplementation(libs.edc.junit) +} \ No newline at end of file diff --git a/edc-extensions/validators/empty-asset-selector/src/main/java/org/eclipse/tractusx/edc/validators/emptyassetselector/EmptyAssetSelectorBlockerExtension.java b/edc-extensions/validators/empty-asset-selector/src/main/java/org/eclipse/tractusx/edc/validators/emptyassetselector/EmptyAssetSelectorBlockerExtension.java new file mode 100644 index 000000000..2034a4df5 --- /dev/null +++ b/edc-extensions/validators/empty-asset-selector/src/main/java/org/eclipse/tractusx/edc/validators/emptyassetselector/EmptyAssetSelectorBlockerExtension.java @@ -0,0 +1,64 @@ +/******************************************************************************** + * Copyright (c) 2025 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * + * 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 + ********************************************************************************/ + +package org.eclipse.tractusx.edc.validators.emptyassetselector; + +import org.eclipse.edc.runtime.metamodel.annotation.Extension; +import org.eclipse.edc.runtime.metamodel.annotation.Inject; +import org.eclipse.edc.runtime.metamodel.annotation.Setting; +import org.eclipse.edc.spi.monitor.Monitor; +import org.eclipse.edc.spi.query.CriterionOperatorRegistry; +import org.eclipse.edc.spi.system.ServiceExtension; +import org.eclipse.edc.validator.spi.JsonObjectValidatorRegistry; + +import static org.eclipse.edc.connector.controlplane.contract.spi.types.offer.ContractDefinition.CONTRACT_DEFINITION_TYPE; + +@Extension(value = EmptyAssetSelectorBlockerExtension.NAME) +public class EmptyAssetSelectorBlockerExtension implements ServiceExtension { + + public static final String NAME = "Empty Asset Selector Blocker extension"; + + private static final String BLOCKER_DISABLED = "false"; + + @Setting(description = "Block contract definitions from being created/updated with an empty asset selector.", defaultValue = BLOCKER_DISABLED, key = "tx.edc.validator.contractdefinitions.block-empty-asset-selector") + private boolean blockerEnabled; + + @Inject + JsonObjectValidatorRegistry validatorRegistry; + + @Inject + CriterionOperatorRegistry criterionOperatorRegistry; + + @Inject + Monitor monitor; + + @Override + public String name() { + return NAME; + } + + @Override + public void prepare() { + if (blockerEnabled) { + monitor.info("ContractDefinition validator that blocks empty assetsSelector has been enabled"); + validatorRegistry.register(CONTRACT_DEFINITION_TYPE, EmptyAssetSelectorValidator.instance(criterionOperatorRegistry)); + } + } + +} diff --git a/edc-extensions/validators/empty-asset-selector/src/main/java/org/eclipse/tractusx/edc/validators/emptyassetselector/EmptyAssetSelectorValidator.java b/edc-extensions/validators/empty-asset-selector/src/main/java/org/eclipse/tractusx/edc/validators/emptyassetselector/EmptyAssetSelectorValidator.java new file mode 100644 index 000000000..52889e68b --- /dev/null +++ b/edc-extensions/validators/empty-asset-selector/src/main/java/org/eclipse/tractusx/edc/validators/emptyassetselector/EmptyAssetSelectorValidator.java @@ -0,0 +1,44 @@ +/******************************************************************************** + * Copyright (c) 2025 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * + * 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 + ********************************************************************************/ + +package org.eclipse.tractusx.edc.validators.emptyassetselector; + +import org.eclipse.edc.spi.query.CriterionOperatorRegistry; +import org.eclipse.edc.validator.jsonobject.JsonObjectValidator; +import org.eclipse.edc.validator.jsonobject.validators.MandatoryArray; +import org.eclipse.edc.validator.jsonobject.validators.MandatoryValue; +import org.eclipse.edc.validator.jsonobject.validators.OptionalIdNotBlank; +import org.eclipse.edc.validator.jsonobject.validators.model.CriterionValidator; + +import static org.eclipse.edc.connector.controlplane.contract.spi.types.offer.ContractDefinition.CONTRACT_DEFINITION_ACCESSPOLICY_ID; +import static org.eclipse.edc.connector.controlplane.contract.spi.types.offer.ContractDefinition.CONTRACT_DEFINITION_ASSETS_SELECTOR; +import static org.eclipse.edc.connector.controlplane.contract.spi.types.offer.ContractDefinition.CONTRACT_DEFINITION_CONTRACTPOLICY_ID; + +public class EmptyAssetSelectorValidator { + + public static JsonObjectValidator instance(CriterionOperatorRegistry criterionOperatorRegistry) { + return JsonObjectValidator.newValidator() + .verifyId(OptionalIdNotBlank::new) + .verify(CONTRACT_DEFINITION_ACCESSPOLICY_ID, MandatoryValue::new) + .verify(CONTRACT_DEFINITION_CONTRACTPOLICY_ID, MandatoryValue::new) + .verify(CONTRACT_DEFINITION_ASSETS_SELECTOR, MandatoryArray.min(1)) + .verifyArrayItem(CONTRACT_DEFINITION_ASSETS_SELECTOR, path -> CriterionValidator.instance(path, criterionOperatorRegistry)) + .build(); + } +} diff --git a/edc-extensions/validators/empty-asset-selector/src/main/java/org/eclipse/tractusx/edc/validators/emptyassetselector/README.md b/edc-extensions/validators/empty-asset-selector/src/main/java/org/eclipse/tractusx/edc/validators/emptyassetselector/README.md new file mode 100644 index 000000000..2c0f09174 --- /dev/null +++ b/edc-extensions/validators/empty-asset-selector/src/main/java/org/eclipse/tractusx/edc/validators/emptyassetselector/README.md @@ -0,0 +1,46 @@ +# Contract Definitions Validator: Empty Asset Selector + +The goal of this extension is to provide a replacement validator for contract definition entities. +It is used to validate requests that create or update contract definitions via the data management API endpoint. +When enabled, it prevents contract definitions with no asset selector, or an empty one, from being created which +elsewise leads to all available assets being included in the Contract Definition. + +This extension is included with the standard tractusx-edc distribution, but is disabled by default. To enable it, +you can set `tx.edc.validator.contractdefinitions.block-empty-asset-selector`to `true` in your connector configuration. + +## Example + +When the validator extension is enabled, creating the following contract definition will lead to a 400 error. + +```json +{ + "@context": { + "@vocab": "https://w3id.org/edc/v0.0.1/ns/" + }, + "@type": "ContractDefinition", + "@id": "myContractDefinitionId", + "accessPolicyId": "myAccessPolicyId", + "contractPolicyId": "myContractPolicyId" +} +``` + +Above, the `assetSelector` property is missing from the request, so an empty one is added by default. +The validator will block this contract definition from being created. + +Similarly, this will also fail: + +```json +{ + "@context": { + "@vocab": "https://w3id.org/edc/v0.0.1/ns/" + }, + "@type": "ContractDefinition", + "@id": "myContractDefinitionId", + "accessPolicyId": "myAccessPolicyId", + "contractPolicyId": "myContractPolicyId", + "assetSelector": [] +} +``` + +The `assetSelector` property exists, but since it's an empty list the validator will also block this contract +definition from being created. A valid contract definition should have at least one criterion. diff --git a/edc-extensions/validators/empty-asset-selector/src/main/resources/META-INF/services/org.eclipse.edc.spi.system.ServiceExtension b/edc-extensions/validators/empty-asset-selector/src/main/resources/META-INF/services/org.eclipse.edc.spi.system.ServiceExtension new file mode 100644 index 000000000..182e977b4 --- /dev/null +++ b/edc-extensions/validators/empty-asset-selector/src/main/resources/META-INF/services/org.eclipse.edc.spi.system.ServiceExtension @@ -0,0 +1,20 @@ +################################################################################# +# Copyright (c) 2025 Bayerische Motoren Werke Aktiengesellschaft +# +# 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 +################################################################################# + +org.eclipse.tractusx.edc.validators.emptyassetselector.EmptyAssetSelectorBlockerExtension \ No newline at end of file diff --git a/edc-extensions/validators/empty-asset-selector/src/test/java/org/eclipse/tractusx/edc/validators/emptyassetselector/EmptyAssetSelectorValidatorTest.java b/edc-extensions/validators/empty-asset-selector/src/test/java/org/eclipse/tractusx/edc/validators/emptyassetselector/EmptyAssetSelectorValidatorTest.java new file mode 100644 index 000000000..899e626a0 --- /dev/null +++ b/edc-extensions/validators/empty-asset-selector/src/test/java/org/eclipse/tractusx/edc/validators/emptyassetselector/EmptyAssetSelectorValidatorTest.java @@ -0,0 +1,184 @@ +/******************************************************************************** + * Copyright (c) 2025 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * + * 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 + ********************************************************************************/ + +package org.eclipse.tractusx.edc.validators.emptyassetselector; + +import jakarta.json.Json; +import jakarta.json.JsonArrayBuilder; +import org.assertj.core.api.Assertions; +import org.eclipse.edc.spi.query.CriterionOperatorRegistry; +import org.eclipse.edc.validator.jsonobject.JsonObjectValidator; +import org.eclipse.edc.validator.spi.ValidationFailure; +import org.eclipse.edc.validator.spi.Violation; +import org.junit.jupiter.api.Test; + +import static jakarta.json.Json.createArrayBuilder; +import static jakarta.json.Json.createObjectBuilder; +import static org.assertj.core.api.InstanceOfAssertFactories.list; +import static org.eclipse.edc.connector.controlplane.contract.spi.types.offer.ContractDefinition.CONTRACT_DEFINITION_ACCESSPOLICY_ID; +import static org.eclipse.edc.connector.controlplane.contract.spi.types.offer.ContractDefinition.CONTRACT_DEFINITION_ASSETS_SELECTOR; +import static org.eclipse.edc.connector.controlplane.contract.spi.types.offer.ContractDefinition.CONTRACT_DEFINITION_CONTRACTPOLICY_ID; +import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.ID; +import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.VALUE; +import static org.eclipse.edc.junit.assertions.AbstractResultAssert.assertThat; +import static org.eclipse.edc.spi.query.Criterion.CRITERION_OPERAND_LEFT; +import static org.eclipse.edc.spi.query.Criterion.CRITERION_OPERAND_RIGHT; +import static org.eclipse.edc.spi.query.Criterion.CRITERION_OPERATOR; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +class EmptyAssetSelectorValidatorTest { + + CriterionOperatorRegistry criterionOperatorRegistry = mock(); + + private final JsonObjectValidator validator = EmptyAssetSelectorValidator.instance(criterionOperatorRegistry); + + @Test + void shouldPass_whenContractDefinitionIsCorrect() { + + var criterion = createObjectBuilder() + .add(CRITERION_OPERAND_LEFT, value("operandLeft")) + .add(CRITERION_OPERATOR, value("=")) + .add(CRITERION_OPERAND_RIGHT, value("operandRight")); + + var contractDefinition = createObjectBuilder() + .add(CONTRACT_DEFINITION_ACCESSPOLICY_ID, value("accessPolicyId")) + .add(CONTRACT_DEFINITION_CONTRACTPOLICY_ID, value("accessPolicyId")) + .add(CONTRACT_DEFINITION_ASSETS_SELECTOR, createArrayBuilder().add(criterion)) + .build(); + + when(criterionOperatorRegistry.isSupported("=")).thenReturn(true); + + var result = validator.validate(contractDefinition); + + assertThat(result).isSucceeded(); + } + + @Test + void shouldFail_whenContractDefinitionHasNoAssetSelector() { + var contractDefinition = createObjectBuilder() + .add(CONTRACT_DEFINITION_ACCESSPOLICY_ID, value("accessPolicyId")) + .add(CONTRACT_DEFINITION_CONTRACTPOLICY_ID, value("accessPolicyId")) + .build(); + + var result = validator.validate(contractDefinition); + + assertThat(result).isFailed().extracting(ValidationFailure::getViolations).asInstanceOf(list(Violation.class)) + .isNotEmpty() + .anySatisfy(violation -> Assertions.assertThat(violation.path()).isEqualTo(CONTRACT_DEFINITION_ASSETS_SELECTOR)) + .anySatisfy(violation -> Assertions.assertThat(violation.message()).contains("is missing")); + } + + @Test + void shouldFail_whenContractDefinitionHasEmptyAssetSelector() { + var contractDefinition = createObjectBuilder() + .add(CONTRACT_DEFINITION_ACCESSPOLICY_ID, value("accessPolicyId")) + .add(CONTRACT_DEFINITION_CONTRACTPOLICY_ID, value("accessPolicyId")) + .add(CONTRACT_DEFINITION_ASSETS_SELECTOR, Json.createArrayBuilder().build()) + .build(); + + var result = validator.validate(contractDefinition); + + assertThat(result).isFailed().extracting(ValidationFailure::getViolations).asInstanceOf(list(Violation.class)) + .isNotEmpty() + .anySatisfy(violation -> Assertions.assertThat(violation.path()).isEqualTo(CONTRACT_DEFINITION_ASSETS_SELECTOR)) + .anySatisfy(violation -> Assertions.assertThat(violation.message()).contains("should at least contains '1' elements")); + } + + /** + * Set of tests from upstream ContractDefinitionValidatorTest that still need to pass here. + **/ + + @Test + void shouldFail_whenMandatoryFieldsAreMissing() { + var contractDefinition = createObjectBuilder().build(); + + var result = validator.validate(contractDefinition); + + assertThat(result).isFailed().extracting(ValidationFailure::getViolations).asInstanceOf(list(Violation.class)) + .isNotEmpty() + .anySatisfy(violation -> Assertions.assertThat(violation.path()).isEqualTo(CONTRACT_DEFINITION_ACCESSPOLICY_ID)) + .anySatisfy(violation -> Assertions.assertThat(violation.path()).isEqualTo(CONTRACT_DEFINITION_CONTRACTPOLICY_ID)); + } + + @Test + void shouldFail_whenIdIsBlank() { + var contractDefinition = createObjectBuilder() + .add(ID, " ") + .build(); + + var result = validator.validate(contractDefinition); + + assertThat(result).isFailed().extracting(ValidationFailure::getViolations).asInstanceOf(list(Violation.class)) + .isNotEmpty() + .filteredOn(it -> ID.equals(it.path())) + .anySatisfy(violation -> Assertions.assertThat(violation.message()).contains("blank")); + } + + @Test + void shouldFail_whenAccessPolicyIdIsBlank() { + var contractDefinition = createObjectBuilder() + .add(CONTRACT_DEFINITION_ACCESSPOLICY_ID, value(" ")) + .build(); + + var result = validator.validate(contractDefinition); + + assertThat(result).isFailed().extracting(ValidationFailure::getViolations).asInstanceOf(list(Violation.class)) + .isNotEmpty() + .filteredOn(it -> CONTRACT_DEFINITION_ACCESSPOLICY_ID.equals(it.path())) + .anySatisfy(violation -> Assertions.assertThat(violation.message()).contains("blank")); + } + + @Test + void shouldFail_whenContractPolicyIdIsBlank() { + var contractDefinition = createObjectBuilder() + .add(CONTRACT_DEFINITION_CONTRACTPOLICY_ID, value(" ")) + .build(); + + var result = validator.validate(contractDefinition); + + assertThat(result).isFailed().extracting(ValidationFailure::getViolations).asInstanceOf(list(Violation.class)) + .isNotEmpty() + .filteredOn(it -> CONTRACT_DEFINITION_CONTRACTPOLICY_ID.equals(it.path())) + .anySatisfy(violation -> Assertions.assertThat(violation.message()).contains("blank")); + } + + @Test + void shouldFail_whenAssetSelectorCriterionIsNotValid() { + var contractDefinition = createObjectBuilder() + .add(CONTRACT_DEFINITION_ACCESSPOLICY_ID, value("id")) + .add(CONTRACT_DEFINITION_CONTRACTPOLICY_ID, value("id")) + .add(CONTRACT_DEFINITION_ASSETS_SELECTOR, createArrayBuilder().add(createObjectBuilder() + .add(CRITERION_OPERAND_LEFT, value(" ")) + .add(CRITERION_OPERATOR, value(" ")) + )) + .build(); + + var result = validator.validate(contractDefinition); + + assertThat(result).isFailed().extracting(ValidationFailure::getViolations).asInstanceOf(list(Violation.class)) + .isNotEmpty() + .anySatisfy(violation -> Assertions.assertThat(violation.path()).endsWith(CRITERION_OPERAND_LEFT)) + .anySatisfy(violation -> Assertions.assertThat(violation.path()).endsWith(CRITERION_OPERATOR)); + } + + private JsonArrayBuilder value(String value) { + return createArrayBuilder().add(createObjectBuilder().add(VALUE, value)); + } +} \ No newline at end of file diff --git a/edc-tests/edc-controlplane/validator-tests/build.gradle.kts b/edc-tests/edc-controlplane/validator-tests/build.gradle.kts new file mode 100644 index 000000000..ec4178300 --- /dev/null +++ b/edc-tests/edc-controlplane/validator-tests/build.gradle.kts @@ -0,0 +1,37 @@ +/******************************************************************************** + * Copyright (c) 2025 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * + * 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 + ********************************************************************************/ + +plugins { + `java-library` + `java-test-fixtures` +} + +dependencies { + testImplementation(testFixtures(project(":edc-tests:e2e-fixtures"))) + + testImplementation(libs.edc.junit) + testImplementation(libs.restAssured) + + testCompileOnly(project(":edc-tests:runtime:runtime-memory")) +} + +// do not publish +edcBuild { + publish.set(false) +} diff --git a/edc-tests/edc-controlplane/validator-tests/src/test/java/org/eclipse/tractusx/edc/tests/validators/EmptyAssetSelectorValidatorTest.java b/edc-tests/edc-controlplane/validator-tests/src/test/java/org/eclipse/tractusx/edc/tests/validators/EmptyAssetSelectorValidatorTest.java new file mode 100644 index 000000000..0e2c4e8f0 --- /dev/null +++ b/edc-tests/edc-controlplane/validator-tests/src/test/java/org/eclipse/tractusx/edc/tests/validators/EmptyAssetSelectorValidatorTest.java @@ -0,0 +1,141 @@ +/******************************************************************************** + * Copyright (c) 2025 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * + * 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 + ********************************************************************************/ + +package org.eclipse.tractusx.edc.tests.validators; + +import io.restassured.response.ValidatableResponse; +import jakarta.json.Json; +import jakarta.json.JsonArray; +import org.eclipse.edc.junit.annotations.EndToEndTest; +import org.eclipse.edc.junit.extensions.RuntimeExtension; +import org.eclipse.tractusx.edc.tests.participant.TransferParticipant; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; + +import java.util.Map; + +import static io.restassured.http.ContentType.JSON; +import static jakarta.json.Json.createArrayBuilder; +import static jakarta.json.Json.createObjectBuilder; +import static org.eclipse.edc.connector.controlplane.contract.spi.types.offer.ContractDefinition.CONTRACT_DEFINITION_ACCESSPOLICY_ID; +import static org.eclipse.edc.connector.controlplane.contract.spi.types.offer.ContractDefinition.CONTRACT_DEFINITION_ASSETS_SELECTOR; +import static org.eclipse.edc.connector.controlplane.contract.spi.types.offer.ContractDefinition.CONTRACT_DEFINITION_CONTRACTPOLICY_ID; +import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.CONTEXT; +import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.ID; +import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; +import static org.eclipse.edc.spi.constants.CoreConstants.EDC_NAMESPACE; +import static org.eclipse.edc.spi.constants.CoreConstants.EDC_PREFIX; +import static org.eclipse.tractusx.edc.tests.TestRuntimeConfiguration.PROVIDER_BPN; +import static org.eclipse.tractusx.edc.tests.TestRuntimeConfiguration.PROVIDER_NAME; +import static org.eclipse.tractusx.edc.tests.runtimes.Runtimes.memoryRuntime; +import static org.hamcrest.Matchers.contains; + +public class EmptyAssetSelectorValidatorTest { + + + protected static final TransferParticipant PROVIDER = TransferParticipant.Builder.newInstance() + .name(PROVIDER_NAME) + .id(PROVIDER_BPN) + .build(); + + + abstract static class Tests { + + @Test + @DisplayName("Provider gets 400 when no asset selector is used") + void shouldFail_whenContractDefinitionHasNoAssetSelector() { + + var requestResponse = createContractDefinitionRequest("definitionId", "accessPolicyId", "contractPolicy", null); + + requestResponse.statusCode(400) + .body("message", contains("mandatory array '%s' is missing".formatted(CONTRACT_DEFINITION_ASSETS_SELECTOR))); + + } + + @Test + @DisplayName("Provider gets 400 when empty asset selector is used") + void shouldFail_whenContractDefinitionHasEmptyAssetSelector() { + + var requestResponse = createContractDefinitionRequest("definitionId", "accessPolicyId", "contractPolicy", createArrayBuilder().build()); + + requestResponse.statusCode(400) + .body("message", contains("array '%s' should at least contains '1' elements".formatted(CONTRACT_DEFINITION_ASSETS_SELECTOR))); + + } + + @Test + @DisplayName("Provider gets 200 when asset selector has a valid criterion") + void shouldPass_whenContractDefinitionHasCorrectAssetSelector() { + + var assetSelector = Json.createArrayBuilder() + .add(createObjectBuilder() + .add(TYPE, "Criterion") + .add(EDC_NAMESPACE + "operandLeft", EDC_NAMESPACE + "id") + .add(EDC_NAMESPACE + "operator", "=") + .add(EDC_NAMESPACE + "operandRight", "assetId") + .build()) + .build(); + + var requestResponse = createContractDefinitionRequest("definitionId", "accessPolicyId", "contractPolicy", assetSelector); + + requestResponse.statusCode(200); + + } + + private ValidatableResponse createContractDefinitionRequest(String definitionId, String accessPolicyId, String contractPolicyId, JsonArray criterionArray) { + var requestBody = createObjectBuilder() + .add(CONTEXT, createObjectBuilder().add(EDC_PREFIX, EDC_NAMESPACE)) + .add(ID, definitionId) + .add(TYPE, EDC_NAMESPACE + "ContractDefinition") + .add(CONTRACT_DEFINITION_ACCESSPOLICY_ID, accessPolicyId) + .add(CONTRACT_DEFINITION_CONTRACTPOLICY_ID, contractPolicyId); + + if (criterionArray != null) { + requestBody.add(CONTRACT_DEFINITION_ASSETS_SELECTOR, criterionArray); + } + + return PROVIDER.getManagementEndpoint().baseRequest() + .contentType(JSON) + .body(requestBody.build()) + .when() + .post("/v3/contractdefinitions") + .then(); + } + + + } + + @Nested + @EndToEndTest + class InMemory extends Tests { + + @RegisterExtension + protected static final RuntimeExtension PROVIDER_RUNTIME = memoryRuntime(PROVIDER.getName(), PROVIDER.getBpn(), enrichConfiguration()); + + private static Map enrichConfiguration() { + var configuration = PROVIDER.getConfiguration(); + configuration.put("tx.edc.validator.contractdefinitions.block-empty-asset-selector", "true"); + return configuration; + } + + } + +} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 74c378d51..c8263b4e7 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -5,7 +5,7 @@ format.version = "1.1" edc = "0.11.1" assertj = "3.27.3" awaitility = "4.2.2" -aws = "2.30.16" +aws = "2.30.17" azure-storage-blob = "12.29.0" bouncyCastle-jdk18on = "1.80" flyway = "11.3.1" diff --git a/settings.gradle.kts b/settings.gradle.kts index 008bbefb3..b75fd5c1b 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -52,6 +52,7 @@ include(":edc-extensions:cx-policy") include(":edc-extensions:dcp:tx-dcp") include(":edc-extensions:dcp:tx-dcp-sts-dim") include(":edc-extensions:data-flow-properties-provider") +include(":edc-extensions:validators:empty-asset-selector") include(":edc-extensions:agreements") include(":edc-extensions:agreements:retirement-evaluation-core") @@ -73,6 +74,7 @@ include(":edc-tests:edc-controlplane:transfer-tests") include(":edc-tests:edc-controlplane:iatp-tests") include(":edc-tests:edc-controlplane:policy-tests") include(":edc-tests:edc-controlplane:agreement-retirement-tests") +include(":edc-tests:edc-controlplane:validator-tests") include(":edc-tests:runtime:extensions") include(":edc-tests:runtime:runtime-memory") include(":edc-tests:runtime:mock-connector")