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

Clean up acceptedPolicies configuration #551

Merged
merged 8 commits into from
Apr 19, 2024
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ _**For better traceability add the corresponding GitHub issue number in each cha

## [Unreleased]

## Changed

- Removed obsolete entries from acceptedPolicies configuration. #530

### Fixed

- Update bouncycastle to 1.78 to fix CVE's.
Expand Down
6 changes: 0 additions & 6 deletions charts/item-relationship-service/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,9 @@ edc:
# IRS will only negotiate contracts for offers with a policy as defined in the allowedNames list.
# If a requested asset does not provide one of these policies, a tombstone will be created and this node will not be processed.
acceptedPolicies:
- leftOperand: "PURPOSE"
operator: "eq"
rightOperand: "ID 3.0 Trace"
- leftOperand: "PURPOSE"
operator: "eq"
rightOperand: "ID 3.1 Trace"
- leftOperand: "PURPOSE"
operator: "eq"
rightOperand: R2_Traceability
- leftOperand: "FrameworkAgreement.traceability"
operator: "eq"
rightOperand: "active"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ policy store in order to receice further on assets with the specific policy.
"odrl:operator": {
"@id": "odrl:eq"
},
"odrl:rightOperand": "ID 3.0 Trace"
"odrl:rightOperand": "ID 3.1 Trace"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ note left
},
"rightExpression": {
"edctype": "dataspaceconnector:literalexpression",
"value": "ID 3.0 Trace"
"value": "ID 3.1 Trace"
},
"operator": "EQ"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ private void registerAsset(final String assetId, final String notificationType,
}
}
""".formatted(assetId, notificationType, essBaseUrl + path);
final var entity = restTemplate.exchange(edcProviderUrl + assetsPath, HttpMethod.POST,
toEntity(body), String.class);
final var entity = restTemplate.exchange(edcProviderUrl + assetsPath, HttpMethod.POST, toEntity(body),
String.class);

if (entity.getStatusCode().is2xxSuccessful()) {
log.info("Notification asset registered successfully.");
Expand Down Expand Up @@ -160,7 +160,7 @@ private void registerPolicy(final String policyId) {
"odrl:operator": {
"@id": "odrl:eq"
},
"odrl:rightOperand": "ID 3.0 Trace"
"odrl:rightOperand": "ID 3.1 Trace"
}
]
}
Expand All @@ -169,8 +169,8 @@ private void registerPolicy(final String policyId) {
}
}
""".formatted(policyId);
final var entity = restTemplate.exchange(edcProviderUrl + policydefinitionsPath,
HttpMethod.POST, toEntity(body), String.class);
final var entity = restTemplate.exchange(edcProviderUrl + policydefinitionsPath, HttpMethod.POST,
toEntity(body), String.class);

if (entity.getStatusCode().is2xxSuccessful()) {
log.info("Notification policy registered successfully.");
Expand All @@ -194,8 +194,8 @@ private void registerContractDefinition(final String contractId, final String as
}
""".formatted(contractId, contractId, assetId);

final var entity = restTemplate.exchange(edcProviderUrl + contractdefinitionsPath,
HttpMethod.POST, toEntity(body), String.class);
final var entity = restTemplate.exchange(edcProviderUrl + contractdefinitionsPath, HttpMethod.POST,
toEntity(body), String.class);
if (entity.getStatusCode().is2xxSuccessful()) {
log.info("Notification contract definition registered successfully.");
} else {
Expand Down
6 changes: 0 additions & 6 deletions irs-api/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,9 @@ irs-edc-client:
# IRS will only negotiate contracts for offers with a policy as defined in the acceptedPolicies list.
# If a requested asset does not provide one of these policies, a tombstone will be created and this node will not be processed.
acceptedPolicies:
- leftOperand: "PURPOSE"
operator: "eq"
rightOperand: "ID 3.0 Trace"
- leftOperand: "PURPOSE"
operator: "eq"
rightOperand: "ID 3.1 Trace"
- leftOperand: "PURPOSE"
operator: "eq"
rightOperand: R2_Traceability
- leftOperand: "FrameworkAgreement.traceability"
operator: "eq"
rightOperand: "active"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void shouldMapContstraints() throws JsonProcessingException {
.leftExpression(
new LiteralExpression("idsc:PURPOSE"))
.rightExpression(
new LiteralExpression("ID 3.0 Trace"))
new LiteralExpression("ID 3.1 Trace"))
.build();
final ObjectMapper objectMapper = new JsonLdConfiguration().objectMapper();
final String s = objectMapper.writeValueAsString(atomicConstraint);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void shouldParseEdcContractAgreementsResponse() throws JsonProcessingException {
"odrl:operator": {
"@id": "odrl:eq"
},
"odrl:rightOperand": "ID 3.0 Trace"
"odrl:rightOperand": "ID 3.1 Trace"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void shouldRejectWrongPolicy() {
@Test
void shouldRejectWhenPolicyStoreIsEmpty() {
// given
Policy policy = createAtomicConstraintPolicy(TestConstants.PURPOSE, TestConstants.ID_3_0_TRACE);
Policy policy = createAtomicConstraintPolicy(TestConstants.PURPOSE, TestConstants.ID_3_1_TRACE);
when(policyStore.getAcceptedPolicies(any())).thenReturn(List.of());
// when
boolean result = policyCheckerService.isValid(policy, "bpn");
Expand Down Expand Up @@ -102,12 +102,12 @@ void shouldRejectAndConstraintsWhenOnlyOneMatch() {
@Test
void shouldAcceptAndConstraintsWhenAcceptedPolicyContainsMoreConstraintsSuperSetOfProvidedPolicy() {
// given
final Constraint constraint1 = new Constraint(TestConstants.FRAMEWORK_AGREEMENT_TRACEABILITY, new Operator(OperatorType.EQ),
TestConstants.STATUS_ACTIVE);
final Constraint constraint1 = new Constraint(TestConstants.FRAMEWORK_AGREEMENT_TRACEABILITY,
new Operator(OperatorType.EQ), TestConstants.STATUS_ACTIVE);
final Constraint constraint2 = new Constraint(TestConstants.MEMBERSHIP, new Operator(OperatorType.EQ),
TestConstants.STATUS_ACTIVE);
final Constraint constraint3 = new Constraint(TestConstants.FRAMEWORK_AGREEMENT_DISMANTLER, new Operator(OperatorType.EQ),
TestConstants.STATUS_ACTIVE);
final Constraint constraint3 = new Constraint(TestConstants.FRAMEWORK_AGREEMENT_DISMANTLER,
new Operator(OperatorType.EQ), TestConstants.STATUS_ACTIVE);
final var policyList = List.of(
new AcceptedPolicy(policy("and-policy", List.of(constraint1, constraint2, constraint3), List.of()),
OffsetDateTime.now().plusYears(1)));
Expand All @@ -127,12 +127,12 @@ void shouldAcceptAndConstraintsWhenAcceptedPolicyContainsMoreConstraintsSuperSet
@Test
void shouldAcceptOrConstraintsWhenAcceptedPolicyContainsMoreConstraintsSuperSetOfProvidedPolicy() {
// given
final Constraint constraint1 = new Constraint(TestConstants.FRAMEWORK_AGREEMENT_TRACEABILITY, new Operator(OperatorType.EQ),
TestConstants.STATUS_ACTIVE);
final Constraint constraint1 = new Constraint(TestConstants.FRAMEWORK_AGREEMENT_TRACEABILITY,
new Operator(OperatorType.EQ), TestConstants.STATUS_ACTIVE);
final Constraint constraint2 = new Constraint(TestConstants.MEMBERSHIP, new Operator(OperatorType.EQ),
TestConstants.STATUS_ACTIVE);
final Constraint constraint3 = new Constraint(TestConstants.FRAMEWORK_AGREEMENT_DISMANTLER, new Operator(OperatorType.EQ),
TestConstants.STATUS_ACTIVE);
final Constraint constraint3 = new Constraint(TestConstants.FRAMEWORK_AGREEMENT_DISMANTLER,
new Operator(OperatorType.EQ), TestConstants.STATUS_ACTIVE);
final var policyList = List.of(
new AcceptedPolicy(policy("and-policy", List.of(), List.of(constraint1, constraint2, constraint3)),
OffsetDateTime.now().plusYears(1)));
Expand All @@ -152,12 +152,12 @@ void shouldAcceptOrConstraintsWhenAcceptedPolicyContainsMoreConstraintsSuperSetO
@Test
void shouldAcceptConstraintsWithDefaultPolicy() {
// given
final Constraint constraint1 = new Constraint(TestConstants.FRAMEWORK_AGREEMENT_TRACEABILITY, new Operator(OperatorType.EQ),
TestConstants.STATUS_ACTIVE);
final Constraint constraint1 = new Constraint(TestConstants.FRAMEWORK_AGREEMENT_TRACEABILITY,
new Operator(OperatorType.EQ), TestConstants.STATUS_ACTIVE);
final Constraint constraint2 = new Constraint(TestConstants.MEMBERSHIP, new Operator(OperatorType.EQ),
TestConstants.STATUS_ACTIVE);
final Constraint constraint3 = new Constraint(TestConstants.FRAMEWORK_AGREEMENT_DISMANTLER, new Operator(OperatorType.EQ),
TestConstants.STATUS_ACTIVE);
final Constraint constraint3 = new Constraint(TestConstants.FRAMEWORK_AGREEMENT_DISMANTLER,
new Operator(OperatorType.EQ), TestConstants.STATUS_ACTIVE);

final var policyList = List.of(new AcceptedPolicy(
policy("default-policy", List.of(constraint1, constraint2, constraint3),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void setUp() {
@Test
void testCreatePolicyDefinitionRequest() throws JsonProcessingException, JSONException {
// given
String policyName = "ID 3.0 Trace";
String policyName = "ID 3.1 Trace";
String policyId = "4cc0bb57-2d64-4cfb-a13b-aceef3477b7e";

// when
Expand All @@ -99,7 +99,7 @@ void testCreatePolicyDefinitionRequest() throws JsonProcessingException, JSONExc
{
"@type": "Constraint",
"odrl:leftOperand": "PURPOSE",
"odrl:rightOperand": "ID 3.0 Trace",
"odrl:rightOperand": "ID 3.1 Trace",
"odrl:operator": {
"@id": "odrl:eq"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public class TestConstants {
public static final String FRAMEWORK_AGREEMENT_DISMANTLER = "FrameworkAgreement.dismantler";
public static final String FRAMEWORK_AGREEMENT_TEST = "FrameworkAgreement.test";
public static final String MEMBERSHIP = "Membership";
public static final String ID_3_0_TRACE = "ID 3.0 Trace";
public static final String ID_3_1_TRACE = "ID 3.1 Trace";
public static final String STATUS_ACTIVE = "active";
public static final String PURPOSE = "PURPOSE";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class EdcTransformerTest {
"odrl:operator": {
"@id": "odrl:eq"
},
"odrl:rightOperand": "ID 3.0 Trace"
"odrl:rightOperand": "ID 3.1 Trace"
}
}
},
Expand Down Expand Up @@ -190,7 +190,7 @@ private static Policy createPolicy(final String assetId) {
new LiteralExpression("idsc:PURPOSE"))
.operator(Operator.EQ)
.rightExpression(
new LiteralExpression("ID 3.0 Trace"))
new LiteralExpression("ID 3.1 Trace"))
.build();
final OrConstraint orConstraint = OrConstraint.Builder.newInstance().constraint(atomicConstraint).build();
final Permission permission = Permission.Builder.newInstance()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
class PolicyStoreServiceTest {

private static final String BPN = "testBpn";
private static final String EXAMPLE_ALLOWED_NAME = "ID 3.0 Trace";
private static final String EXAMPLE_ALLOWED_NAME = "ID 3.1 Trace";
private static final String EXAMPLE_ACCEPTED_LEFT_OPERAND = "PURPOSE";
private static final String REGISTER_POLICY_EXAMPLE_PAYLOAD = PolicyStoreControllerTest.REGISTER_POLICY_EXAMPLE_PAYLOAD;

Expand Down
6 changes: 0 additions & 6 deletions irs-registry-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,9 @@ irs-edc-client:
# IRS will only negotiate contracts for offers with a policy as defined in the acceptedPolicies list.
# If a requested asset does not provide one of these policies, a tombstone will be created and this node will not be processed.
acceptedPolicies:
- leftOperand: "PURPOSE"
operator: "eq"
rightOperand: "ID 3.0 Trace"
- leftOperand: "PURPOSE"
operator: "eq"
rightOperand: "ID 3.1 Trace"
- leftOperand: "PURPOSE"
operator: "eq"
rightOperand: R2_Traceability
- leftOperand: "FrameworkAgreement.traceability"
operator: "eq"
rightOperand: "active"
Expand Down
6 changes: 3 additions & 3 deletions local/testing/testdata/CX_Testdata_v.1.7.0_PartType.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"policies": {
"ID 3.0 Trace": {
"ID 3.1 Trace": {
"@context": {
"odrl": "http://www.w3.org/ns/odrl/2/"
},
"@type": "PolicyDefinitionRequestDto",
"@id": "id-3.0-trace",
"@id": "id-3.1-trace",
"policy": {
"@type": "Policy",
"odrl:permission": [
Expand All @@ -20,7 +20,7 @@
"odrl:operator": {
"@id": "odrl:eq"
},
"odrl:rightOperand": "ID 3.0 Trace"
"odrl:rightOperand": "ID 3.1 Trace"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"policies": {
"ID 3.0 Trace": {
"ID 3.1 Trace": {
"@context": {
"odrl": "http://www.w3.org/ns/odrl/2/"
},
"@type": "PolicyDefinitionRequestDto",
"@id": "id-3.0-trace",
"@id": "id-3.1-trace",
"policy": {
"@type": "Policy",
"odrl:permission": [
Expand All @@ -20,7 +20,7 @@
"odrl:operator": {
"@id": "odrl:eq"
},
"odrl:rightOperand": "ID 3.0 Trace"
"odrl:rightOperand": "ID 3.1 Trace"
}
]
}
Expand Down
6 changes: 3 additions & 3 deletions local/testing/testdata/ESS_Testdata_v2.0.0-AsPlanned.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"policies": {
"ID 3.0 Trace": {
"ID 3.1 Trace": {
"@context": {
"odrl": "http://www.w3.org/ns/odrl/2/"
},
"@type": "PolicyDefinitionRequestDto",
"@id": "id-3.0-trace",
"@id": "id-3.1-trace",
"policy": {
"@type": "Policy",
"odrl:permission": [
Expand All @@ -20,7 +20,7 @@
"odrl:operator": {
"@id": "odrl:eq"
},
"odrl:rightOperand": "ID 3.0 Trace"
"odrl:rightOperand": "ID 3.1 Trace"
},
{
"@type": "Constraint",
Expand Down
10 changes: 5 additions & 5 deletions local/testing/testdata/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ An example policy can look like this:
```json
{
"policies": {
"ID 3.0 Trace": {
"ID 3.1 Trace": {
"@context": {
"odrl": "http://www.w3.org/ns/odrl/2/"
},
"@type": "PolicyDefinitionRequestDto",
"@id": "id-3.0-trace",
"@id": "id-3.1-trace",
"policy": {
"@type": "Policy",
"odrl:permission": [
Expand All @@ -70,7 +70,7 @@ An example policy can look like this:
"@type": "Constraint",
"odrl:leftOperand": "idsc:PURPOSE",
"odrl:operator": "EQ",
"odrl:rightOperand": "ID 3.0 Trace"
"odrl:rightOperand": "ID 3.1 Trace"
}
]
}
Expand All @@ -87,8 +87,8 @@ An example policy can look like this:

There are two options to apply the policy.

1. Use the parameter `-p id-3.0-trace` to apply this policy to every asset
2. Add a field `policy: "id-3.0-trace"` to the top level of each asset you want to use this policy. Every other asset
1. Use the parameter `-p id-3.1-trace` to apply this policy to every asset
2. Add a field `policy: "id-3.1-trace"` to the top level of each asset you want to use this policy. Every other asset
will get the default, empty policy.

It is also possible to define more than one policy at the beginning and then use the `"policy": "<id>"` field to apply a
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"policies": {
"ID 3.0 Trace": {
"ID 3.1 Trace": {
"@context": {
"odrl": "http://www.w3.org/ns/odrl/2/"
},
"@type": "PolicyDefinitionRequestDto",
"@id": "id-3.0-trace",
"@id": "id-3.1-trace",
"policy": {
"@type": "Policy",
"odrl:permission": [
Expand All @@ -20,7 +20,7 @@
"odrl:operator": {
"@id": "odrl:eq"
},
"odrl:rightOperand": "ID 3.0 Trace"
"odrl:rightOperand": "ID 3.1 Trace"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"policies": {
"ID 3.0 Trace": {
"ID 3.1 Trace": {
"@context": {
"odrl": "http://www.w3.org/ns/odrl/2/"
},
"@type": "PolicyDefinitionRequestDto",
"@id": "id-3.0-trace",
"@id": "id-3.1-trace",
"policy": {
"@type": "Policy",
"odrl:permission": [
Expand All @@ -20,7 +20,7 @@
"odrl:operator": {
"@id": "odrl:eq"
},
"odrl:rightOperand": "ID 3.0 Trace"
"odrl:rightOperand": "ID 3.1 Trace"
}
]
}
Expand Down
Loading
Loading