Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

chore: fix backend issues with policies and dsp endpoints/prepared v4.0.1 #388

Merged
merged 27 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
90fc8bf
chore: fixed dev chart configs policies
matbmoser Jul 19, 2024
b6da909
chore: fixed typo with certification registry
matbmoser Jul 19, 2024
dfba27a
chore: updated edc api version
matbmoser Jul 19, 2024
567df75
chore: extention of challanges
matbmoser Jul 22, 2024
6d0ff1a
chore: fixed link typo
matbmoser Jul 22, 2024
032c2e9
fix: fixed issue with verification charts configuration
Jul 22, 2024
97f39a4
fix: removed assetid from transfer, so no error is raising
Jul 22, 2024
43be37e
fix: solved problem related to edc 0.7.3
Jul 23, 2024
f318a68
feat: fixed chart frontend ingress
Jul 23, 2024
53411b9
chore: updated annotations from frontend!
Jul 23, 2024
754fcec
chore: updated annotations from frontend!
Jul 23, 2024
6a9917f
chore: updated secret paths for association int env vault
Jul 24, 2024
8ed8158
chore: added compatibility matrix and fixed typos
Jul 24, 2024
14fe185
chore: added compatibility matrix and fixed typos
Jul 24, 2024
e1c2170
chore: added compatibility matrix and fixed typos
Jul 24, 2024
60bbaa6
chore: prepared release v4.0.1
Jul 24, 2024
2ac60a1
chore: updated values-int
Jul 24, 2024
da7c19b
chore: updated values-int
Jul 24, 2024
b13c627
chore: updated values-int
Jul 24, 2024
fdb99fd
chore: updated interoperability guide
Jul 24, 2024
7012a6e
feat: updated dash license to latest version
Jul 24, 2024
0853e76
fix: fixed typos in yaml files
Jul 24, 2024
9a6637a
feat: updated helm docs
Jul 24, 2024
485db41
chore(dpp-verification): updated image paths and removed typos
Jul 24, 2024
407f07d
feat(dpp-verification): updated verification images
Jul 24, 2024
8b5d05e
feat: prepared release user changelog
Jul 24, 2024
a0a8c20
chore: updated verification version to v2.1
Jul 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions charts/digital-product-pass/templates/configmap-backend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -157,23 +157,23 @@ data:
strictMode: {{ .Values.backend.passport.policyCheck.strictMode }}
policies: {{- toYaml .Values.backend.passport.policyCheck.policies | nindent 10 }}
# -- digital product pass verification add-on configuration
verification:
enabled: {{ .Values.backend.verification.enabled }}
autoVerify: {{ .Values.backend.verification.autoVerify }}
wallet:
url: {{ .Values.backend.verification.wallet.url }}
endpoints:
health: {{ .Values.backend.verification.wallet.endpoints.health }}
verify: {{ .Values.backend.verification.wallet.endpoints.verify }}
certifiedDataCredential:
## -- These keys are used in order to find if a subModel contains a verifiable credential, defined in the verification documentation
semanticIdKeys:
- key: "Entity"
value: "https://www.w3.org/ns/credentials/v2"
- key: "DataElement"
value: "urn:samm:io.catenax.dpp_verification.cdc:1.0.0#CertifiedDataCredential"
- key: "Operation"
value: "https://w3c.github.io/vc-jws-2020/contexts/v1/"
verification:
enabled: {{ .Values.backend.verification.enabled }}
autoVerify: {{ .Values.backend.verification.autoVerify }}
wallet:
url: {{ .Values.backend.verification.wallet.url }}
endpoints:
health: {{ .Values.backend.verification.wallet.endpoints.health }}
verify: {{ .Values.backend.verification.wallet.endpoints.verify }}
certifiedDataCredential:
## -- These keys are used in order to find if a subModel contains a verifiable credential, defined in the verification documentation
semanticIdKeys:
- key: "Entity"
value: "https://www.w3.org/ns/credentials/v2"
- key: "DataElement"
value: "urn:samm:io.catenax.dpp_verification.cdc:1.0.0#CertifiedDataCredential"
- key: "Operation"
value: "https://w3c.github.io/vc-jws-2020/contexts/v1/"
# -- configuration of the spring boot server
server:
# -- configuration of backend errors
Expand Down
9 changes: 3 additions & 6 deletions charts/digital-product-pass/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ backend:
hostname: ""
apis:
readiness: "/api/check/readiness"
management: "/management/v2"
management: "/management/v3"
catalog: "/catalog/request"
negotiation: "/contractnegotiations"
transfer: "/transferprocesses"
Expand Down Expand Up @@ -206,15 +206,12 @@ backend:
# -- list of allowed policies that can be selected from the edc catalog in negotiations
policies:
- permission:
- action: "USE"
- action: "odrl:use"
logicalConstraint: "odrl:and"
constraints:
- leftOperand: "cx-policy:Membership"
operator: "odrl:eq"
rightOperand: "active"
- leftOperand: "cx-policy:FrameworkAgreement"
operator: "odrl:eq"
rightOperand: "CircularEconomy:1.0"
- leftOperand: "cx-policy:UsagePurpose"
operator: "odrl:eq"
rightOperand: "cx.circular.dpp:1"
Expand Down Expand Up @@ -246,7 +243,7 @@ backend:
# -- list of allowed policies that can be selected from the edc catalog in negotiations
policies:
- permission:
- action: "USE"
- action: "odrl:use"
logicalConstraint: "odrl:and"
constraints:
- leftOperand: "cx-policy:Membership"
Expand Down
2 changes: 1 addition & 1 deletion dpp-backend/digitalproductpass/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
</parent>
<groupId>org.eclipse.tractusx</groupId>
<artifactId>digitalproductpass</artifactId>
<version>4.0.0</version>
<version>4.0.1</version>
<packaging>jar</packaging>
<name>Catena-X Digital Product Passport Core + Verification Add-on</name>
<description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public Response getDigitalTwin(@RequestBody Object body, @PathVariable String pr
}

try {
connectorAddress = CatenaXUtil.buildEndpoint(connectorAddress);
connectorAddress = CatenaXUtil.buildDspEndpoint(connectorAddress);
} catch (Exception e) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@
public class TransferRequest extends DidDocument {

/** ATTRIBUTES **/
@JsonProperty("assetId")
String assetId;
@JsonProperty("counterPartyAddress")
String counterPartyAddress;
@JsonProperty("contractId")
Expand All @@ -66,9 +64,8 @@ public class TransferRequest extends DidDocument {
public TransferRequest() {
}

public TransferRequest(String id, String type, String assetId, String counterPartyAddress, String contractId, DataDestination dataDestination, Boolean managedResources, String protocol, String transferType, List<CallbackAddress> callbackAddresses) {
public TransferRequest(String id, String type, String counterPartyAddress, String contractId, DataDestination dataDestination, Boolean managedResources, String protocol, String transferType, List<CallbackAddress> callbackAddresses) {
super(id, type);
this.assetId = assetId;
this.counterPartyAddress = counterPartyAddress;
this.contractId = contractId;
this.dataDestination = dataDestination;
Expand All @@ -78,8 +75,7 @@ public TransferRequest(String id, String type, String assetId, String counterPar
this.callbackAddresses = callbackAddresses;
}

public TransferRequest(String assetId, String counterPartyAddress, String contractId, DataDestination dataDestination, Boolean managedResources, String protocol, String transferType, List<CallbackAddress> callbackAddresses) {
this.assetId = assetId;
public TransferRequest(String counterPartyAddress, String contractId, DataDestination dataDestination, Boolean managedResources, String protocol, String transferType, List<CallbackAddress> callbackAddresses) {
this.counterPartyAddress = counterPartyAddress;
this.contractId = contractId;
this.dataDestination = dataDestination;
Expand All @@ -89,9 +85,8 @@ public TransferRequest(String assetId, String counterPartyAddress, String contra
this.callbackAddresses = callbackAddresses;
}

public TransferRequest(String id, String type, JsonNode context, String assetId, String counterPartyAddress, String contractId, DataDestination dataDestination, Boolean managedResources, String protocol, String transferType, List<CallbackAddress> callbackAddresses) {
public TransferRequest(String id, String type, JsonNode context, String counterPartyAddress, String contractId, DataDestination dataDestination, Boolean managedResources, String protocol, String transferType, List<CallbackAddress> callbackAddresses) {
super(id, type, context);
this.assetId = assetId;
this.counterPartyAddress = counterPartyAddress;
this.contractId = contractId;
this.dataDestination = dataDestination;
Expand All @@ -101,9 +96,8 @@ public TransferRequest(String id, String type, JsonNode context, String assetId,
this.callbackAddresses = callbackAddresses;
}

public TransferRequest(String type, String assetId, String counterPartyAddress, String contractId, DataDestination dataDestination, Boolean managedResources, String protocol, String transferType, List<CallbackAddress> callbackAddresses) {
public TransferRequest(String type, String counterPartyAddress, String contractId, DataDestination dataDestination, Boolean managedResources, String protocol, String transferType, List<CallbackAddress> callbackAddresses) {
super(type);
this.assetId = assetId;
this.counterPartyAddress = counterPartyAddress;
this.contractId = contractId;
this.dataDestination = dataDestination;
Expand All @@ -113,9 +107,8 @@ public TransferRequest(String type, String assetId, String counterPartyAddress,
this.callbackAddresses = callbackAddresses;
}

public TransferRequest(JsonNode context, String assetId, String counterPartyAddress, String contractId, DataDestination dataDestination, Boolean managedResources, String protocol, String transferType, List<CallbackAddress> callbackAddresses) {
public TransferRequest(JsonNode context, String counterPartyAddress, String contractId, DataDestination dataDestination, Boolean managedResources, String protocol, String transferType, List<CallbackAddress> callbackAddresses) {
super(context);
this.assetId = assetId;
this.counterPartyAddress = counterPartyAddress;
this.contractId = contractId;
this.dataDestination = dataDestination;
Expand All @@ -125,9 +118,8 @@ public TransferRequest(JsonNode context, String assetId, String counterPartyAddr
this.callbackAddresses = callbackAddresses;
}

public TransferRequest(JsonNode context, String type, String assetId, String counterPartyAddress, String contractId, DataDestination dataDestination, Boolean managedResources, String protocol, String transferType, List<CallbackAddress> callbackAddresses) {
public TransferRequest(JsonNode context, String type, String counterPartyAddress, String contractId, DataDestination dataDestination, Boolean managedResources, String protocol, String transferType, List<CallbackAddress> callbackAddresses) {
super(context, type);
this.assetId = assetId;
this.counterPartyAddress = counterPartyAddress;
this.contractId = contractId;
this.dataDestination = dataDestination;
Expand All @@ -139,12 +131,6 @@ public TransferRequest(JsonNode context, String type, String assetId, String cou


/** GETTERS AND SETTERS **/
public String getAssetId() {
return assetId;
}
public void setAssetId(String assetId) {
this.assetId = assetId;
}
public String getCounterPartyAddress() {
return counterPartyAddress;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,18 +196,47 @@ public static String buildManagementEndpoint(Environment env, String path) {
throw new UtilException(CatenaXUtil.class, e, "[ERROR] Invalid edc endpoint or management endpoint");
}
}
/**
* Builds a dsp endpoint, adding the /api/v1/dsp endpoint.
* <p>
* @param endpoint
* the {@code String} partial endpoint.
*
* @return the built {@code String} endpoint by cleaning the given endpoint and adding the EDC data endpoint and BPN number (if applied).
*
* @throws UtilException
* if the given endpoint is an invalid one.
*/
public static String buildDspEndpoint(String endpoint) {
try {
if (CatenaXUtil.containsEdcEndpoint(endpoint)) {
return endpoint;
}
String cleanUrl = HttpUtil.cleanUrlWithPath(endpoint);
// Remove the trailing slash
if (endpoint.endsWith("/")) {
cleanUrl = endpoint.substring(0, endpoint.length() - 1);
}
//Contact the dsp endpoint
return cleanUrl + edcDataEndpoint;
} catch (Exception e) {
throw new UtilException(CatenaXUtil.class, e, "[ERROR] Invalid url [" + endpoint + "] given!");
}

}

/**
* @deprecated Use {@code CatenaXUtil.buildEndpointSafe()} instead. This method provided the old logic of parsing dsp endpoints with BPNs
* Builds the full Endpoint for a given partial endpoint.
* <p>
* @param endpoint
* the {@code String} partial endpoint.
*
* @return the built {@code String} endpoint by cleaning the given endpoint and adding the EDC data endpoint and BPN number (if applied).
*
* @throws UtilException
* if the given endpoint is an invalid one.
*/
@Deprecated
public static String buildEndpoint(String endpoint) {
try {
if (CatenaXUtil.containsEdcEndpoint(endpoint)) {
Expand Down
16 changes: 16 additions & 0 deletions dpp-backend/digitalproductpass/src/main/java/utils/HttpUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,22 @@ public static String cleanUrl(String strUrl) throws MalformedURLException{
String authority = url.getAuthority();
return String.format("%s://%s", protocol, authority);
}
/**
* Parses the given {@code String} URL into a String format with protocol and authority information with path
* <p>
* @param strUrl
* the {@code String} URL.
*
* @return a {@code String} object with format result.
*
*/
public static String cleanUrlWithPath(String strUrl) throws MalformedURLException{
URL url = new URL(strUrl);
String protocol = url.getProtocol();
String authority = url.getAuthority();
String path = url.getPath();
return String.format("%s://%s%s", protocol, authority, path);
}


/**************************************************
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,6 @@ void saveTransferRequestAndTransfer() {
String connectorId = UUID.randomUUID().toString();
transferRequest.setProtocol("HTTP");
transferRequest.setContractId(contractId);
transferRequest.setAssetId(assetId);
transferRequest.setCounterPartyAddress("connectorAddress");

String transferId = UUID.randomUUID().toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,6 @@ void initiateTransferAndSeeTransfer() {
List<CallbackAddress> callbackAddresses = List.of(CallbackAddress.builder().transactional(false).uri("http://test.endpoint/4546").events(List.of("transfer.process")).build());
TransferRequest transferRequest = new TransferRequest(
jsonUtil.toJsonNode(Map.of("odrl", "http://www.w3.org/ns/odrl/2/")),
dataSet.getAssetId(),
status.getEndpoint(),
negotiation.getContractAgreementId(),
null,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/*********************************************************************************
*
* Tractus-X - Digital Product Pass Application
*
* Copyright (c) 2022, 2024 BMW AG
* Copyright (c) 2022, 2024 Henkel AG & Co. KGaA
* Copyright (c) 2023, 2024 CGI Deutschland B.V. & Co. KG
* Copyright (c) 2023, 2024 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 govern in permissions and limitations
* under the License.
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

package utils;

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;

class CatenaXUtilTest {

Check notice

Code scanning / CodeQL

Unused classes and interfaces Note test

Unused class: CatenaXUtilTest is not referenced within this codebase. If not used as an external API it should be removed.
String edcUrlWithoutDsp = "https://edc-url.com/";
String edcUrlWithoutDspBar = "https://edc-url.com";
String edcUrlWithPathWithoutDsp = "https://edc-url.com/provider/";
String edcUrlWithPathWithoutDspBar = "https://edc-url.com/provider";
String edcUrlWithDsp = "https://edc-url.com"+CatenaXUtil.edcDataEndpoint;
String edcUrlWithPathDsp = "https://edc-url.com/provider"+CatenaXUtil.edcDataEndpoint;
String edcUrlWithBpnDsp = "https://edc-url.com/BPNL000000000000"+CatenaXUtil.edcDataEndpoint;
String edcUrlWithBpnWithoutDsp = "https://edc-url.com/BPNL000000000000";
String edcUrlWithPort = "https://edc-url.com:8888/BPNL000000000000";
String edcUrlWithBpnWithoutDspMorePath = "https://edc-url.com/BPNL000000000000/this/is/more/path";
@Test
void buildEdcUrlWithoutDsp() {
String output = CatenaXUtil.buildDspEndpoint(edcUrlWithoutDsp);
LogUtil.printTest("[CatenaXUtil.buildEdcUrlWithoutDsp] Input: ["+edcUrlWithoutDsp+"] Output: ["+output+"]");
assertEquals(edcUrlWithDsp, output);
}
@Test
void buildEdcUrlWithoutDspBar() {
String output = CatenaXUtil.buildDspEndpoint(edcUrlWithoutDspBar);
LogUtil.printTest("[CatenaXUtil.buildEdcUrlWithoutDspBar] Input: ["+edcUrlWithoutDspBar+"] Output: ["+output+"]");
assertEquals(edcUrlWithDsp, output);
}
@Test
void buildEdcUrlWithPathWithoutDsp() {
String output = CatenaXUtil.buildDspEndpoint(edcUrlWithPathWithoutDsp);
LogUtil.printTest("[CatenaXUtil.buildEdcUrlWithPathWithoutDsp] Input: ["+edcUrlWithPathWithoutDsp+"] Output: ["+output+"]");
assertEquals(edcUrlWithPathDsp, output);
}

@Test
void buildEdcUrlWithPathWithoutDspBar() {
String output = CatenaXUtil.buildDspEndpoint(edcUrlWithPathWithoutDspBar);
LogUtil.printTest("[CatenaXUtil.buildEdcUrlWithPathWithoutDspBar] Input: ["+edcUrlWithPathWithoutDspBar+"] Output: ["+output+"]");
assertEquals(edcUrlWithPathDsp, output);
}
@Test
void buildEdcUrlWithBpnDsp() {
String output = CatenaXUtil.buildDspEndpoint(edcUrlWithBpnDsp);
LogUtil.printTest("[CatenaXUtil.buildEdcUrlWithBpnDsp] Input: ["+edcUrlWithBpnDsp+"] Output: ["+output+"]");
assertEquals(edcUrlWithBpnDsp, output);
}

@Test
void buildEdcUrlWithBpnWithoutDsp() {
String output = CatenaXUtil.buildDspEndpoint(edcUrlWithBpnWithoutDsp);
LogUtil.printTest("[CatenaXUtil.buildEdcUrlWithBpnWithoutDsp] Input: ["+edcUrlWithBpnWithoutDsp+"] Output: ["+output+"]");
assertEquals(edcUrlWithBpnDsp, output);
}

@Test
void buildEdcUrlWithBpnWithoutDspMorePath() {
String output = CatenaXUtil.buildDspEndpoint(edcUrlWithBpnWithoutDspMorePath);
LogUtil.printTest("[CatenaXUtil.edcUrlWithBpnWithoutDspMorePath] Input: ["+edcUrlWithBpnWithoutDspMorePath+"] Output: ["+output+"]");
assertEquals(edcUrlWithBpnWithoutDspMorePath+CatenaXUtil.edcDataEndpoint,output);
}
@Test
void buildEdcWithPort() {
String output = CatenaXUtil.buildDspEndpoint(edcUrlWithPort);
LogUtil.printTest("[CatenaXUtil.buildEdcWithPort] Input: ["+edcUrlWithPort+"] Output: ["+output+"]");
assertEquals(edcUrlWithPort+CatenaXUtil.edcDataEndpoint, output);
}


}
Loading
Loading