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

fix(policy-store): [#trace-foss-970] return rightOperand without odrl… #725

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ _**For better traceability add the corresponding GitHub issue number in each cha

### Fixed

- Fixed ESS Investigation job processing not starting #579
- Fixed ESS Investigation job processing not starting #579
- Policy store API returns 'rightOperand' without 'odrl:' prefix now (see traceability-foss/issues/970).

### Changed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,14 @@
public class Constraint {

@Schema(implementation = String.class, example = "string")
@JsonAlias({"odrl:leftOperand"})
@JsonAlias({ "odrl:leftOperand" })
ds-jhartmann marked this conversation as resolved.
Show resolved Hide resolved
private String leftOperand;
@JsonAlias("odrl:operator")
@Schema
private Operator operator;
@Schema(implementation = String.class, example = "string")
@JsonProperty("odrl:rightOperand")
@JsonAlias("odrl:rightOperand")
@JsonProperty("rightOperand")
ds-jhartmann marked this conversation as resolved.
Show resolved Hide resolved
private String rightOperand;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/********************************************************************************
* Copyright (c) 2022,2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
* Copyright (c) 2021,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 governing permissions and limitations
* under the License.
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/
package org.eclipse.tractusx.irs.edc.client.policy;

import static org.assertj.core.api.Assertions.assertThat;

import java.util.Collection;
import java.util.List;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

class ConstraintTest {

private ObjectMapper mapper;

@BeforeEach
void setUp() {
mapper = new ObjectMapper();
mapper.registerModule(new JavaTimeModule());
}

@Test
void canReadPermissionsWithDifferentRightOperandAttributeNames() throws JsonProcessingException {

final List<Permission> permissions = mapper.readerForListOf(Permission.class).readValue("""
[
{
"action": "use",
"constraint": {
"and": [
{
"leftOperand": "Membership",
"operator": {
"@id": "eq"
},
"odrl:rightOperand": "active"
},
{
"leftOperand": "PURPOSE",
"operator": {
"@id": "eq"
},
"rightOperand": "ID 3.1 Trace"
}
],
"or": null
}
}
]
""");

assertThat(permissions).isNotEmpty();
assertThat(permissions.stream()
.map(p -> p.getConstraint().getAnd())
.flatMap(Collection::stream)
.map(Constraint::getRightOperand)).containsExactlyInAnyOrder("active", "ID 3.1 Trace");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ public record PolicyResponse(OffsetDateTime validUntil, Payload payload) {
"operator": {
"@id": "eq"
},
"odrl:rightOperand": "active"
"rightOperand": "active"
},
{
"leftOperand": "PURPOSE",
"operator": {
"@id": "eq"
},
"odrl:rightOperand": "ID 3.1 Trace"
"rightOperand": "ID 3.1 Trace"
}
],
"or": null
Expand Down
Loading