Skip to content

Commit

Permalink
Merge branch 'main' into fix/#503-Fix-tests-Tavern-Cucumber-Tests
Browse files Browse the repository at this point in the history
# Conflicts:
#	local/testing/api-tests/README.md
  • Loading branch information
mkanal committed Apr 25, 2024
2 parents b025745 + 3f5c59f commit ad734b9
Show file tree
Hide file tree
Showing 30 changed files with 188 additions and 191 deletions.
23 changes: 17 additions & 6 deletions .github/workflows/publish-documentation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@ jobs:
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

- name: Build API documentation with Maven
run: |
mvn clean package -pl irs-common,irs-models,irs-policy-store,irs-testing,irs-edc-client,irs-registry-client,irs-api -DskipTests --batch-mode
cp irs-api/target/generated-sources/openapi/index.html docs/src/docs/api-specification/index.html
- name: Build with Maven
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
Expand Down Expand Up @@ -112,10 +107,26 @@ jobs:
run: |
mv docs/src/diagram-replacer/assets/ docs/target/generated-docs/assets/
- name: Generate Swagger UI
uses: Legion2/swagger-ui-action@v1
with:
output: swagger-ui
spec-file: docs/src/api/irs-api.yaml

- name: Update documentation on GitHub Pages
if: github.ref == 'refs/heads/main'
uses: peaceiris/actions-gh-pages@v3.9.3
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: "./docs/target/generated-docs"
destination_dir: "docs"

- name: Deploy Swagger UI to GitHub Pages
if: github.ref == 'refs/heads/main'
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: "swagger-ui"
destination_dir: "docs/swagger-ui"


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
173 changes: 87 additions & 86 deletions DEPENDENCIES

Large diffs are not rendered by default.

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
5 changes: 0 additions & 5 deletions docs/src/docs/api-specification/api-specification.adoc

This file was deleted.

5 changes: 0 additions & 5 deletions docs/src/docs/api-specification/api.adoc

This file was deleted.

10 changes: 0 additions & 10 deletions docs/src/docs/api-specification/index.html

This file was deleted.

4 changes: 2 additions & 2 deletions docs/src/docs/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
== Administration Guide
xref:administration/administration-guide.adoc[]

== API-Documentation
xref:api-specification/api-specification.adoc[OpenApi specification]
== Swagger-UI
xref:swagger-ui/index.adoc[Swagger-UI]

== Architecture Documentation (arc42)
- xref:arc42/index.adoc[Single chapters]
Expand Down
13 changes: 13 additions & 0 deletions docs/src/docs/swagger-ui/index.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
= Swagger-UI

== NOTICE

This work is licensed under the https://www.apache.org/licenses/LICENSE-2.0[Apache-2.0].

- SPDX-License-Identifier: Apache-2.0
- SPDX-FileCopyrightText: 2021, 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
- SPDX-FileCopyrightText: 2022, 2023 BOSCH AG
- SPDX-FileCopyrightText: 2021, 2022 ZF Friedrichshafen AG
- SPDX-FileCopyrightText: 2022 ISTOS GmbH
- SPDX-FileCopyrightText: 2021, 2023 Contributors to the Eclipse Foundation
- Source URL: https://github.com/eclipse-tractusx/item-relationship-service
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
17 changes: 12 additions & 5 deletions local/testing/api-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ This folder contains [Tavern](https://tavern.readthedocs.io) API tests for the I

## Usage

* Install python
* Install pytest: ```py -m pip install pytest```
* Install tavern: ```py -m pip install tavern```
* Create variable.env in directory api-tests
* Copy content to variable.env
1. Install python
2. Install pytest: ```py -m pip install pytest```
3. Install tavern: ```py -m pip install tavern```
4. Create variable.env in directory api-tests
5. Copy content to variable.env
```
# this is temporary file for local development to setup environments variable such a secrets and URLs
# to run it just execute in console:
Expand Down Expand Up @@ -36,3 +36,10 @@ export ADMIN_USER_API_KEY_ESS=



2. To run a single test:
```console
py -m pytest local/testing/api-tests/irs-api-tests.tavern.yaml::"<test name>"

# for example:
py -m pytest local/testing/api-tests/irs-api-tests.tavern.yaml::"Make sure job with submodels process with status COMPLETED with asPlanned-id"
```
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
Loading

0 comments on commit ad734b9

Please sign in to comment.