-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
217 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
val edcVersion: String by project | ||
val edcGroup: String by project | ||
val restAssured: String by project | ||
val mockitoVersion: String by project | ||
val lombokVersion: String by project | ||
val jettyVersion: String by project | ||
val jettyGroup: String by project | ||
|
||
plugins { | ||
`java-library` | ||
`maven-publish` | ||
} | ||
|
||
dependencies { | ||
annotationProcessor("org.projectlombok:lombok:${lombokVersion}") | ||
compileOnly("org.projectlombok:lombok:${lombokVersion}") | ||
|
||
api("${edcGroup}:core-spi:${edcVersion}") | ||
api("${edcGroup}:control-plane-spi:${edcVersion}") | ||
implementation("${edcGroup}:api-core:${edcVersion}") | ||
implementation("${edcGroup}:management-api-configuration:${edcVersion}") | ||
|
||
implementation("jakarta.ws.rs:jakarta.ws.rs-api:3.1.0") | ||
implementation("jakarta.validation:jakarta.validation-api:3.0.2") | ||
|
||
testAnnotationProcessor("org.projectlombok:lombok:${lombokVersion}") | ||
testCompileOnly("org.projectlombok:lombok:${lombokVersion}") | ||
|
||
testImplementation("${edcGroup}:control-plane-core:${edcVersion}") | ||
testImplementation("${edcGroup}:junit:${edcVersion}") | ||
testImplementation("${edcGroup}:http:${edcVersion}") { | ||
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("${jettyGroup}:jetty-client:${jettyVersion}") | ||
testImplementation("${jettyGroup}:jetty-http:${jettyVersion}") | ||
testImplementation("${jettyGroup}:jetty-io:${jettyVersion}") | ||
testImplementation("${jettyGroup}:jetty-server:${jettyVersion}") | ||
testImplementation("${jettyGroup}:jetty-util:${jettyVersion}") | ||
testImplementation("${jettyGroup}:jetty-webapp:${jettyVersion}") | ||
|
||
testImplementation("io.rest-assured:rest-assured:${restAssured}") | ||
testImplementation("${edcGroup}:data-plane-selector-core:${edcVersion}") | ||
testImplementation("org.mockito:mockito-core:${mockitoVersion}") | ||
testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.0") | ||
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.10.0") | ||
} | ||
|
||
val sovityEdcExtensionGroup: String by project | ||
group = sovityEdcExtensionGroup | ||
|
||
publishing { | ||
publications { | ||
create<MavenPublication>(project.name) { | ||
from(components["java"]) | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
extensions/jwks/src/main/java/de/sovity/edc/extension/jwks/JwksController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright (c) 2023 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.jwks; | ||
|
||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.Produces; | ||
import jakarta.ws.rs.core.MediaType; | ||
|
||
@Produces({MediaType.APPLICATION_JSON}) | ||
@Path(JwksController.JWKS_PATH) | ||
public class JwksController { | ||
|
||
public static final String JWKS_PATH = "/jwks"; | ||
|
||
|
||
@GET | ||
@Produces(MediaType.APPLICATION_JSON) | ||
public String getLastCommitInfo() { | ||
return "Hello World"; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
extensions/jwks/src/main/java/de/sovity/edc/extension/jwks/JwksExtension.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright (c) 2023 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.jwks; | ||
|
||
import org.eclipse.edc.connector.api.management.configuration.ManagementApiConfiguration; | ||
import org.eclipse.edc.runtime.metamodel.annotation.Inject; | ||
import org.eclipse.edc.spi.system.ServiceExtension; | ||
import org.eclipse.edc.spi.system.ServiceExtensionContext; | ||
import org.eclipse.edc.web.spi.WebService; | ||
|
||
public class JwksExtension implements ServiceExtension { | ||
|
||
public static final String EXTENSION_NAME = "JwksExtension"; | ||
@Inject | ||
private WebService webService; | ||
|
||
@Override | ||
public String name() { | ||
return EXTENSION_NAME; | ||
} | ||
|
||
@Override | ||
public void initialize(ServiceExtensionContext context) { | ||
var controller = new JwksController(); | ||
webService.registerResource(controller); | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
extensions/jwks/src/test/java/de/sovity/edc/extension/jwks/JwksTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* Copyright (c) 2023 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.jwks; | ||
|
||
|
||
import io.restassured.http.ContentType; | ||
import org.eclipse.edc.connector.dataplane.selector.spi.store.DataPlaneInstanceStore; | ||
import org.eclipse.edc.jsonld.spi.JsonLd; | ||
import org.eclipse.edc.junit.extensions.EdcExtension; | ||
import org.eclipse.edc.spi.protocol.ProtocolWebhook; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
|
||
import java.util.Map; | ||
import java.util.UUID; | ||
|
||
import static io.restassured.RestAssured.given; | ||
import static org.eclipse.edc.junit.testfixtures.TestUtils.getFreePort; | ||
import static org.mockito.Mockito.mock; | ||
|
||
@ExtendWith(EdcExtension.class) | ||
public class JwksTest { | ||
|
||
private static final String AUTH_KEY = UUID.randomUUID().toString(); | ||
private static final int WEB_HTTP_PORT = getFreePort(); | ||
private static final String WEB_HTTP_PATH = "/api"; | ||
|
||
@BeforeEach | ||
void setUp(EdcExtension extension) { | ||
extension.registerServiceMock(ProtocolWebhook.class, mock(ProtocolWebhook.class)); | ||
extension.registerServiceMock(JsonLd.class, mock(JsonLd.class)); | ||
extension.registerServiceMock( | ||
DataPlaneInstanceStore.class, | ||
mock(DataPlaneInstanceStore.class)); | ||
extension.setConfiguration(Map.of( | ||
"web.http.port", String.valueOf(WEB_HTTP_PORT), | ||
"web.http.path", WEB_HTTP_PATH, | ||
"web.http.management.port", String.valueOf(getFreePort()), | ||
"web.http.management.path", "/api/v1/data", | ||
"edc.api.auth.key", AUTH_KEY, | ||
"edc.last.commit.info", "test env commit message", | ||
"edc.build.date", "2023-05-08T15:30:00Z")); | ||
} | ||
|
||
@Test | ||
void jwksSuccessfullyExposed() { | ||
var request = given() | ||
.baseUri("http://localhost:" + WEB_HTTP_PORT) | ||
.basePath(WEB_HTTP_PATH) | ||
.when() | ||
.contentType(ContentType.JSON) | ||
.get(JwksController.JWKS_PATH) | ||
.then() | ||
.statusCode(200) | ||
.contentType(ContentType.JSON); | ||
|
||
// request.assertThat()..body("envLastCommitInfo", equalTo("test env commit message")) | ||
// .body("envBuildDate", equalTo("2023-05-08T15:30:00Z")) | ||
// .body("jarLastCommitInfo", equalTo("test jar commit message")) | ||
// .body("jarBuildDate", equalTo("2023-05-09T15:30:00Z")); | ||
|
||
} | ||
|
||
} |
1 change: 1 addition & 0 deletions
1
...ons/jwks/src/test/resources/META-INF/services/org.eclipse.edc.spi.system.ServiceExtension
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
de.sovity.edc.extension.jwks.JwksExtension |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters