Closed ds-jhartmann closed 4 months ago
Check for policies is done here https://github.com/eclipse-tractusx/item-relationship-service/blob/72b03963cce3895d75e6b651b0b405195dd716d3/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/policy/ConstraintCheckerService.java#L46-L58
Make sure that and constraints match for all constraints
This Test should validate that the check is working as expected: https://github.com/eclipse-tractusx/item-relationship-service/blob/a45960ba21905403ef6d55883709ad0e817221ac/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/policy/ConstraintCheckerServiceTest.java
@Test
void shouldNotAcceptAndConstraintWithOneLessElement1() {
final AndConstraint andConstraint = createAndConstraint(
List.of(createAtomicConstraint(TestConstants.FRAMEWORK_AGREEMENT_TRACEABILITY,
TestConstants.STATUS_ACTIVE),
createAtomicConstraint(TestConstants.PURPOSE, TestConstants.ID_3_1_TRACE)));
final Policy acceptedPolicy = createPolicyWithAndConstraint(
List.of(new Operand(TestConstants.FRAMEWORK_AGREEMENT_TRACEABILITY, TestConstants.STATUS_ACTIVE),
new Operand(TestConstants.MEMBERSHIP, TestConstants.STATUS_ACTIVE),
new Operand(TestConstants.PURPOSE, TestConstants.ID_3_1_TRACE)));
boolean result = cut.hasAllConstraint(acceptedPolicy, List.of(andConstraint));
assertThat(result).isFalse();
}
@ds-jhartmann: shouldn't it be the other way around: andConstraint one constraint more than acceptedPolicy?
final AndConstraint andConstraint = createAndConstraint(
List.of(createAtomicConstraint(TestConstants.FRAMEWORK_AGREEMENT_TRACEABILITY,
TestConstants.STATUS_ACTIVE),
createAtomicConstraint(TestConstants.MEMBERSHIP, TestConstants.STATUS_ACTIVE),
createAtomicConstraint(TestConstants.PURPOSE, TestConstants.ID_3_1_TRACE)));
final Policy acceptedPolicy = createPolicyWithAndConstraint(
List.of(new Operand(TestConstants.FRAMEWORK_AGREEMENT_TRACEABILITY, TestConstants.STATUS_ACTIVE),
new Operand(TestConstants.PURPOSE, TestConstants.ID_3_1_TRACE)));
boolean result = cut.hasAllConstraint(acceptedPolicy, List.of(andConstraint));
assertThat(result).isFalse();
@ds-jhartmann: shouldn't it be the other way around: andConstraint one constraint more than acceptedPolicy?
Oh, you're right. The bug describes your behavior. However, the Test example I provided should also fail, since the Policy does not match exactly
Successfully tested: Starting Point: EDC has 2 constraints
IRS accepted policy has 3 constraints: syntax and value match EDC policy IRS accepted policy has 2 constraints: syntax and value match EDC policy IRS accepted policy has 2 constraints: syntax does not match EDC policy IRS accepted policy has 2 constraints: value does not match EDC policy
Testscenario:
Default policy contains the two constraints
LGFM. PO acceptance in behalf of @jzbmw .
Description
Current behaviour
When IRS accepted policy has a AND constraint with 2 constraints and the EDC offer policy has a AND constraint with 1 constraint, IRS accepts the Policy if one of the IRS accepted policies matches the EDC offer policy AND constraint.
Expected behavior
Steps to reproduce the Bug