Skip to content

Commit

Permalink
Chore: adds tests to data plane aas (#123)
Browse files Browse the repository at this point in the history
* Add some tests

* Improve / Adapt some docs / configs

* Fix test failures /  get ports via edc

* Add license header, change log message

* Update some docs

* Make synchronizer rate configurable at runtime

* Fix data transfer throwing exception
When data sink aasDataProcessor could not be created

* Update some tests / Code cleanup
  • Loading branch information
carlos-schmidt authored Jul 14, 2024
1 parent 4c3f91f commit 0ce024c
Show file tree
Hide file tree
Showing 44 changed files with 911 additions and 150 deletions.
73 changes: 37 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ model via the EDC.

The repository contains several material:

- `client`: Source code for the client extension (automated contract negotiation)
- `client`: The client extension: Automated contract negotiation from HTTP endpoints
- `config`: Checkstyle files for code formatting
- `data-plane-aas`: AAS data plane implementation (following HTTP data plane)
- `edc-extension4aas`: Source code for the AAS extension
- `example`: Example use case for the edc-extension4aas and client extension with a preconfigured EDC launcher.
- `edc-extension4aas`: The AAS extension
- `example`: Example use case for the AAS extension with a preconfigured EDC launcher.
- `public-api-management`: Managing outward facing endpoints (http) which require no authentication

<!-- ------------------Template Section --------------------------- -->
Expand Down Expand Up @@ -82,10 +82,9 @@ Provide digital twin (AAS) data to business partners in Data Spaces like Catena-

### Dependencies

In this section, dependencies from EDC and third-party are listed. (Implementation for test runs are not listed)
In this section, dependencies from EDC and third-party are listed. (Implementation for test runs are not shown)
<details>

#### EDC-Extension-for-AAS
<summary>EDC-Extension-for-AAS</summary>

| Name | Description |
|:----------------------------------------------|:----------------------------------------------------------------------------------------------------|
Expand All @@ -95,7 +94,9 @@ In this section, dependencies from EDC and third-party are listed. (Implementati
| org.eclipse.edc:http-spi | OkHttp3 Fields |
| org.eclipse.edc:management-api | EDC Asset/Contract Management |

#### Client Extension
</details>
<details>
<summary>Client Extension</summary>

| Name | Description |
|:--------------------------------------------|:-------------------------------------------------------------------------|
Expand All @@ -109,62 +110,62 @@ In this section, dependencies from EDC and third-party are listed. (Implementati
| org.eclipse.edc:json-ld-lib | JsonLD expansion |
| org.eclipse.edc:management-api | EDC WebService for registering endpoints |

#### Data-Plane-AAS
</details>
<details>
<summary>Data-Plane-AAS</summary>

| Name | Description |
|:------------------------------------------|:-----------------------------------------------------------------------------------|
| org.eclipse.edc:data-plane-spi | Data-plane functionality |
| org.eclipse.edc:http-spi | OkHttp3 Fields |
| org.eclipse.edc:lib | OkHttp3 Fields + EdcHttpClient implementation |
| org.eclipse.digitaltwin.aas4j:aas4j-model | [Eclipse AAS4J java model](https://github.com/eclipse-aas4j/aas4j/tree/main/model) |

#### Public API Management Extension
</details>
<details>
<summary>Public API Management Extension</summary>

| Name | Description |
|:-------------------------|:-----------------------|
| org.eclipse.edc:auth-spi | EDC Authentication SPI |

</details>

### Configurations
### Configuration Values

<details>
<summary>Common Configuration Values</summary>
<summary>Common Configurations</summary>

| Key | Values | Description |
|:--------------------------------------------------|:---------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| edc.dataplane.aas.acceptAllSelfSignedCertificates | True/__False__ | Accept self-signed certificates from ALL AAS services (internal+external, provider+consumer) |
| edc.dataplane.aas.acceptOwnSelfSignedCertificates | True/__False__ | Accept self-signed certificates from registered services (example: Creating AAS service in extension -> extension registers service at dataplane to allow its self-signed certificate) |
| edc.client.acceptAllProviderOffers | True/False | If true, the client accepts any contractOffer offered by a provider connector on automated contract negotiation (e.g., trusted provider). Default value: false |
| Key | Values | Description |
|:--------------------------------------------------|:------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| edc.dataplane.aas.acceptAllSelfSignedCertificates | True/<u>False</u> | Accept self-signed certificates from ALL AAS services (internal+external, provider+consumer) |
| edc.dataplane.aas.acceptOwnSelfSignedCertificates | True/<u>False</u> | Accept self-signed certificates from registered services (example: Creating AAS service in extension -> extension registers service at dataplane to allow its self-signed certificate) |

</details>

<details>

<summary>EDC-Extension-for-AAS Configurations</summary>

| Key | Value Type | Description |
|:----------------------------------|:------------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| edc.aas.remoteAasLocation | URL | A URL of an AAS service (such as FA³ST) that is already running and is conformant with official AAS API specification |
| edc.aas.localAASModelPath | path | A path to a serialized AAS environment compatible to specification version 3.0RC01 (see: https://github.com/FraunhoferIOSB/FAAAST-Service/blob/main/README.md) |
| edc.aas.localAASServicePort | Open network port | Port to locally created AAS service. Required, if localAASModelPath is defined and localAASServiceConfigPath is not defined. |
| edc.aas.localAASServiceConfigPath | path | Path to AAS config for locally started AAS service. Required, if localAASServicePort is not defined, but localAASModelPath is defined. |
| edc.aas.syncPeriod | whole number in seconds | Time period in which AAS services should be polled for structural changes (added/deleted elements etc.). Default value is 5 (seconds). Note: This configuration value is only read on startup, the synchronization period cannot be changed at runtime. |
| edc.aas.exposeSelfDescription | boolean | Whether the Self Description should be exposed on {edc}/api/selfDescription. When set to False, the selfDescription is still available for authenticated requests. |
| edc.aas.defaultAccessPolicyPath | path | Path to an access policy file (JSON). This policy will be used as the default access policy for all assets created after the configuration value has been set. |
| edc.aas.defaultContractPolicyPath | path | Path to a contract policy file (JSON). This policy will be used as the default contract policy for all assets created after the configuration value has been set. |
| edc.aas.onlySubmodels | boolean | (Provider) Only list submodels of AAS services |
<summary>EDC-Extension-for-AAS</summary>

| Key | Value Type | Description |
|:----------------------------------|:------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| edc.aas.defaultAccessPolicyPath | path | Path to an access policy file (JSON). This policy will be used as the default access policy for all assets created after the configuration value has been set. |
| edc.aas.defaultContractPolicyPath | path | Path to a contract policy file (JSON). This policy will be used as the default contract policy for all assets created after the configuration value has been set. |
| edc.aas.exposeSelfDescription | boolean | Whether the Self Description should be exposed on {edc}/api/selfDescription. When set to False, the selfDescription is still available for authenticated requests. Default: True |
| edc.aas.localAASModelPath | path | A path to a serialized AAS environment compatible to specification version 3.0RC01 (see: https://github.com/FraunhoferIOSB/FAAAST-Service/blob/main/README.md) |
| edc.aas.localAASServiceConfigPath | path | Path to AAS config for locally started AAS service. Required, if localAASServicePort is not defined, but localAASModelPath is defined. |
| edc.aas.localAASServicePort | Open network port | Port to locally created AAS service. Required, if localAASModelPath is defined and localAASServiceConfigPath is not defined. |
| edc.aas.onlySubmodels | boolean | (Provider) Only register submodels of AAS services. Default: False |
| edc.aas.remoteAasLocation | URL | Register a URL of an AAS service (such as FA³ST) that is already running and is conformant with official AAS API specification |
| edc.aas.syncPeriod | number in seconds | Time period in which AAS services should be polled for structural changes (added/deleted elements etc.). Default: 5 (seconds). |

</details>

<details>

<summary>Client Extension Configurations</summary>
<summary>Client Extension</summary>

| Key | Value Type | Description |
|:-----------------------------------------|:------------------------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| edc.client.acceptAllProviderOffers | True/<u>False</u> | Accept any contractOffer offered by all provider connectors on automated contract negotiation (e.g., trusted provider) |
| edc.client.acceptedPolicyDefinitionsPath | path | Path pointing to a JSON-file containing acceptable PolicyDefinitions for automated contract negotiation in a list (only policies must match in a provider's PolicyDefinition) |
| edc.client.waitForAgreementTimeout | whole number in seconds | How long should the extension wait for an agreement when automatically negotiating a contract? Default value is 10(s). |
| edc.client.waitForTransferTimeout | whole number in seconds | How long should the extension wait for a data transfer when automatically negotiating a contract? Default value is 10(s). |
| edc.client.acceptedPolicyDefinitionsPath | path | Path pointing to a JSON-file containing acceptable PolicyDefinitions for automated contract negotiation in a list (only policies must match in a provider's PolicyDefinition) |

</details>

Expand Down
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ Compatibility: **Eclipse Dataspace Connector v0.8.0**
* Accepting self-signed certificates now
optional (`edc.dataplane.aas.acceptOwnSelfSignedCertificates`, `edc.dataplane.aas.acceptAllSelfSignedCertificates`)
* SubmodelElementList is now a model element inside the SelfDescription (AASv3 change)
* Synchronizer rate can now be changed at runtime via configuration updates (time unit still in seconds)

* New extension: data-plane-aas
* Provides custom AAS data source and data sink
* Communicate with AAS over AASDataAddress (see above, reference chains)
* Allow communication with AAS with self-signed TLS certificates (configurable)
* Use default EdcHttpClient if not self-signed

**Bugfixes**

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright (c) 2021 Fraunhofer IOSB, eine rechtlich nicht selbstaendige
* Einrichtung der Fraunhofer-Gesellschaft zur Foerderung der angewandten
* Forschung e.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://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.
*/
package de.fraunhofer.iosb.client;

import org.eclipse.edc.api.auth.spi.AuthenticationService;
Expand Down
13 changes: 11 additions & 2 deletions data-plane-aas/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,26 @@ val edcVersion: String by project
val aas4jVersion: String by project
val faaastVersion: String by project
val jupiterVersion: String by project
val mockitoVersion: String by project

repositories { mavenCentral() }

dependencies {
implementation("$group:data-plane-spi:${edcVersion}")
implementation("$group:http-spi:${edcVersion}")
implementation("$group:data-plane-spi:${edcVersion}") {
exclude(group = "dev.failsafe", module = "failsafe")
exclude(group = group, module = "policy-model")
}
implementation("$group:http-lib:${edcVersion}") {
exclude(group = group, module = "auth-spi") // Not needed in this extension
exclude(group = group, module = "core-spi") // Already by data-plane-spi
}

implementation("org.eclipse.digitaltwin.aas4j:aas4j-model:${aas4jVersion}")

testImplementation("$group:junit:$edcVersion")
testImplementation("org.junit.jupiter:junit-jupiter-api:${jupiterVersion}")
testImplementation("de.fraunhofer.iosb.ilt.faaast.service:starter:${faaastVersion}")
testImplementation("org.mockito:mockito-core:${mockitoVersion}")
}

tasks.test { useJUnitPlatform() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
import de.fraunhofer.iosb.registry.AasServiceRegistry;
import de.fraunhofer.iosb.ssl.impl.DefaultSelfSignedCertificateRetriever;
import de.fraunhofer.iosb.ssl.impl.NoOpSelfSignedCertificateRetriever;
import dev.failsafe.RetryPolicy;
import okhttp3.OkHttpClient;
import okhttp3.Response;
import org.eclipse.edc.connector.dataplane.spi.pipeline.PipelineService;
import org.eclipse.edc.runtime.metamodel.annotation.Extension;
import org.eclipse.edc.runtime.metamodel.annotation.Inject;
Expand Down Expand Up @@ -58,6 +61,10 @@ public class DataPlaneAasExtension implements ServiceExtension {

@Inject
private PipelineService pipelineService;
@Inject
private OkHttpClient okHttpClient;
@Inject
private RetryPolicy<Response> retryPolicy;

public void initialize(ServiceExtensionContext context) {
var monitor = context.getMonitor();
Expand All @@ -72,8 +79,8 @@ public void initialize(ServiceExtensionContext context) {
var registeredServices = (ownSelfSigned || allSelfSigned) ? new HashSet<String>() : null;

var aasDataProcessorFactory = allSelfSigned ?
new AllAasDataProcessorFactory(retriever) :
new RegisteredAasDataProcessorFactory(retriever, registeredServices);
new AllAasDataProcessorFactory(retriever, okHttpClient, retryPolicy, monitor) :
new RegisteredAasDataProcessorFactory(retriever, registeredServices, okHttpClient, retryPolicy, monitor);

context.registerService(AasDataProcessorFactory.class, aasDataProcessorFactory);

Expand Down
Loading

0 comments on commit 0ce024c

Please sign in to comment.