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

Feat/518 policy store integration tests #892

Closed
wants to merge 60 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
0cc093c
feat(impl): [#518] add builder to CreatePolicyRequest and UpdatePolic…
dsmf Apr 23, 2024
a1eb42f
feat(impl): [#518] add helper class for policy tests
dsmf Apr 23, 2024
143d44d
feat(impl): [#518] add helper method PolicyTestHelper.jsonFromString
dsmf Apr 23, 2024
ba375c4
feat(impl): [#518] add irs-policy-store as dependency
dsmf Apr 23, 2024
21e9b3c
feat(impl): [#518] add E2E test step definitions for policy store
dsmf Apr 23, 2024
e080e95
feat(impl): [#518] extract PropertyNotFoundException to separate class
dsmf Apr 23, 2024
a31b816
feat(impl): [#518] add policy-store.feature (temporarily)
dsmf Apr 23, 2024
c57d86b
feat(impl): [#518] rename method
dsmf Apr 23, 2024
8833745
feat(impl): [#518] improvements and test for update policy
dsmf Apr 23, 2024
b5923fc
feat(impl): [#518] improve / correct tests
dsmf Apr 24, 2024
604c916
feat(impl): [#518] complete tests from story
dsmf Apr 24, 2024
5ceb3fb
feat(impl): [#518] add forgotten step def
dsmf Apr 24, 2024
0f77425
feat(impl): [#518] split up test step def classes and update todos
dsmf Apr 24, 2024
4b1ae1e
feat(impl): [#518] improvements
dsmf Apr 24, 2024
b7ab223
feat(impl): [#518] improvements
dsmf Apr 24, 2024
a24f4a9
feat(impl): [#518] improvements/fixes
dsmf Apr 24, 2024
33ba65d
feat(impl): [#518] improvements/fixes
dsmf Apr 24, 2024
48dc00d
feat(impl): [#518] correct naming, add step definition
dsmf Apr 24, 2024
aad2e1e
feat(impl): [#518] cleanup
dsmf Apr 24, 2024
1041b0e
feat(impl): [#518] improve IDs and years for better readability and a…
dsmf Apr 25, 2024
dcec256
feat(impl): [#518] improvement
dsmf Apr 25, 2024
1b82620
feat(impl): [#518] new step definitions with PolicyRecordBuilder
dsmf Apr 25, 2024
8a7a4de
feat(impl): [#518] improved by using the steps with PolicyRecordBuilder
dsmf Apr 25, 2024
e7fb865
feat(impl): [#518] remove dependency to irs-policy-store
dsmf Apr 25, 2024
47bc158
feat(impl): [#518] fix dependency issues
dsmf Apr 25, 2024
ff265fb
feat(impl): [#518] cleanup
dsmf Apr 25, 2024
348ba8b
Merge branch 'refs/heads/main' into feat/518-policy-store-integration…
dsmf Apr 25, 2024
a0a14c2
feat(impl): [#518] fix NPE
dsmf Apr 29, 2024
c506417
feat(impl): [#518] move helper code to helper classes
dsmf Apr 29, 2024
88a25ef
feat(impl): [#518] move some code to helper class
dsmf Apr 29, 2024
b05ab1b
feat(impl): [#518] move ObjectMapper to common test helper
dsmf Apr 29, 2024
57dedc8
feat(impl): [#518] move some code to PolicyTestHelper
dsmf Apr 29, 2024
e8a3bc1
feat(impl): [#518] add todo for later
dsmf Apr 29, 2024
5950a1c
feat(impl): [#518] add javadoc
dsmf Apr 29, 2024
a554b9c
feat(impl): [#518] some renaming, import cleanup, javadoc
dsmf Apr 29, 2024
2cb5953
feat(impl): [#518] re-use common code
dsmf Apr 29, 2024
605fb3a
feat(impl): [#518] update todos
dsmf Apr 29, 2024
4000f24
feat(impl): [#518] fix warnings
dsmf Apr 29, 2024
5823260
feat(impl): [#518] rename list to plural
dsmf Apr 29, 2024
c7fe7bb
feat(impl): [#518] add helper method
dsmf Apr 29, 2024
0652a15
feat(impl): [#518] improvements
dsmf Apr 29, 2024
6643033
feat(impl): [#518] add scenario
dsmf Apr 30, 2024
8bb136f
Merge branch 'refs/heads/main' into feat/518-policy-store-integration…
dsmf Apr 30, 2024
00fdf4d
feat(impl): [#518] rename step definition class
dsmf Apr 30, 2024
bc5abde
feat(impl): [#518] update todos and link with PBIs
dsmf Apr 30, 2024
a9597bc
feat(impl): [#518] remove policy-store.feature file
dsmf Apr 30, 2024
4d6afa6
feat(impl): [#518] update CHANGELOG.md
dsmf Apr 30, 2024
a20e430
Update integration-test-DEV.yaml
dsmf Apr 30, 2024
9365226
Update integration-test-DEV.yaml
dsmf Apr 30, 2024
6a0306a
Merge branch 'main' into feat/518-policy-store-integration-tests--rew…
dsmf Apr 30, 2024
5b7d930
feat(impl): [#518] revert addition of unused builder
dsmf May 2, 2024
e38180c
feat(impl): [#518] move content of constant POLICY_TEMPLATE to a file
dsmf May 2, 2024
1975a1f
feat(impl): [#518] removed unused attribute authProperties
dsmf May 2, 2024
4f978fe
Merge branch 'refs/heads/main' into feat/518-policy-store-integration…
dsmf May 2, 2024
1205592
feat(impl): [#518] update CHANGELOG.md
dsmf May 2, 2024
d4580df
Merge branch 'refs/heads/main' into feat/518-policy-store-integration…
dsmf May 2, 2024
424f36d
chore(workflows): [#518] temporarily set other exportFilter
dsmf May 2, 2024
d81199d
chore(workflows): [#518] configure RestAssured request and response l…
dsmf May 2, 2024
cb3e08a
Undo temporarily setting other exportFilter
dsmf May 2, 2024
56a5e60
chore(docs): [#518] fix merge conflict
dsmf May 6, 2024
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
2 changes: 1 addition & 1 deletion .config/pmd-rules.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<rule ref="category/java/documentation.xml/CommentSize">
<properties>
<property name="maxLines" value="23"/>
<property name="maxLineLength" value="120"/>
<property name="maxLineLength" value="100"/>
</properties>
</rule>
<rule ref="category/java/documentation.xml/CommentRequired">
Expand Down
9 changes: 7 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@ _**For better traceability add the corresponding GitHub issue number in each cha

## [Unreleased]

## Added

- Cucumber test step definitions for Policy Store API (Happy Path) including some test helper utilities. #518
-

## [5.1.0] - 2024-05-06


### Changed

- Removed obsolete entries from acceptedPolicies configuration. #530
Expand Down Expand Up @@ -632,8 +638,7 @@ _**For better traceability add the corresponding GitHub issue number in each cha
### Unresolved
- **Select Aspects you need** You are able to select the needed aspects for which you want to collect the correct endpoint information.

[Unreleased]: https://github.com/eclipse-tractusx/item-relationship-service/compare/5.1.0...HEAD
[5.1.0]: https://github.com/eclipse-tractusx/item-relationship-service/compare/5.0.0...5.1.0
[Unreleased]: https://github.com/eclipse-tractusx/item-relationship-service/compare/5.0.0...HEAD
[5.0.0]: https://github.com/eclipse-tractusx/item-relationship-service/compare/4.9.0...5.0.0
[4.9.0]: https://github.com/eclipse-tractusx/item-relationship-service/compare/4.8.0...4.9.0
[4.8.0]: https://github.com/eclipse-tractusx/item-relationship-service/compare/4.7.0...4.8.0
Expand Down
219 changes: 137 additions & 82 deletions DEPENDENCIES

Large diffs are not rendered by default.

5 changes: 0 additions & 5 deletions charts/item-relationship-service/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [7.1.0] - 2024-05-06

### Fixed

- Fix for incomplete renaming of Helm chart (see #489)
- Fixed missing Spring attribute #358


### Changed
- Update IRS version to 5.1.0

## [7.0.1] - 2024-04-17

Expand Down
4 changes: 2 additions & 2 deletions charts/item-relationship-service/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 7.1.0
version: 7.0.1
# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "5.1.0"
appVersion: "5.0.0"
dependencies:
- name: common
repository: https://charts.bitnami.com/bitnami
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,9 @@ data:
client:
registration:
semantics:
authorization-grant-type: client_credentials
client-id: "${SEMANTICS_OAUTH2_CLIENT_ID}" # taken from secret ENV
client-secret: "${SEMANTICS_OAUTH2_CLIENT_SECRET}" # taken from secret ENV
discovery:
authorization-grant-type: client_credentials
client-id: ${DISCOVERY_OAUTH2_CLIENT_ID} # taken from secret ENV
client-secret: ${DISCOVERY_OAUTH2_CLIENT_SECRET} # taken from secret ENV
provider:
Expand Down
2 changes: 1 addition & 1 deletion docs/src/api/irs-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ info:
description: The API of the Item Relationship Service (IRS) for retrieving item
graphs along the value chain of CATENA-X partners.
title: IRS API
version: 5.1.0
version: 5.0.0
servers:
- url: http://localhost:8080
security:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public class IrsApplication {
/**
* The IRS API version.
*/
public static final String API_VERSION = "5.1.0";
public static final String API_VERSION = "5.0.0";

/**
* The URL prefix for IRS API URLs.
Expand Down
2 changes: 1 addition & 1 deletion irs-api/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ spring:
oauth2:
client:
registration:
semantics:
semantics :
authorization-grant-type: client_credentials
client-id: ${SEMANTICS_OAUTH2_CLIENT_ID} # Semantic Hub OAuth2 client ID used to authenticate with the IAM
client-secret: ${SEMANTICS_OAUTH2_CLIENT_SECRET} # Semantic Hub OAuth2 client secret used to authenticate with the IAM
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
import static org.eclipse.tractusx.irs.WiremockSupport.createEndpointDataReference;
import static org.eclipse.tractusx.irs.WiremockSupport.encodedAssetIds;
import static org.eclipse.tractusx.irs.WiremockSupport.randomUUID;
import static org.eclipse.tractusx.irs.component.enums.AspectType.AspectTypesConstants.BATCH;
import static org.eclipse.tractusx.irs.component.enums.AspectType.AspectTypesConstants.SINGLE_LEVEL_BOM_AS_BUILT;
import static org.eclipse.tractusx.irs.testing.wiremock.DiscoveryServiceWiremockSupport.DISCOVERY_FINDER_PATH;
import static org.eclipse.tractusx.irs.testing.wiremock.DiscoveryServiceWiremockSupport.DISCOVERY_FINDER_URL;
import static org.eclipse.tractusx.irs.testing.wiremock.DiscoveryServiceWiremockSupport.EDC_DISCOVERY_PATH;
Expand Down Expand Up @@ -60,6 +58,7 @@
import org.eclipse.tractusx.irs.component.Jobs;
import org.eclipse.tractusx.irs.component.RegisterJob;
import org.eclipse.tractusx.irs.component.enums.JobState;
import org.eclipse.tractusx.irs.data.StringMapper;
import org.eclipse.tractusx.irs.edc.client.EndpointDataReferenceStorage;
import org.eclipse.tractusx.irs.semanticshub.AspectModels;
import org.eclipse.tractusx.irs.semanticshub.SemanticHubWireMockSupport;
Expand Down Expand Up @@ -112,6 +111,12 @@ static void startContainer() {
WiremockSupport.successfulSemanticModelRequest();
}

@AfterEach
void tearDown() {
cacheManager.getCacheNames()
.forEach(cacheName -> Objects.requireNonNull(cacheManager.getCache(cacheName)).clear());
}

@AfterAll
static void stopContainer() {
minioContainer.stop();
Expand All @@ -136,12 +141,6 @@ static void configureProperties(DynamicPropertyRegistry registry) {
registry.add("resilience4j.retry.configs.default.waitDuration", () -> "1s");
}

@AfterEach
void tearDown() {
cacheManager.getCacheNames()
.forEach(cacheName -> Objects.requireNonNull(cacheManager.getCache(cacheName)).clear());
}

@Test
void shouldStartApplicationAndCollectSemanticModels() throws SchemaNotFoundException {
// Arrange
Expand Down Expand Up @@ -265,6 +264,7 @@ void shouldStartRecursiveProcesses() {
assertThat(jobHandle.getId()).isNotNull();
waitForCompletion(jobHandle);
final Jobs jobForJobId = irsService.getJobForJobId(jobHandle.getId(), false);
System.out.println(StringMapper.mapToString(jobForJobId));

assertThat(jobForJobId.getJob().getState()).isEqualTo(JobState.COMPLETED);
assertThat(jobForJobId.getShells()).hasSize(3);
Expand All @@ -280,9 +280,10 @@ private void successfulRegistryAndDataRequest(final String globalAssetId, final
final String batchFileName, final String sbomFileName) {

final String edcAssetId = WiremockSupport.randomUUIDwithPrefix();
final String batch = WiremockSupport.submodelRequest(edcAssetId, BATCH, batchAspectName, batchFileName);
final String batch = WiremockSupport.submodelRequest(edcAssetId, "Batch",
batchAspectName, batchFileName);

final String singleLevelBomAsBuilt = WiremockSupport.submodelRequest(edcAssetId, SINGLE_LEVEL_BOM_AS_BUILT,
final String singleLevelBomAsBuilt = WiremockSupport.submodelRequest(edcAssetId, "SingleLevelBomAsBuilt",
singleLevelBomAsBuiltAspectName, sbomFileName);

final List<String> submodelDescriptors = List.of(batch, singleLevelBomAsBuilt);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@ public static EndpointDataReference createEndpointDataReference(final String con
.getBytes(StandardCharsets.UTF_8));
final String jwtToken = "eyJhbGciOiJSUzI1NiJ9." + b64EncodedAuthCode + ".test";
return EndpointDataReference.Builder.newInstance()
.contractId(contractAgreementId)
.authKey("Authorization")
.id("test")
.authKey("testkey")
.authCode(jwtToken)
.properties(
Map.of(JsonLdConfiguration.NAMESPACE_EDC_CID, contractAgreementId))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/********************************************************************************
* 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.cucumber;

import static io.restassured.RestAssured.given;

import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.function.Predicate;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import io.restassured.RestAssured;
import io.restassured.filter.log.LogDetail;
import io.restassured.filter.log.RequestLoggingFilter;
import io.restassured.filter.log.ResponseLoggingFilter;
import io.restassured.specification.RequestSpecification;
import org.apache.commons.lang3.StringUtils;

/**
* Common helper class for E2E tests.
*/
public class E2ETestHelper {

public static final ObjectMapper objectMapper;

static {
objectMapper = new ObjectMapper();
objectMapper.registerModule(new JavaTimeModule());
objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
}

private static final boolean LOG_EVERY_REQUEST_AND_RESPONSE = true;

public static File getExpectedFile(final String fileName) {
return getFile("expected-files/" + fileName);
}

public static String getTemplateFileContent(final String fileName) throws IOException {
final File file = getTemplateFile(fileName);
byte[] bytes = Files.readAllBytes(file.toPath());
return new String(bytes, StandardCharsets.UTF_8);
}

public static File getTemplateFile(final String fileName) {
return getFile("templates/" + fileName);
}

public static File getFile(final String path) {
final ClassLoader classLoader = E2ETestHelper.class.getClassLoader();
final URL ressource = classLoader.getResource(path);
return new File(ressource.getFile());
}

public static RequestSpecification givenAuthentication(
AuthenticationProperties.AuthenticationPropertiesBuilder authBuilder) {
final AuthenticationProperties authProperties = authBuilder.build();
return given().spec(authProperties.getNewAuthenticationRequestSpecification());
}

static Predicate<String> startingWith(final String prefix) {
return s -> StringUtils.startsWith(s, prefix);
}

public static void configureRequestAndResponseLogging() {
if (LOG_EVERY_REQUEST_AND_RESPONSE) {
final LogDetail logDetail = LogDetail.ALL;
final RequestLoggingFilter requestLoggingFilter = new RequestLoggingFilter(logDetail);
final ResponseLoggingFilter responseLoggingFilter = new ResponseLoggingFilter(logDetail);
RestAssured.filters(requestLoggingFilter, responseLoggingFilter);
} else {
RestAssured.enableLoggingOfRequestAndResponseIfValidationFails(LogDetail.ALL);
}
}
}
Loading