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: Contract Termination #996

Merged
merged 71 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from 62 commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
96708d2
WiP agreement details query
ununhexium Jul 3, 2024
dcaafa1
WiP agreement e2e tests failing because of DB access when not needed
ununhexium Jul 4, 2024
72003f7
Cleanup database direct access dependencies
ununhexium Jul 4, 2024
829e8bd
WiP Tests back to passing
ununhexium Jul 5, 2024
b51ddad
WiP Contract Termination REST API
ununhexium Jul 5, 2024
05fed2b
Fix older tests
ununhexium Jul 8, 2024
e6c0b41
Fix tests
ununhexium Jul 8, 2024
a2f7988
EDC-CE-870 100% repro timeout
ununhexium Jul 8, 2024
a85a4cf
Migrate Catalog API Test
ununhexium Jul 9, 2024
6eeb2ac
Suspend test until merge with RT's PR
ununhexium Jul 9, 2024
0655430
-cancel +terminate
ununhexium Jul 9, 2024
a7d8ee9
Assert both sides
ununhexium Jul 9, 2024
0c8cece
Format
ununhexium Jul 9, 2024
3b3a54a
Fix ContractAgreementTransferApiServiceTest
ununhexium Jul 9, 2024
c10db0c
Fix ContractDefinitionPageApiServiceTest
ununhexium Jul 9, 2024
a616334
Fix DashboardPageApiServiceTest
ununhexium Jul 9, 2024
faab3a4
Fix TransferHistoryPageApiServiceTest
ununhexium Jul 9, 2024
08a4cb3
Fix TransferProcessAssetApiServiceTest
ununhexium Jul 9, 2024
7c5c89f
Fix KpiApiTest
ununhexium Jul 9, 2024
2225097
Fix PolicyDefinitionApiServiceTest
ununhexium Jul 9, 2024
cf93fd5
Fix SupportedPolicyApiTest
ununhexium Jul 9, 2024
5a3f8ad
Fix UseCaseApiWrapperTest
ununhexium Jul 9, 2024
f3de9d0
todos
ununhexium Jul 9, 2024
740ee97
todos
ununhexium Jul 9, 2024
1fa2f1d
Limit reason and detail sizes
ununhexium Jul 10, 2024
74c8e6c
await instead of Thread.sleep()
ununhexium Jul 10, 2024
d518de1
Add self/counterparty distinction
ununhexium Jul 10, 2024
de7b573
Remove hardcoded port
ununhexium Jul 10, 2024
e2de51c
Remove hardcoded port
ununhexium Jul 10, 2024
432135a
Update mockito
ununhexium Jul 10, 2024
19b2954
Parallelize 2min -> 35s
ununhexium Jul 10, 2024
9a4b765
Remove hardcoded port
ununhexium Jul 10, 2024
82f6063
Return correct status codes
ununhexium Jul 11, 2024
16d5c29
Add test for data transfer prevention
ununhexium Jul 11, 2024
8ba8bdb
Refactor init
ununhexium Jul 11, 2024
621ec2d
todos
ununhexium Jul 11, 2024
f618d20
Asset multiple contracts
ununhexium Jul 11, 2024
cc9ea8c
Add query by termination status
ununhexium Jul 11, 2024
d7271f4
Remove TestUtils
ununhexium Jul 11, 2024
a9457d6
Add DSL provider in EdcRuntimeExtensionWithTestDatabase
ununhexium Jul 11, 2024
08cfbe8
Clear todos and fix ports allocation
ununhexium Jul 12, 2024
415bdb5
Cleanup
ununhexium Jul 12, 2024
812d620
Full checkstyle
ununhexium Jul 12, 2024
38a9a9c
Add readme
ununhexium Jul 12, 2024
28b7832
Disable test for Gh
ununhexium Jul 12, 2024
6d5f884
Switch to newer test setup model
ununhexium Jul 12, 2024
9dd98a4
Migrate Sovity Messenger Demo to new test style
ununhexium Jul 12, 2024
4a01ffb
New test style for DataSourceParameterizationTest
ununhexium Jul 12, 2024
e23925f
Cleanup
ununhexium Jul 12, 2024
673fa3c
Cleanup
ununhexium Jul 12, 2024
5f359bd
Introducing test Scenario
ununhexium Jul 12, 2024
53597ee
Simplify DataSourceQueryParamsTest
ununhexium Jul 12, 2024
c5194bd
Add e2e test extension
ununhexium Jul 12, 2024
30a0265
Lazy EdcClient construction
ununhexium Jul 12, 2024
0aa3ca0
Cleanup
ununhexium Jul 12, 2024
240f8c9
Cleanup
ununhexium Jul 12, 2024
49dc2f7
Cleanup
ununhexium Jul 15, 2024
5b59c56
Cleanup
ununhexium Jul 15, 2024
342cd01
Cleanup
ununhexium Jul 15, 2024
e436de2
Self code review
ununhexium Jul 15, 2024
5a7b31d
Code review
ununhexium Jul 15, 2024
321ce2d
Fix imports and avoid test on GH
ununhexium Jul 15, 2024
abd0777
Code review 1
ununhexium Jul 16, 2024
f0820ce
Code review 2
ununhexium Jul 17, 2024
4df58e8
Code review 3
ununhexium Jul 17, 2024
5254471
Refactor: force transactions
ununhexium Jul 17, 2024
cc35d71
Rm tmp line
ununhexium Jul 17, 2024
cb505d2
refactor
ununhexium Jul 17, 2024
764f57b
Increase timeout for GH
ununhexium Jul 17, 2024
cbdf262
Code review 4
ununhexium Jul 18, 2024
b4b4b73
docs: fix wording
richardtreier Jul 18, 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: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ please see [changelog_updates.md](docs/dev/changelog_updates.md).

#### Minor Changes

- Added Contract Termination to allow users to stop sharing they data.
ununhexium marked this conversation as resolved.
Show resolved Hide resolved
ununhexium marked this conversation as resolved.
Show resolved Hide resolved

#### Patch Changes

### Deployment Migration Notes
Expand Down
18 changes: 11 additions & 7 deletions docs/api/sovity-edc-api-wrapper.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ paths:
operationId: getContractAgreementPage
requestBody:
content:
'*/*':
application/json:
schema:
$ref: '#/components/schemas/ContractAgreementPageQuery'
responses:
Expand Down Expand Up @@ -524,11 +524,11 @@ components:
DataSourceType:
type: string
description: Supported Data Source Types by UiDataSource
default: CUSTOM
enum:
- HTTP_DATA
- ON_REQUEST
- CUSTOM
default: CUSTOM
SecretValue:
type: object
properties:
Expand Down Expand Up @@ -736,14 +736,14 @@ components:
UiDataSourceHttpDataMethod:
type: string
description: Supported HTTP Methods by UiDataSource
default: GET
enum:
- GET
- POST
- PUT
- PATCH
- DELETE
- OPTIONS
default: GET
UiDataSourceOnRequest:
required:
- contactEmail
Expand Down Expand Up @@ -1788,14 +1788,18 @@ components:
- reason
type: object
properties:
reason:
title: Termination reason
type: string
description: A short reason why this contract was terminated
detail:
title: Termination detail
maxLength: 1000
minLength: 0
type: string
description: A user explanation to detail why the contract was terminated.
reason:
title: Termination reason
maxLength: 100
minLength: 0
type: string
description: A short reason why this contract was terminated
description: Data for terminating a Contract Agreement
AtomicConstraintDto:
required:
Expand Down
47 changes: 47 additions & 0 deletions docs/dev/checkstyle/checkstyle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Checkstyle

## Note about Copyrights
ununhexium marked this conversation as resolved.
Show resolved Hide resolved
ununhexium marked this conversation as resolved.
Show resolved Hide resolved

While it's close to impossible to write a regex to validate all the possible copyright messages, the one currently configured in [checkstyle-config.xml](checkstyle-config.xml) matches almost all the files in this project.

Failing to use this template will make it progressively harder to fix the checkstyle errors as the copyright warnings will accumulate and dilute those errors, wasting precious brain time.

IntelliJ has a feature to help maintain consistent copyright headers in

`Settings > Editor > Copyright > Copyright profiles`.

The copyright below passes the checkstyle when put in a Java multiline comment.

```
Copyright (c) 2024 sovity GmbH

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

SPDX-License-Identifier: Apache-2.0

Contributors:
sovity GmbH - initial API and implementation

```

Which once inserted at the top of a file will look like

```java
/*
* Copyright (c) 2024 sovity GmbH
*
* 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
*
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* sovity GmbH - initial API and implementation
*
*/

package foo.bar;
```
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ dependencies {

testImplementation(libs.assertj.core)
testImplementation(libs.mockito.core)
testImplementation(libs.mockito.inline)
testImplementation(libs.edc.junit)
testImplementation(libs.restAssured.restAssured)
testImplementation(libs.testcontainers.testcontainers)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* sovity GmbH - init
* sovity GmbH - init
*
*/

package de.sovity.edc.ext.catalog.crawler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ dependencies {
testImplementation(project(":utils:test-connector-remote"))
testImplementation(libs.assertj.core)
testImplementation(libs.mockito.core)
testImplementation(libs.mockito.inline)
testImplementation(libs.restAssured.restAssured)
testImplementation(libs.testcontainers.testcontainers)
testImplementation(libs.flyway.core)
Expand Down
41 changes: 41 additions & 0 deletions extensions/contract-termination/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!-- PROJECT LOGO -->
<br />
<div align="center">
<a href="https://github.com/sovity/edc-ce">
<img src="https://raw.githubusercontent.com/sovity/edc-ui/main/src/assets/images/sovity_logo.svg" alt="Logo" width="300">
</a>

<h3 align="center">EDC-Connector Extension:<br />Contract Termination</h3>

<p align="center">
<a href="https://github.com/sovity/edc-ce/issues/new?template=bug_report.md">Report Bug</a>
·
<a href="https://github.com/sovity/edc-ce/issues/new?template=feature_request.md">Request Feature</a>
</p>
</div>


## About this Extension

To allow contracts termination and cancellation while no official specification for this feature is available, we added our own extension, keeping the Core EDC intact.
ununhexium marked this conversation as resolved.
Show resolved Hide resolved

## Why does this extension exist?

Contracts termination is not natively supported the in the EDC. Contracts in general can be terminated and this feature has been added here, waiting for an official implementation to be available.
ununhexium marked this conversation as resolved.
Show resolved Hide resolved

## Details

When a User clicks "Terminate contract" on a contract agreement, a request is sent to the EDC to mark the contract agreement as terminated, followed by a notification and registration of that same termination on the counterpart's side.

The termination is saved in the EDC's database.
Any transfer started from this contract agreement will be rejected.

The contract agreements' implementation doesn't interfere with the existing EDC features besides forcefully preventing transfers that are started on terminated contract agreements.
1
ununhexium marked this conversation as resolved.
Show resolved Hide resolved
ununhexium marked this conversation as resolved.
Show resolved Hide resolved
## License

Apache License 2.0 - see [LICENSE](../../LICENSE)

## Contact

sovity GmbH - [email protected]
60 changes: 60 additions & 0 deletions extensions/contract-termination/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@

plugins {
`java-library`
`maven-publish`
}

dependencies {
annotationProcessor(libs.lombok)
compileOnly(libs.lombok)

implementation(project(":utils:jooq-database-access"))
implementation(project(":extensions:database-direct-access"))
implementation(project(":extensions:sovity-messenger"))

implementation(libs.edc.coreSpi)
implementation(libs.edc.transferSpi)
implementation(libs.edc.dspNegotiationTransform)

implementation(libs.jakarta.rsApi)

testAnnotationProcessor(libs.lombok)
testCompileOnly(libs.lombok)

testImplementation(project(":extensions:postgres-flyway"))
testImplementation(project(":utils:test-connector-remote"))
testImplementation(project(":utils:test-utils"))
testImplementation(project(":utils:versions"))

testImplementation(libs.edc.http) {
exclude(group = "org.eclipse.jetty", module = "jetty-client")
exclude(group = "org.eclipse.jetty", module = "jetty-http")
exclude(group = "org.eclipse.jetty", module = "jetty-io")
exclude(group = "org.eclipse.jetty", module = "jetty-server")
exclude(group = "org.eclipse.jetty", module = "jetty-util")
exclude(group = "org.eclipse.jetty", module = "jetty-webapp")
}

// Updated jetty versions for e.g. CVE-2023-26048
testImplementation(libs.bundles.jetty.cve2023)

testImplementation(libs.assertj.core)
testImplementation(libs.flyway.core)
testImplementation(libs.junit.api)
testImplementation(libs.mockito.core)
testImplementation(libs.restAssured.restAssured)
testImplementation(libs.testcontainers.testcontainers)
testImplementation(libs.testcontainers.postgresql)

testRuntimeOnly(libs.junit.engine)
}

group = libs.versions.sovityEdcExtensionGroup.get()

publishing {
publications {
create<MavenPublication>(project.name) {
from(components["java"])
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright (c) 2024 sovity GmbH
*
* 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
*
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* sovity GmbH - initial API and implementation
*
*/

package de.sovity.edc.extension.contacttermination;

import de.sovity.edc.ext.db.jooq.enums.ContractTerminatedBy;
import lombok.Builder;
import org.eclipse.edc.connector.contract.spi.types.negotiation.ContractNegotiation;
import org.eclipse.edc.connector.contract.spi.types.negotiation.ContractNegotiationStates;

import java.time.OffsetDateTime;

@Builder(toBuilder = true)
public record ContractAgreementTerminationDetails(
String contractAgreementId,
String counterpartyId,
String counterpartyAddress,
ContractNegotiationStates state,
ContractNegotiation.Type type,
String providerAgentId,
String consumerAgentId,
String reason,
String detail,
OffsetDateTime terminatedAt,
ContractTerminatedBy terminatedBy
) {
public boolean isTerminated() {
return terminatedAt != null;
}

boolean isConsumer() {
return type.equals(ContractNegotiation.Type.CONSUMER);
}

boolean isProvider() {
return type.equals(ContractNegotiation.Type.PROVIDER);
}
}
Loading
Loading