Skip to content

Commit

Permalink
chore: Fix OpenAPI service deployment for e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
andresrosenthal committed Feb 8, 2025
1 parent b1192ec commit 96f4d34
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 6 deletions.
1 change: 0 additions & 1 deletion Docker/xrd-dev-stack/local-dev-exec-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,4 @@ cd "$XROAD_HOME"/src && ./gradlew :security-server:e2e-test:e2eTest --rerun-task
-Pe2eTestCSImage=xrd-centralserver-dev \
-Pe2eTestSSImage=xrd-securityserver-dev \
-Pe2eTestTestCAImage=xrd-testca \
-Pe2eTestISSOAPImage=example-adapter-v2:latest \
$ADDITIONAL_GRADLE_ARGS
3 changes: 3 additions & 0 deletions src/security-server/e2e-test/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ tasks.register<Test>("e2eTest") {
if (project.hasProperty("e2eTestCAImage")) {
systemTestArgs += "-Dtest-automation.custom.cs-image=${project.property("e2eTestCAImage")}"
}
if (project.hasProperty("e2eTestISOPENAPIImage")) {
systemTestArgs += "-Dtest-automation.custom.isopenapi-image=${project.property("e2eTestISOPENAPIImage")}"
}
if (project.hasProperty("e2eTestISSOAPImage")) {
systemTestArgs += "-Dtest-automation.custom.issoap-image=${project.property("e2eTestISSOAPImage")}"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@ public class CustomProperties {
private String csImage;
private String ssImage;
private String caImage;
private String isopenapiImage;
private String issoapImage;
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public void initialize() {
.withEnv("CS_IMG", customProperties.getCsImage())
.withEnv("SS_IMG", customProperties.getSsImage())
.withEnv("CA_IMG", customProperties.getCaImage())
.withEnv("IS_OPENAPI_IMG", customProperties.getIsopenapiImage())
.withEnv("IS_SOAP_IMG", customProperties.getIssoapImage())
.withLogConsumer(HURL, createLogConsumer(HURL))
.withLogConsumer(CS, createLogConsumer(CS))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ public void requestSoapIsSentToProxy(String targetProxy, DocString docString) {
.then();
}

@Step("response is sent of http status code {int} and body path {string} is equal to {string}")
@Step("response is received with http status code {int} and body path {string} is equal to {string}")
public void responseValidated(int httpStatus, String path, String value) {
response.assertThat()
.statusCode(httpStatus)
.body(path, equalTo(value));
}

@Step("response is sent of http status code {int} and body path {string} is not empty")
@Step("response is received with http status code {int} and body path {string} is not empty")
public void responseValidated(int httpStatus, String path) {
response.assertThat()
.statusCode(httpStatus)
Expand All @@ -88,5 +88,16 @@ public void requestRestIsSentToProxy(String targetProxy, DocString docString) {
.then();
}

@Step("REST request targeted at {string} API endpoint is sent to {string} proxy")
public void requestOpenapiRestIsSentToProxy(String apiEndpoint, String targetProxy) {
var mapping = envSetup.getContainerMapping(targetProxy, Port.PROXY);

response = given()
.header(HttpHeaders.CONTENT_TYPE, "application/json")
.header(HEADER_CLIENT_ID, "DEV/COM/4321/TestClient")
.get("http://%s:%s/r1/DEV/COM/1234/TestService/restapi/%s"
.formatted(mapping.host(), mapping.port(), apiEndpoint.replaceFirst("^/", "")))
.then();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ test-automation:
cs-image: "ghcr.io/nordic-institute/xrddev-central-server:latest"
ss-image: "ghcr.io/nordic-institute/xrddev-security-server:latest"
ca-image: "ghcr.io/nordic-institute/xrddev-testca:latest"
isopenapi-image: "ghcr.io/nordic-institute/xrddev-example-restapi:latest"
issoap-image: "niis/example-adapter:latest"
use-custom-env: false
custom-env-mapping: # original : custom
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,16 @@ Feature: 0100 - SS: Proxy
</soapenv:Body>
</soapenv:Envelope>
"""
Then response is sent of http status code 200 and body path "Envelope.Body" is not empty
Then response is received with http status code 200 and body path "Envelope.Body" is not empty


Scenario: REST request is successful transferred over X-Road proxy
Scenario: REST request is successfully transferred over X-Road proxy
When REST request is sent to "ss1" proxy
"""json
{"data": 1.0, "service": "random"}
"""
Then response is sent of http status code 200 and body path "message" is equal to "Hello, world from POST service!"
Then response is received with http status code 200 and body path "message" is equal to "Hello, world from POST service!"

Scenario: REST request with valid API path permission is successfully transferred over X-Road proxy
When REST request targeted at "/api/members" API endpoint is sent to "ss1" proxy
Then response is received with http status code 200 and body path "[0].name" is equal to "MTÜ Nordic Institute for Interoperability Solutions"

0 comments on commit 96f4d34

Please sign in to comment.