-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ci): use E2E tests for BOM smoke tests (#4550)
* feat(ci): use E2E tests for BOM Smoke tests * pr remarks
- Loading branch information
1 parent
8cd7cc2
commit c777edd
Showing
10 changed files
with
231 additions
and
33 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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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,31 @@ | ||
/* | ||
* Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) | ||
* | ||
* 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: | ||
* Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation | ||
* | ||
*/ | ||
|
||
plugins { | ||
java | ||
} | ||
|
||
dependencies { | ||
testImplementation(project(":core:common:junit")) | ||
testImplementation(project(":core:common:lib:boot-lib")) | ||
testImplementation(libs.restAssured) | ||
testImplementation(libs.assertj) | ||
testImplementation(libs.awaitility) | ||
testImplementation(libs.mockserver.netty) | ||
testImplementation(libs.mockserver.client) | ||
} | ||
|
||
edcBuild { | ||
publish.set(false) | ||
} |
164 changes: 164 additions & 0 deletions
164
system-tests/bom-tests/src/test/java/org/eclipse/edc/test/bom/BomSmokeTests.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,164 @@ | ||
/* | ||
* Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) | ||
* | ||
* 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: | ||
* Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation | ||
* | ||
*/ | ||
|
||
package org.eclipse.edc.test.bom; | ||
|
||
import org.eclipse.edc.boot.vault.InMemoryVault; | ||
import org.eclipse.edc.junit.annotations.EndToEndTest; | ||
import org.eclipse.edc.junit.extensions.EmbeddedRuntime; | ||
import org.eclipse.edc.junit.extensions.RuntimeExtension; | ||
import org.eclipse.edc.junit.extensions.RuntimePerMethodExtension; | ||
import org.eclipse.edc.spi.security.Vault; | ||
import org.junit.jupiter.api.AfterAll; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Nested; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
import org.mockserver.integration.ClientAndServer; | ||
|
||
import java.util.Map; | ||
|
||
import static io.restassured.RestAssured.given; | ||
import static org.awaitility.Awaitility.await; | ||
import static org.eclipse.edc.junit.testfixtures.TestUtils.getResourceFileContentAsString; | ||
import static org.eclipse.edc.util.io.Ports.getFreePort; | ||
import static org.hamcrest.Matchers.equalTo; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockserver.model.HttpRequest.request; | ||
import static org.mockserver.model.HttpResponse.response; | ||
import static org.mockserver.stop.Stop.stopQuietly; | ||
|
||
public class BomSmokeTests { | ||
abstract static class SmokeTest { | ||
public static final String DEFAULT_PORT = "8080"; | ||
public static final String DEFAULT_PATH = "/api"; | ||
|
||
@Test | ||
void assertRuntimeReady() { | ||
await().untilAsserted(() -> given() | ||
.baseUri("http://localhost:" + DEFAULT_PORT + DEFAULT_PATH + "/check/startup") | ||
.get() | ||
.then() | ||
.statusCode(200) | ||
.log().ifValidationFails() | ||
.body("isSystemHealthy", equalTo(true))); | ||
|
||
} | ||
} | ||
|
||
@Nested | ||
@EndToEndTest | ||
class ControlPlaneDcp extends SmokeTest { | ||
|
||
@RegisterExtension | ||
protected RuntimeExtension runtime = | ||
new RuntimePerMethodExtension(new EmbeddedRuntime("control-plane-dcp-bom", | ||
Map.of( | ||
"edc.iam.sts.oauth.token.url", "https://sts.com/token", | ||
"edc.iam.sts.oauth.client.id", "test-client", | ||
"edc.iam.sts.oauth.client.secret.alias", "test-alias", | ||
"web.http.port", DEFAULT_PORT, | ||
"web.http.path", DEFAULT_PATH, | ||
"web.http.management.port", "8081", | ||
"web.http.management.path", "/api/management"), | ||
":dist:bom:controlplane-dcp-bom" | ||
)); | ||
} | ||
|
||
@Nested | ||
@EndToEndTest | ||
class ControlPlaneOauth2 extends SmokeTest { | ||
|
||
@RegisterExtension | ||
protected static RuntimeExtension runtime = | ||
new RuntimePerMethodExtension(new EmbeddedRuntime("control-plane-oauth2-bom", | ||
Map.of( | ||
"edc.oauth.token.url", "https://oauth2.com/token", | ||
"edc.oauth.certificate.alias", "test-alias", | ||
"edc.oauth.private.key.alias", "private-test-alias", | ||
"web.http.management.port", "8081", | ||
"web.http.management.path", "/api/management", | ||
"web.http.port", DEFAULT_PORT, | ||
"web.http.path", DEFAULT_PATH, | ||
"edc.oauth.provider.jwks.url", "http://localhost:9999/jwks", | ||
"edc.oauth.client.id", "test-client"), | ||
":dist:bom:controlplane-oauth2-bom" | ||
)); | ||
private static ClientAndServer jwksServer; | ||
|
||
@BeforeAll | ||
static void setup() { | ||
var v = new InMemoryVault(mock()); | ||
v.storeSecret("test-alias", getResourceFileContentAsString("cert.pem")); | ||
runtime.registerServiceMock(Vault.class, v); | ||
|
||
// mock the JWKS server, respond with some arbitrary JWKS | ||
jwksServer = ClientAndServer.startClientAndServer(9999); | ||
jwksServer.when(request().withPath("/jwks").withMethod("GET")) | ||
.respond(response().withStatusCode(200).withBody(getResourceFileContentAsString("jwks_response.json"))); | ||
} | ||
|
||
@AfterAll | ||
static void cleanup() { | ||
stopQuietly(jwksServer); | ||
} | ||
} | ||
|
||
@Nested | ||
@EndToEndTest | ||
public class DataPlaneBase extends SmokeTest { | ||
|
||
private static ClientAndServer server; | ||
@RegisterExtension | ||
protected RuntimeExtension runtime = | ||
new RuntimePerMethodExtension(new EmbeddedRuntime("data-plane-base-bom", | ||
Map.of( | ||
"edc.transfer.proxy.token.verifier.publickey.alias", "test-alias", | ||
"edc.transfer.proxy.token.signer.privatekey.alias", "private-alias", | ||
"edc.dpf.selector.url", "http://localhost:%s/selector".formatted(server.getPort()), | ||
"web.http.control.port", "8081", | ||
"web.http.control.path", "/api/control", | ||
"web.http.port", DEFAULT_PORT, | ||
"web.http.path", DEFAULT_PATH), | ||
":dist:bom:dataplane-base-bom" | ||
)); | ||
|
||
@BeforeAll | ||
static void setup() { | ||
server = ClientAndServer.startClientAndServer(getFreePort()); | ||
server.when(request().withPath("/selector")) | ||
.respond(response().withStatusCode(200)); | ||
} | ||
|
||
@AfterAll | ||
static void afterAll() { | ||
stopQuietly(server); | ||
} | ||
} | ||
|
||
@Nested | ||
@EndToEndTest | ||
class StsFeature extends SmokeTest { | ||
|
||
@RegisterExtension | ||
protected RuntimeExtension runtime = | ||
new RuntimePerMethodExtension(new EmbeddedRuntime("data-plane-base-bom", | ||
Map.of( | ||
"web.http.port", DEFAULT_PORT, | ||
"web.http.path", DEFAULT_PATH, | ||
"edc.api.accounts.key", "password"), | ||
":dist:bom:sts-feature-bom" | ||
)); | ||
} | ||
} |
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,13 @@ | ||
-----BEGIN CERTIFICATE----- | ||
MIIB7DCCAVWgAwIBAgIGAYHYExlWMA0GCSqGSIb3DQEBCwUAMA8xDTALBgNVBAMM | ||
BFRlc3QwHhcNMjIwNzA3MDk1MjE5WhcNMzIwNzA0MDk1MjE5WjAPMQ0wCwYDVQQD | ||
DARUZXN0MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDHggAW6QF9E2N2y37U | ||
xcacS+LFZwyVIFJkd/Zbe4JF0N+qqPGgRO8kMYiXb12geuJ+lxobLQkOlsnztkfX | ||
htVLkYoruSthMQORC/fZDhP1eV5KpR0LVACoQmLJBTbKE2tOJh5HODxvzhiV+Bi5 | ||
DAWOhmkA1dYo1UFg8ORt/YzOvQIDAQABo1MwUTAdBgNVHQ4EFgQUwxs2XndsvlwH | ||
4JqFpqMXF9mEDVAwHwYDVR0jBBgwFoAUwxs2XndsvlwH4JqFpqMXF9mEDVAwDwYD | ||
VR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOBgQCajJWQ7x7TEZvCRXWr3J43 | ||
WFoOZBjhKwDtNySoeF/mJvxEcWzeCfxvqO/zQ16+vMj/+1kW7+eex8dSYBfRtb83 | ||
MjOtKQYd4PU5uH4QqFFyJ3oH72ZItTAikfuRcrV0Gu7lsLSkLjglUFAREr8aI0QC | ||
0SDLUMXw7nNsSJ/s2yIiVw== | ||
-----END CERTIFICATE----- |
20 changes: 20 additions & 0 deletions
20
system-tests/bom-tests/src/test/resources/jwks_response.json
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,20 @@ | ||
{ | ||
"keys": [ | ||
{ | ||
"kty": "RSA", | ||
"kid": "1438289820780", | ||
"use": "sig", | ||
"alg": "RS256", | ||
"n": "idWPro_QiAFOdMsJD163lcDIPogOwXogRo3Pct2MMyeE2GAGqV20Sc8QUbuLDfPl-7Hi9IfFOz--JY6QL5l92eV-GJXkTmidUEooZxIZSp3ghRxLCqlyHeF5LuuM5LPRFDeF4YWFQT_D2eNo_w95g6qYSeOwOwGIfaHa2RMPcQAiM6LX4ot-Z7Po9z0_3ztFa02m3xejEFr2rLRqhFl3FZJaNnwTUk6an6XYsunxMk3Ya3lRaKJReeXeFtfTpShgtPiAl7lIfLJH9h26h2OAlww531DpxHSm1gKXn6bjB0NTC55vJKft4wXoc_0xKZhnWmjQE8d9xE8e1Z3Ll1LYbw", | ||
"e": "AQAB" | ||
}, | ||
{ | ||
"kty": "RSA", | ||
"kid": "1438289856256", | ||
"use": "sig", | ||
"alg": "RS256", | ||
"n": "zo5cKcbFECeiH8eGx2D-DsFSpjSKbTVlXD6uL5JAy9rYIv7eYEP6vrKeX-x1z70yEdvgk9xbf9alc8siDfAz3rLCknqlqL7XGVAQL0ZP63UceDmD60LHOzMrx4eR6p49B3rxFfjvX2SWSV3-1H6XNyLk_ALbG6bGCFGuWBQzPJB4LMKCrOFq-6jtRKOKWBXYgkYkaYs5dG-3e2ULbq-y2RdgxYh464y_-MuxDQfvUgP787XKfcXP_XjJZvyuOEANjVyJYZSOyhHUlSGJapQ8ztHdF-swsnf7YkePJ2eR9fynWV2ZoMaXOdidgZtGTa4R1Z4BgH2C0hKJiqRy9fB7Gw", | ||
"e": "AQAB" | ||
} | ||
] | ||
} |