From 540731cc40a902f37ac6990da0d02521c42a6179 Mon Sep 17 00:00:00 2001 From: Muhammad Saud Khan Date: Wed, 17 Jul 2024 15:36:14 +0200 Subject: [PATCH 1/7] fix(frontend): fix edc policy rendering in frontend policy dialog --- dpp-frontend/src/utils/edcUtil.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dpp-frontend/src/utils/edcUtil.js b/dpp-frontend/src/utils/edcUtil.js index 9f00f7488..e5c47132d 100644 --- a/dpp-frontend/src/utils/edcUtil.js +++ b/dpp-frontend/src/utils/edcUtil.js @@ -212,7 +212,9 @@ export default { } // Parse the left operand - let rawLeftOperand = jsonUtil.get("odrl:leftOperand", constraint, ".", null); + let rawLeftOperand = jsonUtil.get("odrl:leftOperand.@id", constraint, ".", null); + if (rawLeftOperand == null) + throw new Error("The left operand structure is not valid, because of missing id attribute"); leftOperand = rawLeftOperand; // If is not a string convert the object or array to string if (typeof rawLeftOperand !== "string") { From 5f6e0b3e5883fd65d929d144d2aebd12df741319 Mon Sep 17 00:00:00 2001 From: Mathias Brunkow Moser Date: Wed, 17 Jul 2024 16:53:45 +0200 Subject: [PATCH 2/7] fix(dpp-policy): fixed structure of policy definition with '@id' --- .../models/negotiation/policy/Constraint.java | 15 ++++++++------- .../negotiation/policy/LogicalConstraint.java | 2 +- .../src/test/java/utils/PolicyUtilTest.java | 11 ++++++----- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/dpp-backend/digitalproductpass/src/main/java/org/eclipse/tractusx/digitalproductpass/core/models/negotiation/policy/Constraint.java b/dpp-backend/digitalproductpass/src/main/java/org/eclipse/tractusx/digitalproductpass/core/models/negotiation/policy/Constraint.java index 9e016b973..c5e748f7a 100644 --- a/dpp-backend/digitalproductpass/src/main/java/org/eclipse/tractusx/digitalproductpass/core/models/negotiation/policy/Constraint.java +++ b/dpp-backend/digitalproductpass/src/main/java/org/eclipse/tractusx/digitalproductpass/core/models/negotiation/policy/Constraint.java @@ -47,7 +47,7 @@ public class Constraint { /** ATTRIBUTES **/ @JsonProperty("odrl:leftOperand") @JsonAlias({"leftOperand","odrl:leftOperand"}) - String leftOperand; + DidDocument leftOperand; @JsonProperty("odrl:operator") @JsonAlias({"operator","odrl:operator"}) DidDocument operator; @@ -56,7 +56,7 @@ public class Constraint { String rightOperand; /** CONSTRUCTOR(S) **/ - public Constraint(String leftOperand, DidDocument operator, String rightOperand) { + public Constraint(DidDocument leftOperand, DidDocument operator, String rightOperand) { this.leftOperand = leftOperand; this.operator = operator; this.rightOperand = rightOperand; @@ -64,7 +64,7 @@ public Constraint(String leftOperand, DidDocument operator, String rightOperand) public Constraint() { } - public Constraint(String leftOperand, String operator, String rightOperand){ + public Constraint(DidDocument leftOperand, String operator, String rightOperand){ this.leftOperand = leftOperand; this.operator = new DidDocument(); this.operator.setId(operator); @@ -75,18 +75,19 @@ public Constraint(PolicyCheckConfig.ConstraintConfig constraintConfig) { } public void buildConstraint(PolicyCheckConfig.ConstraintConfig constraintConfig){ - this.leftOperand = constraintConfig.getLeftOperand(); + this.leftOperand = new DidDocument(); + this.leftOperand.setId(constraintConfig.getLeftOperand()); this.operator = new DidDocument(); this.operator.setId(constraintConfig.getOperator()); this.rightOperand = constraintConfig.getRightOperand(); } /** GETTERS AND SETTERS **/ - public String getLeftOperand() { + public DidDocument getLeftOperand() { return leftOperand; } - public void setLeftOperand(String leftOperand) { + public void setLeftOperand(DidDocument leftOperand) { this.leftOperand = leftOperand; } @@ -122,7 +123,7 @@ public boolean equals(Object o) { */ public Boolean compareConstraint(Constraint constraint){ try{ - if(!this.leftOperand.equalsIgnoreCase(constraint.getLeftOperand())){return false;} //If left operand is not the same as the left operand + if(!this.leftOperand.getId().equalsIgnoreCase(constraint.getLeftOperand().getId())){return false;} //If left operand is not the same as the left operand if(!this.operator.getId().equalsIgnoreCase(constraint.getOperator().getId())){return false;}//If operator id is not the same as the operator id return this.rightOperand.equalsIgnoreCase(constraint.getRightOperand());//If right operand is not the same as the right operand }catch (Exception e){ diff --git a/dpp-backend/digitalproductpass/src/main/java/org/eclipse/tractusx/digitalproductpass/core/models/negotiation/policy/LogicalConstraint.java b/dpp-backend/digitalproductpass/src/main/java/org/eclipse/tractusx/digitalproductpass/core/models/negotiation/policy/LogicalConstraint.java index 085647bc7..30223784e 100644 --- a/dpp-backend/digitalproductpass/src/main/java/org/eclipse/tractusx/digitalproductpass/core/models/negotiation/policy/LogicalConstraint.java +++ b/dpp-backend/digitalproductpass/src/main/java/org/eclipse/tractusx/digitalproductpass/core/models/negotiation/policy/LogicalConstraint.java @@ -61,7 +61,7 @@ enum LogicType{ /** CONSTRUCTOR(S) **/ - public LogicalConstraint(String leftOperand, DidDocument operator, String rightOperand, List andOperator, List orOperator) { + public LogicalConstraint(DidDocument leftOperand, DidDocument operator, String rightOperand, List andOperator, List orOperator) { super(leftOperand, operator, rightOperand); this.andOperator = andOperator; this.orOperator = orOperator; diff --git a/dpp-backend/digitalproductpass/src/test/java/utils/PolicyUtilTest.java b/dpp-backend/digitalproductpass/src/test/java/utils/PolicyUtilTest.java index 9f526e82f..e2cd823c0 100644 --- a/dpp-backend/digitalproductpass/src/test/java/utils/PolicyUtilTest.java +++ b/dpp-backend/digitalproductpass/src/test/java/utils/PolicyUtilTest.java @@ -128,12 +128,13 @@ void setUp() { policiesDtr = new LinkedList<>(); multipleCredential = new LinkedHashMap<>(); multipleCredentialDtr = new LinkedHashMap<>(); + LinkedHashMap leftOperand = new LinkedHashMap<>(); operator.put("@id", "odrl:eq"); - constraint1.put("odrl:leftOperand", "cx-policy:Membership"); + constraint1.put("odrl:leftOperand", new LinkedHashMap<>(){{put("@id", "cx-policy:Membership");}}); constraint1.put("odrl:operator", operator); constraint1.put("odrl:rightOperand", "active"); - constraint2.put("odrl:leftOperand", "cx-policy:FrameworkAgreement"); + constraint2.put("odrl:leftOperand",new LinkedHashMap<>(){{put("@id", "cx-policy:FrameworkAgreement");}}); constraint2.put("odrl:operator", operator); constraint2.put("odrl:rightOperand", "circulareconomy:1.0"); @@ -141,7 +142,7 @@ void setUp() { LinkedList> correctContraints = new LinkedList<>(); LinkedHashMap correctAction = new LinkedHashMap<>(); LinkedHashMap correctLogicalConstraint = new LinkedHashMap<>(); - constraint5.put("odrl:leftOperand", "cx-policy:UsagePurpose"); + constraint5.put("odrl:leftOperand",new LinkedHashMap<>(){{put("@id", "cx-policy:UsagePurpose");}}); constraint5.put("odrl:operator", operator); constraint5.put("odrl:rightOperand", "cx.circular.dpp:1"); constraints.add(constraint1); @@ -150,11 +151,11 @@ void setUp() { correctContraints.add(constraint2); correctContraints.add(constraint5); operator.put("@id", "odrl:eq"); - constraint3.put("odrl:leftOperand", "cx-policy:Membership"); + constraint3.put("odrl:leftOperand", new LinkedHashMap<>(){{put("@id", "cx-policy:Membership");}}); constraint3.put("odrl:operator", operator); constraint3.put("odrl:rightOperand", "active"); - constraint4.put("odrl:leftOperand", "cx-policy:UsagePurpose"); + constraint4.put("odrl:leftOperand", new LinkedHashMap<>(){{put("@id", "cx-policy:UsagePurpose");}}); constraint4.put("odrl:operator", operator); constraint4.put("odrl:rightOperand", "cx.core.digitalTwinRegistry:1"); configuredConstraints.add(constraint3); From df27c744caa8c35a903265e36006d233b8478a8d Mon Sep 17 00:00:00 2001 From: Mathias Brunkow Moser Date: Wed, 17 Jul 2024 16:59:42 +0200 Subject: [PATCH 3/7] chore: updated documentation about policies --- docs/data-sovereignty/PolicyConfigGuide.md | 63 ++++++++++++---------- 1 file changed, 36 insertions(+), 27 deletions(-) diff --git a/docs/data-sovereignty/PolicyConfigGuide.md b/docs/data-sovereignty/PolicyConfigGuide.md index af8ec29ae..0c17b6ebe 100644 --- a/docs/data-sovereignty/PolicyConfigGuide.md +++ b/docs/data-sovereignty/PolicyConfigGuide.md @@ -45,29 +45,30 @@ When auto-negotiation is enabled for the assets or done for the digital twin reg ## Table of contents -* [Policy Configuration Guide](#policy-configuration-guide) - * [Introduction](#introduction) - * [Table of contents](#table-of-contents) -* [DPP Backend Configuration](#dpp-backend-configuration) - * [Helm Chart Details](#helm-chart-details) - * [Parameters](#parameters) - * [Main Parameters](#main-parameters) - * [Policy Set Configuration](#policy-set-configuration) - * [Action Configuration](#action-configuration) - * [Logical Constraint Configuration](#logical-constraint-configuration) - * [Constraint Configuration](#constraint-configuration) - * [Comparison Modes](#comparison-modes) -* [DPP Frontend Configuration](#dpp-frontend-configuration) - * [Policy Selection Options](#policy-selection-options) - * [Auto-Negotiation](#auto-negotiation) - * [Manual Negotiation](#manual-negotiation) - * [Agree Contract](#agree-contract) - * [Policy Interpretation](#policy-interpretation) - * [Decline Contract](#decline-contract) -* [Examples](#examples) - * [Logical Constraints](#logical-constraints) - * [Multiple Policies](#multiple-policies) - * [Single Constraint](#single-constraint) +- [Policy Configuration Guide](#policy-configuration-guide) + - [Introduction](#introduction) + - [Table of contents](#table-of-contents) +- [DPP Backend Configuration](#dpp-backend-configuration) + - [Helm Chart Details](#helm-chart-details) + - [Parameters](#parameters) + - [Main Parameters](#main-parameters) + - [Policy Set Configuration](#policy-set-configuration) + - [Action Configuration](#action-configuration) + - [Logical Constraint Configuration](#logical-constraint-configuration) + - [Constraint Configuration](#constraint-configuration) + - [Comparison Modes](#comparison-modes) +- [DPP Frontend Configuration](#dpp-frontend-configuration) + - [Policy Selection Options](#policy-selection-options) + - [Auto-Negotiation](#auto-negotiation) + - [Manual Negotiation](#manual-negotiation) + - [Agree Contract](#agree-contract) + - [Policy Interpretation](#policy-interpretation) + - [Decline Contract](#decline-contract) +- [Examples](#examples) + - [Logical Constraints](#logical-constraints) + - [Multiple Policies](#multiple-policies) + - [Single Constraint](#single-constraint) + - [NOTICE](#notice) # DPP Backend Configuration @@ -227,7 +228,9 @@ In case the and operator is used here is the way how it would be configured. For "odrl:and": [ { "@type": "Constraint", - "odrl:leftOperand": "cx-policy:Membership", + "odrl:leftOperand": { + "@id": "cx-policy:Membership" + }, "odrl:operator": { "@id": "odrl:eq" }, @@ -235,7 +238,9 @@ In case the and operator is used here is the way how it would be configured. For }, { "@type": "Constraint", - "odrl:leftOperand": "cx-policy:FrameworkAgreement", + "odrl:leftOperand": { + "@id": "cx-policy:FrameworkAgreement" + }, "odrl:operator": { "@id": "odrl:eq" }, @@ -243,7 +248,9 @@ In case the and operator is used here is the way how it would be configured. For }, { "@type": "Constraint", - "odrl:leftOperand": "cx-policy:UsagePurpose", + "odrl:leftOperand": { + "@id": "cx-policy:UsagePurpose" + }, "odrl:operator": { "@id": "odrl:eq" }, @@ -396,7 +403,9 @@ The reason behind this is that the policies without logical constraints look lik { "odrl:action": "USE", "odrl:constraint": { - "odrl:leftOperand": "cx-poliy:Membership", + "odrl:leftOperand": { + "@id": "cx-poliy:Membership" + }, "odrl:operator": { "@id": "odrl:eq" }, From 64c8730d635e17b042ae07cb5335b7f570cc15da Mon Sep 17 00:00:00 2001 From: Mathias Brunkow Moser Date: Wed, 17 Jul 2024 17:59:48 +0200 Subject: [PATCH 4/7] feat: added bugfix with the action --- .../models/negotiation/policy/Action.java | 36 +++++-------------- 1 file changed, 8 insertions(+), 28 deletions(-) diff --git a/dpp-backend/digitalproductpass/src/main/java/org/eclipse/tractusx/digitalproductpass/core/models/negotiation/policy/Action.java b/dpp-backend/digitalproductpass/src/main/java/org/eclipse/tractusx/digitalproductpass/core/models/negotiation/policy/Action.java index 6f4b91a10..4b3935c91 100644 --- a/dpp-backend/digitalproductpass/src/main/java/org/eclipse/tractusx/digitalproductpass/core/models/negotiation/policy/Action.java +++ b/dpp-backend/digitalproductpass/src/main/java/org/eclipse/tractusx/digitalproductpass/core/models/negotiation/policy/Action.java @@ -36,6 +36,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import org.eclipse.tractusx.digitalproductpass.core.config.PolicyCheckConfig; import org.eclipse.tractusx.digitalproductpass.core.exceptions.ModelException; +import org.eclipse.tractusx.digitalproductpass.core.models.negotiation.DidDocument; import java.util.ArrayList; import java.util.List; @@ -52,7 +53,7 @@ public class Action { **/ @JsonProperty("odrl:action") @JsonAlias({"action", "odrl:action"}) - ActionType action; + DidDocument action; @JsonProperty("odrl:constraint") @JsonAlias({"constraint", "odrl:constraint"}) LogicalConstraint constraint; @@ -65,7 +66,7 @@ public class Action { public Action() { } - public Action(ActionType action, LogicalConstraint constraint) { + public Action(DidDocument action, LogicalConstraint constraint) { this.action = action; this.constraint = constraint; } @@ -92,18 +93,18 @@ public String retrieveAction() { if(this.action == null){ return null; } - return this.action.getType(); + return this.action.getId(); } public void addAction(String action) { - this.action = new ActionType(); - this.action.setType(action); + this.action = new DidDocument(); + this.action.setId(action); } - public ActionType getAction() { + public DidDocument getAction() { return action; } - public void setAction(ActionType action) { + public void setAction(DidDocument action) { this.action = action; } @@ -148,25 +149,4 @@ static public List build(JsonNode node){ // If node is array parse the action node as a list return mapper.convertValue(node, new TypeReference<>(){}); } - - static class ActionType{ - @JsonProperty("odrl:type") - @JsonAlias({"type", "odrl:type", "@type"}) - String type; - - public ActionType(String type) { - this.type = type; - } - - public ActionType() { - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - } } From 6188a4baba85bd4cf1604062ef9a1af035822c03 Mon Sep 17 00:00:00 2001 From: Mathias Brunkow Moser Date: Wed, 17 Jul 2024 18:40:37 +0200 Subject: [PATCH 5/7] feat: added context for negotiation --- .../digitalproductpass/core/services/DataTransferService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dpp-backend/digitalproductpass/src/main/java/org/eclipse/tractusx/digitalproductpass/core/services/DataTransferService.java b/dpp-backend/digitalproductpass/src/main/java/org/eclipse/tractusx/digitalproductpass/core/services/DataTransferService.java index 2fe5e81df..6f10ed6fa 100644 --- a/dpp-backend/digitalproductpass/src/main/java/org/eclipse/tractusx/digitalproductpass/core/services/DataTransferService.java +++ b/dpp-backend/digitalproductpass/src/main/java/org/eclipse/tractusx/digitalproductpass/core/services/DataTransferService.java @@ -351,7 +351,7 @@ public Dataset getContractOfferByAssetId(String assetId, String counterPartyAddr */ public NegotiationRequest buildRequestFirstPolicy(Dataset dataset, String endpoint, String providerBpn) { return new NegotiationRequest( - jsonUtil.toJsonNode(Map.of("odrl", "http://www.w3.org/ns/odrl/2/")), + jsonUtil.toJsonNode(Map.of("odrl", "http://www.w3.org/ns/odrl/2/", "@vocab", "https://w3id.org/edc/v0.0.1/ns/", "cx-policy", "https://w3id.org/catenax/policy/")), endpoint, "dataspace-protocol-http", this.buildOffer(dataset, 0, providerBpn) @@ -391,7 +391,7 @@ public NegotiationRequest buildRequestById(Dataset dataset, String endpoint, Str */ public NegotiationRequest buildRequest(String endpoint, Policy policyOffer) { return new NegotiationRequest( - jsonUtil.toJsonNode(Map.of("odrl", "http://www.w3.org/ns/odrl/2/")), + jsonUtil.toJsonNode(Map.of("odrl", "http://www.w3.org/ns/odrl/2/", "@vocab", "https://w3id.org/edc/v0.0.1/ns/", "cx-policy", "https://w3id.org/catenax/policy/")), "odrl:ContractRequest", endpoint, "dataspace-protocol-http", From 4edcac3c71cd95c9473a5401f34278d715c271e7 Mon Sep 17 00:00:00 2001 From: Mathias Brunkow Moser Date: Wed, 17 Jul 2024 18:53:34 +0200 Subject: [PATCH 6/7] fix: added counterparty address in the transfer --- .../negotiation/request/TransferRequest.java | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/dpp-backend/digitalproductpass/src/main/java/org/eclipse/tractusx/digitalproductpass/core/models/negotiation/request/TransferRequest.java b/dpp-backend/digitalproductpass/src/main/java/org/eclipse/tractusx/digitalproductpass/core/models/negotiation/request/TransferRequest.java index 76efc3f80..c851d52a5 100644 --- a/dpp-backend/digitalproductpass/src/main/java/org/eclipse/tractusx/digitalproductpass/core/models/negotiation/request/TransferRequest.java +++ b/dpp-backend/digitalproductpass/src/main/java/org/eclipse/tractusx/digitalproductpass/core/models/negotiation/request/TransferRequest.java @@ -46,8 +46,8 @@ public class TransferRequest extends DidDocument { /** ATTRIBUTES **/ @JsonProperty("assetId") String assetId; - @JsonProperty("connectorAddress") - String connectorAddress; + @JsonProperty("counterPartyAddress") + String counterPartyAddress; @JsonProperty("contractId") String contractId; @JsonProperty("dataDestination") @@ -66,10 +66,10 @@ public class TransferRequest extends DidDocument { public TransferRequest() { } - public TransferRequest(String id, String type, String assetId, String connectorAddress, String contractId, DataDestination dataDestination, Boolean managedResources, String protocol, String transferType, List callbackAddresses) { + public TransferRequest(String id, String type, String assetId, String counterPartyAddress, String contractId, DataDestination dataDestination, Boolean managedResources, String protocol, String transferType, List callbackAddresses) { super(id, type); this.assetId = assetId; - this.connectorAddress = connectorAddress; + this.counterPartyAddress = counterPartyAddress; this.contractId = contractId; this.dataDestination = dataDestination; this.managedResources = managedResources; @@ -78,9 +78,9 @@ public TransferRequest(String id, String type, String assetId, String connectorA this.callbackAddresses = callbackAddresses; } - public TransferRequest(String assetId, String connectorAddress, String contractId, DataDestination dataDestination, Boolean managedResources, String protocol, String transferType, List callbackAddresses) { + public TransferRequest(String assetId, String counterPartyAddress, String contractId, DataDestination dataDestination, Boolean managedResources, String protocol, String transferType, List callbackAddresses) { this.assetId = assetId; - this.connectorAddress = connectorAddress; + this.counterPartyAddress = counterPartyAddress; this.contractId = contractId; this.dataDestination = dataDestination; this.managedResources = managedResources; @@ -89,10 +89,10 @@ public TransferRequest(String assetId, String connectorAddress, String contractI this.callbackAddresses = callbackAddresses; } - public TransferRequest(String id, String type, JsonNode context, String assetId, String connectorAddress, String contractId, DataDestination dataDestination, Boolean managedResources, String protocol, String transferType, List callbackAddresses) { + public TransferRequest(String id, String type, JsonNode context, String assetId, String counterPartyAddress, String contractId, DataDestination dataDestination, Boolean managedResources, String protocol, String transferType, List callbackAddresses) { super(id, type, context); this.assetId = assetId; - this.connectorAddress = connectorAddress; + this.counterPartyAddress = counterPartyAddress; this.contractId = contractId; this.dataDestination = dataDestination; this.managedResources = managedResources; @@ -101,10 +101,10 @@ public TransferRequest(String id, String type, JsonNode context, String assetId, this.callbackAddresses = callbackAddresses; } - public TransferRequest(String type, String assetId, String connectorAddress, String contractId, DataDestination dataDestination, Boolean managedResources, String protocol, String transferType, List callbackAddresses) { + public TransferRequest(String type, String assetId, String counterPartyAddress, String contractId, DataDestination dataDestination, Boolean managedResources, String protocol, String transferType, List callbackAddresses) { super(type); this.assetId = assetId; - this.connectorAddress = connectorAddress; + this.counterPartyAddress = counterPartyAddress; this.contractId = contractId; this.dataDestination = dataDestination; this.managedResources = managedResources; @@ -113,10 +113,10 @@ public TransferRequest(String type, String assetId, String connectorAddress, Str this.callbackAddresses = callbackAddresses; } - public TransferRequest(JsonNode context, String assetId, String connectorAddress, String contractId, DataDestination dataDestination, Boolean managedResources, String protocol, String transferType, List callbackAddresses) { + public TransferRequest(JsonNode context, String assetId, String counterPartyAddress, String contractId, DataDestination dataDestination, Boolean managedResources, String protocol, String transferType, List callbackAddresses) { super(context); this.assetId = assetId; - this.connectorAddress = connectorAddress; + this.counterPartyAddress = counterPartyAddress; this.contractId = contractId; this.dataDestination = dataDestination; this.managedResources = managedResources; @@ -125,10 +125,10 @@ public TransferRequest(JsonNode context, String assetId, String connectorAddress this.callbackAddresses = callbackAddresses; } - public TransferRequest(JsonNode context, String type, String assetId, String connectorAddress, String contractId, DataDestination dataDestination, Boolean managedResources, String protocol, String transferType, List callbackAddresses) { + public TransferRequest(JsonNode context, String type, String assetId, String counterPartyAddress, String contractId, DataDestination dataDestination, Boolean managedResources, String protocol, String transferType, List callbackAddresses) { super(context, type); this.assetId = assetId; - this.connectorAddress = connectorAddress; + this.counterPartyAddress = counterPartyAddress; this.contractId = contractId; this.dataDestination = dataDestination; this.managedResources = managedResources; @@ -145,11 +145,11 @@ public String getAssetId() { public void setAssetId(String assetId) { this.assetId = assetId; } - public String getConnectorAddress() { - return connectorAddress; + public String getCounterPartyAddress() { + return counterPartyAddress; } - public void setConnectorAddress(String connectorAddress) { - this.connectorAddress = connectorAddress; + public void setCounterPartyAddress(String counterPartyAddress) { + this.counterPartyAddress = counterPartyAddress; } public String getContractId() { return contractId; } public void setContractId(String contractId) { this.contractId = contractId; } From 8025103c738c91d84eeae970753de0675e19eaa7 Mon Sep 17 00:00:00 2001 From: Muhammad Saud Khan Date: Wed, 17 Jul 2024 20:08:08 +0200 Subject: [PATCH 7/7] fix(backend): fixed policy action type --- .../digitalproductpass/src/main/resources/application.yml | 4 ++-- .../src/test/java/managers/ProcessManagerTest.java | 2 +- .../src/test/java/utils/PolicyUtilTest.java | 6 +++--- .../src/test/resources/application-test.yml | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/dpp-backend/digitalproductpass/src/main/resources/application.yml b/dpp-backend/digitalproductpass/src/main/resources/application.yml index d8bfb7d30..26e5eb15e 100644 --- a/dpp-backend/digitalproductpass/src/main/resources/application.yml +++ b/dpp-backend/digitalproductpass/src/main/resources/application.yml @@ -94,7 +94,7 @@ configuration: # List of allowed permissions policies policies: - permission: - - action: "USE" + - action: "odrl:use" logicalConstraint: "odrl:and" constraints: - leftOperand: "cx-policy:Membership" @@ -156,7 +156,7 @@ configuration: strictMode: false policies: - permission: - - action: "USE" + - action: "odrl:use" logicalConstraint: "odrl:and" constraints: - leftOperand: "cx-policy:Membership" diff --git a/dpp-backend/digitalproductpass/src/test/java/managers/ProcessManagerTest.java b/dpp-backend/digitalproductpass/src/test/java/managers/ProcessManagerTest.java index 866e33a99..d8daadb9e 100644 --- a/dpp-backend/digitalproductpass/src/test/java/managers/ProcessManagerTest.java +++ b/dpp-backend/digitalproductpass/src/test/java/managers/ProcessManagerTest.java @@ -572,7 +572,7 @@ void saveTransferRequestAndTransfer() { transferRequest.setProtocol("HTTP"); transferRequest.setContractId(contractId); transferRequest.setAssetId(assetId); - transferRequest.setConnectorAddress("connectorAddress"); + transferRequest.setCounterPartyAddress("connectorAddress"); String transferId = UUID.randomUUID().toString(); Transfer transfer = new Transfer(); diff --git a/dpp-backend/digitalproductpass/src/test/java/utils/PolicyUtilTest.java b/dpp-backend/digitalproductpass/src/test/java/utils/PolicyUtilTest.java index e2cd823c0..f4eb3d2d1 100644 --- a/dpp-backend/digitalproductpass/src/test/java/utils/PolicyUtilTest.java +++ b/dpp-backend/digitalproductpass/src/test/java/utils/PolicyUtilTest.java @@ -165,13 +165,13 @@ void setUp() { correctLogicalConstraint.put("odrl:and", correctContraints); - action.put("odrl:action", new LinkedHashMap<>(){{put("odrl:type","USE");}}); + action.put("odrl:action", new LinkedHashMap<>(){{put("@id","odrl:use");}}); action.put("odrl:constraint", logicalConstraint); - correctAction.put("odrl:action", new LinkedHashMap<>(){{put("odrl:type","USE");}}); + correctAction.put("odrl:action", new LinkedHashMap<>(){{put("@id","odrl:use");}}); correctAction.put("odrl:constraint", correctLogicalConstraint); - actionDtr.put("odrl:action", new LinkedHashMap<>(){{put("odrl:type","USE");}}); + actionDtr.put("odrl:action", new LinkedHashMap<>(){{put("@id","odrl:use");}}); actionDtr.put("odrl:constraint", logicalConstraintDtr); singlePermission = correctAction; diff --git a/dpp-backend/digitalproductpass/src/test/resources/application-test.yml b/dpp-backend/digitalproductpass/src/test/resources/application-test.yml index f97c22b0f..fc5cfc6bc 100644 --- a/dpp-backend/digitalproductpass/src/test/resources/application-test.yml +++ b/dpp-backend/digitalproductpass/src/test/resources/application-test.yml @@ -93,7 +93,7 @@ configuration: # List of allowed permissions policies policies: - permission: - - action: "USE" + - action: "odrl:use" logicalConstraint: "odrl:and" constraints: - leftOperand: "cx-policy:Membership" @@ -174,7 +174,7 @@ configuration: strictMode: false # The strict mode is quicker and requires less computation complexity, the default mode is comparing against every single object value policies: - permission: - - action: "USE" + - action: "odrl:use" logicalConstraint: "odrl:and" constraints: - leftOperand: "cx-policy:Membership"