Skip to content

Commit

Permalink
refactor: extract wrapper-api, fix endpoint names (#555):
Browse files Browse the repository at this point in the history
- Fixed Wrapper Folder Structure: 
  - `wrapper` was split into `wrapper` and `wrapper-api` for faster build times when the API is unchanged / while coding tests
  - This solved a dependency problem, so all tests for `wrapper` could be moved from `client` back to `wrapper`.
  - Replaced remaining tests using Rest Assured to use the Java API Client Library.
- Cleaned up UiResource and UseCaseResource, streamlined names and method order.
- Fixed Markdown Link Checker to resolve absolute links in the current branch
  • Loading branch information
richardtreier authored Oct 4, 2023
1 parent 1423ad0 commit dbf85ff
Show file tree
Hide file tree
Showing 154 changed files with 894 additions and 884 deletions.
21 changes: 21 additions & 0 deletions .github/markdown-link-checker-config.jq
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env -S jq -nf
{
"ignorePatterns": [
{"pattern": "^https?://localhost"},
{"pattern": "^https?://example"},
{"pattern": "^https://checkstyle\\.sourceforge\\.io"},
{"pattern": "^https://www\\.linkedin\\.com"},
{"pattern": "https://(.*?)\\.azure\\.sovity\\.io"},
{"pattern": "http://edc2?:"}
],
"replacementPatterns": [
{
"pattern": "^https://github.com/sovity/edc-extensions/blob/main/",
"replacement": "https://github.com/sovity/edc-extensions/blob/\(env | .CI_SHA // ("CI_SHA was null" | halt_error))/"
},
{
"pattern": "^https://github.com/sovity/edc-extensions/tree/main/",
"replacement": "https://github.com/sovity/edc-extensions/tree/\(env | .CI_SHA // ("CI_SHA was null" | halt_error))/"
}
]
}
10 changes: 0 additions & 10 deletions .github/markdown-link-checker-config.json

This file was deleted.

11 changes: 7 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,15 @@ jobs:
with:
node-version: '16'
cache: 'npm'
cache-dependency-path: extensions/wrapper/client-ts/package.json
cache-dependency-path: extensions/wrapper/clients/typescript-client/package.json
- name: "Gradle: Validate Gradle Wrapper"
uses: gradle/wrapper-validation-action@ccb4328a959376b642e027874838f60f8e596de3
- name: "Gradle: Generate TS Code"
uses: gradle/gradle-build-action@a4cf152f482c7ca97ef56ead29bf08bcd953284c
with:
arguments: :extensions:wrapper:wrapper:build -x test
- name: "NPM: Dist Tag & Version"
working-directory: ./extensions/wrapper/client-ts
working-directory: ./extensions/wrapper/clients/typescript-client
run: |
if [ "${{ startsWith(github.ref, 'refs/tags/') }}" == "true" ]; then
# Full Release
Expand All @@ -170,11 +170,11 @@ jobs:
npm version $VERSION
echo "DIST_TAG=$DIST_TAG" >> $GITHUB_ENV
- name: "NPM: Build"
working-directory: extensions/wrapper/client-ts
working-directory: extensions/wrapper/clients/typescript-client
run: npm ci && npm run build
- name: "NPM: Publish (Main & Releases Only)"
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/releases/') }}
working-directory: extensions/wrapper/client-ts
working-directory: extensions/wrapper/clients/typescript-client
run: |
npm set //registry.npmjs.org/:_authToken $NODE_AUTH_TOKEN
npm set //registry.npmjs.org/:username $NODE_USER
Expand All @@ -186,7 +186,10 @@ jobs:
name: Markdown Link Checks
runs-on: ubuntu-latest
steps:
- uses: FranzDiebold/github-env-vars-action@v2
- uses: actions/checkout@master
- name: "Markdown Link Checker: Generate Config"
run: .github/markdown-link-checker-config.jq > .github/markdown-link-checker-config.json
- name: "Markdown Link Checker: Validate Links"
uses: gaurav-nelson/github-action-markdown-link-check@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ https://img.shields.io/github/issues/sovity/edc-extensions.svg?style=for-the-bad
[license-shield]:
https://img.shields.io/github/license/sovity/edc-extensions.svg?style=for-the-badge

[license-url]: https://github.com/sovity/edc-extensions/blob/master/LICENSE
[license-url]: https://github.com/sovity/edc-extensions/blob/main/LICENSE

[linkedin-shield]:
https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge&logo=linkedin&colorB=555
Expand Down
14 changes: 7 additions & 7 deletions SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@
## Extensions

* [API Wrapper](./extensions/wrapper/README.md)
* [API Commons Endpoint](./extensions/wrapper/wrapper-common-api/README.md)
* [API EE Endpoint](./extensions/wrapper/wrapper-ee-api/README.md)
* [Java Implementation](./extensions/wrapper/client/README.md)
* [Java Example](./extensions/wrapper/client-example/README.md)
* [TypeScript Implementation](./extensions/wrapper/client-ts/README.md)
* [TypeScript Example](./extensions/wrapper/client-ts-example/README.md)
* [Policies]()
* [Community Edition API](./extensions/wrapper/wrapper-api/README.md)
* [Enterprise Edition API](./extensions/wrapper/wrapper-ee-api/README.md)
* [Java API Client Library](./extensions/wrapper/clients/java-client/README.md)
* [Java API Client Library Example](./extensions/wrapper/clients/java-client-example/README.md)
* [TypeScript API Client Library](./extensions/wrapper/clients/typescript-client/README.md)
* [TypeScript API Client Library Example](./extensions/wrapper/clients/typescript-client-example/README.md)
* Policies
* [Always True](./extensions/policy-always-true/README.md)
* [Referring Connector](./extensions/policy-referring-connector/README.md)
* [Time Interval](./extensions/policy-time-interval/README.md)
Expand Down
4 changes: 2 additions & 2 deletions docker-compose-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ services:
MY_EDC_PROTOCOL: "http://"
EDC_DSP_CALLBACK_ADDRESS: http://edc:11003/api/dsp
EDC_WEB_REST_CORS_ENABLED: 'true'
EDC_WEB_REST_CORS_HEADERS: 'origin,content-type,accept,authorization,x-api-key'
EDC_WEB_REST_CORS_HEADERS: 'origin,content-type,accept,authorization,X-Api-Key'
EDC_WEB_REST_CORS_ORIGINS: '*'
ports:
- '11001:11001'
Expand Down Expand Up @@ -79,7 +79,7 @@ services:
MY_EDC_PROTOCOL: "http://"
EDC_DSP_CALLBACK_ADDRESS: http://edc2:11003/api/dsp
EDC_WEB_REST_CORS_ENABLED: 'true'
EDC_WEB_REST_CORS_HEADERS: 'origin,content-type,accept,authorization,x-api-key'
EDC_WEB_REST_CORS_HEADERS: 'origin,content-type,accept,authorization,X-Api-Key'
EDC_WEB_REST_CORS_ORIGINS: '*'
ports:
- '22001:11001'
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ services:
MY_EDC_PROTOCOL: "http://"
MY_EDC_IDS_BASE_URL: "http://edc:11003"
EDC_WEB_REST_CORS_ENABLED: 'true'
EDC_WEB_REST_CORS_HEADERS: 'origin,content-type,accept,authorization,x-api-key'
EDC_WEB_REST_CORS_HEADERS: 'origin,content-type,accept,authorization,X-Api-Key'
EDC_WEB_REST_CORS_ORIGINS: '*'
ports:
- '11001:11001'
Expand Down Expand Up @@ -81,7 +81,7 @@ services:
MY_EDC_PROTOCOL: "http://"
MY_EDC_IDS_BASE_URL: "http://edc2:11003"
EDC_WEB_REST_CORS_ENABLED: 'true'
EDC_WEB_REST_CORS_HEADERS: 'origin,content-type,accept,authorization,x-api-key'
EDC_WEB_REST_CORS_HEADERS: 'origin,content-type,accept,authorization,X-Api-Key'
EDC_WEB_REST_CORS_ORIGINS: '*'
ports:
- '22001:11001'
Expand Down
2 changes: 1 addition & 1 deletion docs/dev/checkstyle/checkstyle-config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<property name="severity" value="warning"/>
<property name="fileExtensions" value="java"/>
<property name="header"
value="^/\*$\n^ \* Copyright \(c\) 20\d\d((,| -) 20\d{2})? [A-Za-z].+\S$\n^ \*$\n^ \* This program and the accompanying materials are made available under the$\n^ \* terms of the Apache License, Version 2\.0 which is available at$\n^ \* https://www\.apache\.org/licenses/LICENSE-2\.0$\n^ \*$\n^ \* SPDX-License-Identifier: Apache-2\.0$\n^ \*$\n^ \* Contributors:$\n^ \* \S.*\S$\n^ \*$\n^ \*/$\n^$\n^package"/>
value="^/\*$\n^ \* ?Copyright \(c\) 20\d\d((,| -) 20\d{2})? [A-Za-z].+\S$\n^ \*$\n^ \* This program and the accompanying materials are made available under the$\n^ \* terms of the Apache License, Version 2\.0 which is available at$\n^ \* https://www\.apache\.org/licenses/LICENSE-2\.0$\n^ \*$\n^ \* SPDX-License-Identifier: Apache-2\.0$\n^ \*$\n^ \* Contributors:$\n^ \* \S.*\S$\n^ \*$\n^ \*/$\n^$\n^package"/>
<property name="multiLines" value="11"/>
</module>

Expand Down
4 changes: 2 additions & 2 deletions docs/getting-started/documentation/api_wrapper.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ Add the Java Client Library to your Maven/Gradle project: https://github.com/sov

Configuring The Client
========
- Configure the Client with either an API Key or OAuth2 Client Credentials: https://github.com/sovity/edc-extensions/tree/main/extensions/wrapper/client#usage
- Configure the Client with either an API Key or OAuth2 Client Credentials: https://github.com/sovity/edc-extensions/tree/main/extensions/wrapper/clients/java-client#usage
- Your management API URL should look like https://your-connector-name.prod-sovity.azure.sovity.io/control/data

Using The Client
========
Feel free to use the endpoints of the aforementioned API groups.
Example Usage of a Use Case API Endpoint:
```java
KpiResult kpiResult = client.useCaseApi().kpiEndpoint();
KpiResult kpiResult = client.useCaseApi().getKpis();
```
4 changes: 2 additions & 2 deletions docs/postman_collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@
"apikey": [
{
"key": "key",
"value": "x-api-key",
"value": "X-Api-Key",
"type": "string"
},
{
Expand Down Expand Up @@ -934,4 +934,4 @@
"type": "default"
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ static ValidatableResponse mockRequest() {
return given()
.baseUri("http://localhost:" + DATA_PORT)
.basePath("/api/v1/data")
.header("x-api-key", API_KEY)
.header("X-Api-Key", API_KEY)
.when()
.contentType(ContentType.TEXT)
.get("/edc-ui-config")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void testEnvAndJar() {
var request = given()
.baseUri("http://localhost:" + TestUtils.DATA_PORT)
.basePath("/api/v1/data")
.header("x-api-key", TestUtils.AUTH_KEY)
.header("X-Api-Key", TestUtils.AUTH_KEY)
.when()
.contentType(ContentType.JSON)
.get("/last-commit-info")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import org.eclipse.edc.spi.agent.ParticipantAgent;
import org.eclipse.edc.spi.protocol.ProtocolWebhook;
import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
Expand All @@ -33,6 +32,7 @@

import static de.sovity.edc.extension.policy.AlwaysTruePolicyConstants.POLICY_DEFINITION_ID;
import static java.util.Objects.requireNonNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;

@ApiTest
Expand Down Expand Up @@ -61,7 +61,7 @@ void alwaysTruePolicyDef(PolicyEngine policyEngine,
);

// assert
Assertions.assertTrue(result.succeeded(), "Always True Policy wasn't true.");
assertTrue(result.succeeded(), "Always True Policy wasn't true.");
}

@NotNull
Expand All @@ -75,4 +75,4 @@ private PolicyDefinition alwaysTruePolicy(PolicyDefinitionService policyDefiniti
private ParticipantAgent participantAgent() {
return new ParticipantAgent(Map.of(), Map.of());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.eclipse.edc.policy.model.Operator;
import org.eclipse.edc.spi.agent.ParticipantAgent;
import org.eclipse.edc.spi.monitor.Monitor;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
Expand All @@ -38,6 +37,9 @@
import java.util.Collections;
import java.util.List;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

class AbstractReferringConnectorValidationTest {

private AbstractReferringConnectorValidation validation;
Expand Down Expand Up @@ -71,7 +73,7 @@ void testFailsOnUnsupportedOperations(Operator operator) {
prepareReferringConnectorClaim("http://example.org");

// invoke & assert
Assertions.assertFalse(validation.evaluate(operator, "foo", policyContext));
assertFalse(validation.evaluate(operator, "foo", policyContext));
}

@Test
Expand All @@ -82,7 +84,7 @@ void testFailsOnUnsupportedRightValue() {
prepareReferringConnectorClaim("http://example.org");

// invoke & assert
Assertions.assertFalse(validation.evaluate(Operator.EQ, 1, policyContext));
assertFalse(validation.evaluate(Operator.EQ, 1, policyContext));
}

@Test
Expand All @@ -95,7 +97,7 @@ void testValidationFailsWhenClaimMissing() {
final boolean isValid = validation.evaluate(Operator.EQ, "http://example.org", policyContext);

// assert
Assertions.assertFalse(isValid);
assertFalse(isValid);
}

@Test
Expand All @@ -113,8 +115,8 @@ void testValidationWhenClaimContainsValue() {
final boolean isContainedTrue = validation.evaluate(Operator.EQ, "http://example.org", policyContext);

// assert
Assertions.assertTrue(isEqualsTrue);
Assertions.assertFalse(isContainedTrue);
assertTrue(isEqualsTrue);
assertFalse(isContainedTrue);
}

@Test
Expand All @@ -132,8 +134,8 @@ void testValidationWhenClaimContainsValueAsCommaList() {
final boolean isContainedTrue = validation.evaluate(Operator.EQ, "http://example.org", policyContext);

// assert
Assertions.assertTrue(isEqualsTrue);
Assertions.assertFalse(isContainedTrue);
assertTrue(isEqualsTrue);
assertFalse(isContainedTrue);
}

@Test
Expand All @@ -147,7 +149,7 @@ void testValidationWhenParticipantHasProblems() {
final boolean isValid = validation.evaluate(Operator.EQ, "http://example.org", policyContext);

// Mockito.verify(monitor.debug(Mockito.anyString());
Assertions.assertFalse(isValid);
assertFalse(isValid);
}

@Test
Expand All @@ -161,7 +163,7 @@ void testValidationWhenSingleParticipantIsValid() {
final boolean isContainedTrue = validation.evaluate(Operator.EQ, "http://example.org", policyContext);

// Mockito.verify(monitor.debug(Mockito.anyString());
Assertions.assertTrue(isContainedTrue);
assertTrue(isContainedTrue);
}

@Test
Expand All @@ -171,9 +173,9 @@ void testValidationForMultipleParticipants() {
prepareReferringConnectorClaim("http://example.org");

// invoke & verify
Assertions.assertTrue(validation.evaluate(Operator.IN, List.of("http://example.org", "http://example.com"), policyContext));
Assertions.assertTrue(validation.evaluate(Operator.IN, List.of(1, "http://example.org"), policyContext));
Assertions.assertTrue(validation.evaluate(Operator.IN, List.of("http://example.org", "http://example.org"), policyContext));
assertTrue(validation.evaluate(Operator.IN, List.of("http://example.org", "http://example.com"), policyContext));
assertTrue(validation.evaluate(Operator.IN, List.of(1, "http://example.org"), policyContext));
assertTrue(validation.evaluate(Operator.IN, List.of("http://example.org", "http://example.org"), policyContext));
}

private void prepareContextProblems(List<String> problems) {
Expand Down
27 changes: 16 additions & 11 deletions extensions/wrapper/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,23 @@

## About this Extension

This extension contains multiple APIs designed for auto-generation of API Clients to speed up development process. It
contains multiple components:

- APIs for
- EDC UI
- Use Cases
- Further APIs
- An [EDC Extension](./wrapper) serving the implementations
- Auto generated
- [Java API Client](./client)
- [TypeScript API Client](./client-ts)
To provide type-safe JSON APIs for both our Connector UI and Use Case Applications,
we provide an API Wrapper around the Connector over the JSON-LD Management API of the EDC Connector.

These APIs are more opinionated and use-case tailored.

This module contains:

- API Definitions:
- [sovity Community Edition EDC API](./wrapper-api)
- [sovity Enterprise Edition EDC API](./wrapper-ee-api)
- [Broker / Connector Common API](./wrapper-common-api)
- API Client Libraries:
- [Java API Client](./clients/java-client)
- [TypeScript API Client](./clients/typescript-client)
- more to come
- An [EDC Extension](./wrapper) serving the implementations for the sovity Community Edition API.
- [Broker / Connector Common Services](./wrapper-common-mappers)

## Why does this extension exist?

Expand Down
Loading

0 comments on commit dbf85ff

Please sign in to comment.