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-validation):[#757] fix #788

Merged
Show file tree
Hide file tree
Changes from all 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 @@ -12,7 +12,8 @@ _**For better traceability add the corresponding GitHub issue number in each cha

### Fixed

- Fixed ESS Investigation job processing not starting #579
- Access and Usage Policy Validation flow correction. #757
- Fixed ESS Investigation job processing not starting. #579
- Policy store API returns 'rightOperand' without 'odrl:' prefix now (see traceability-foss/issues/970).
- Fixed trivy workflow to fail only on CRITICAL, HIGH (according to https://github.com/eclipse-tractusx/eclipse-tractusx.github.io/pull/949/files).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ public List<Policy> getStoredPolicies(final List<String> bpnls) {
}
}

public List<AcceptedPolicy> getConfiguredDefaultPolicies() {
return allowedPoliciesFromConfig.stream().map(this::toAcceptedPolicy).toList();
}

public Map<String, List<Policy>> getAllStoredPolicies() {
final Map<String, List<Policy>> bpnToPolicies = persistence.readAll();
if (bpnToPolicies.isEmpty()) {
Expand Down Expand Up @@ -267,13 +271,12 @@ private Optional<Policy> findPolicy(final String policyId, final List<String> bp
public List<AcceptedPolicy> getAcceptedPolicies(final String bpn) {

if (bpn == null) {
return getAllPolicies();
return getConfiguredDefaultPolicies();
}

final List<Policy> storedPolicies = getStoredPolicies(List.of(bpn));
final Stream<Policy> result = sortByPolicyId(storedPolicies);
return result.map(this::toAcceptedPolicy).toList();

}

private static Stream<Policy> sortByPolicyId(final List<Policy> policies) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
package org.eclipse.tractusx.irs.policystore.services;

import static java.util.Collections.emptyList;
import static java.util.Collections.emptyMap;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.ArgumentMatchers.any;
Expand Down Expand Up @@ -312,9 +311,6 @@ class GetAcceptedPoliciesTests {
@Test
void getAcceptedPolicies_whenParameterBpnIsNull_shouldReturnTheConfiguredDefaultPolicy() {

// ARRANGE
when(persistenceMock.readAll()).thenReturn(emptyMap());

// ACT
final var acceptedPolicies = testee.getAcceptedPolicies(null);

Expand Down
Loading