Skip to content

Commit 467fe79

Browse files
committed
feat: e2e test suite for ega-dev env
1 parent ec75e37 commit 467fe79

21 files changed

+702
-167
lines changed

e2eTests/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ dependencies {
2525
testImplementation("org.skyscreamer:jsonassert:1.5.3")
2626
testCompileOnly("org.projectlombok:lombok:1.18.40")
2727
testAnnotationProcessor("org.projectlombok:lombok:1.18.40")
28+
implementation("org.bouncycastle:bcprov-jdk18on:1.82")
29+
implementation("org.bouncycastle:bcpkix-jdk18on:1.82")
2830
}
2931

3032
// Start setup scripts.

e2eTests/docker-compose.template.yml

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -644,8 +644,8 @@ services:
644644
container_name: e2e-tests
645645
hostname: e2e_tests
646646
build:
647-
context: .
648-
dockerfile: e2e-tests.Dockerfile
647+
context: ..
648+
dockerfile: e2eTests/e2e-tests.Dockerfile
649649
depends_on:
650650
proxy:
651651
condition: service_healthy
@@ -660,7 +660,27 @@ services:
660660
file-orchestrator:
661661
condition: service_healthy
662662
environment:
663-
- INTEGRATION=FEGA
663+
- E2E_TESTS_RUNTIME=<<E2E_TESTS_RUNTIME>>
664+
- E2E_TESTS_INTEGRATION=<<E2E_TESTS_INTEGRATION>>
665+
- E2E_TESTS_PROXY_HOST=<<E2E_TESTS_PROXY_HOST>>
666+
- E2E_TESTS_PROXY_PORT=<<E2E_TESTS_PROXY_PORT>>
667+
- E2E_TESTS_SDA_DOA_HOST=<<E2E_TESTS_SDA_DOA_HOST>>
668+
- E2E_TESTS_SDA_DOA_PORT=<<E2E_TESTS_SDA_DOA_PORT>>
669+
- E2E_TESTS_CEGAMQ_CONN_STR=<<E2E_TESTS_CEGAMQ_CONN_STR>>
670+
- E2E_TESTS_CEGAAUTH_USERNAME=<<E2E_TESTS_CEGAAUTH_USERNAME>>
671+
- E2E_TESTS_CEGAAUTH_PASSWORD=<<E2E_TESTS_CEGAAUTH_PASSWORD>>
672+
- E2E_TESTS_SDA_DB_HOST=<<E2E_TESTS_SDA_DB_HOST>>
673+
- E2E_TESTS_SDA_DB_PORT=<<E2E_TESTS_SDA_DB_PORT>>
674+
- E2E_TESTS_SDA_DB_USERNAME=<<E2E_TESTS_SDA_DB_USERNAME>>
675+
- E2E_TESTS_SDA_DB_PASSWORD=<<E2E_TESTS_SDA_DB_PASSWORD>>
676+
- E2E_TESTS_SDA_DB_DATABASE_NAME=<<E2E_TESTS_SDA_DB_DATABASE_NAME>>
677+
- E2E_TESTS_TRUSTSTORE_PASSWORD=<<E2E_TESTS_TRUSTSTORE_PASSWORD>>
678+
- E2E_TESTS_PROXY_TOKEN_AUDIENCE=<<E2E_TESTS_PROXY_TOKEN_AUDIENCE>>
679+
- E2E_TESTS_PROXY_ADMIN_USERNAME=<<E2E_TESTS_PROXY_ADMIN_USERNAME>>
680+
- E2E_TESTS_PROXY_ADMIN_PASSWORD=<<E2E_TESTS_PROXY_ADMIN_PASSWORD>>
681+
# - E2E_TESTS_EGA_DEV_BASE_DIRECTORY=<<E2E_TESTS_EGA_DEV_BASE_DIRECTORY>>
682+
# - E2E_TESTS_EGA_DEV_PUBLIC_KEY_FILENAME=<<E2E_TESTS_EGA_DEV_PUBLIC_KEY_FILENAME>>
683+
# - E2E_TESTS_LSAAI_TOKEN=<<E2E_TESTS_LSAAI_TOKEN>>
664684
volumes:
665685
- storage:/storage
666686

e2eTests/e2e-tests.Dockerfile

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,30 @@
11
# Use Temurin 21 as the base image for Java 21
2-
FROM eclipse-temurin:21-jdk-alpine
2+
FROM eclipse-temurin:21-jdk-alpine AS builder
3+
4+
WORKDIR /app
5+
6+
COPY build.gradle.kts settings.gradle.kts gradlew ./
7+
COPY gradle/ ./gradle/
8+
COPY buildSrc ./buildSrc
9+
COPY lib/crypt4gh ./lib/crypt4gh
10+
COPY e2eTests/ ./e2eTests
11+
12+
RUN ./gradlew :lib:crypt4gh:build :e2eTests:jar --no-daemon
13+
14+
FROM eclipse-temurin:21-jre-alpine
315

416
# Install bash
517
RUN apk add --no-cache bash
618

719
# Set the working directory in the container
820
WORKDIR /fega-norway
921

10-
# Copy the application JAR and scripts
11-
COPY /build/libs/e2eTests.jar /fega-norway/e2eTests.jar
12-
COPY env.sh /fega-norway/env.sh
13-
COPY entrypoint.sh /entrypoint.sh
22+
# Copy the application JAR, env, and scripts
23+
COPY --from=builder /app/e2eTests/build/libs/e2eTests.jar /fega-norway/e2eTests.jar
24+
COPY --from=builder /app/e2eTests/entrypoint.sh /fega-norway/entrypoint.sh
1425

1526
# Make entrypoint executable
16-
RUN chmod +x /entrypoint.sh
27+
RUN chmod +x /fega-norway/entrypoint.sh
1728

1829
# Run the entrypoint using bash
19-
CMD ["/bin/bash", "/entrypoint.sh"]
30+
CMD ["/bin/bash", "/fega-norway/entrypoint.sh"]

e2eTests/entrypoint.sh

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,26 @@ if [ -f "/storage/certs/rootCA.pem" ]; then
1010
-noprompt \
1111
-storepass changeit
1212
else
13-
echo "Warning: /storage/certs/rootCA.pem not found, skipping certificate import."
13+
echo "Info: /storage/certs/rootCA.pem not found, skipping certificate import."
1414
fi
1515

16-
# Choose which test to run based on the INTEGRATION variable.
16+
# NB! Must be present in the environment.
17+
#
18+
# Choose which test to run based on the E2E_TESTS_INTEGRATION variable.
1719
# If set to "FEGA", run no.elixir.e2eTests.FEGAIntegrationTest.
1820
# Otherwise, run no.elixir.e2eTests.GDIIntegrationTest.
1921
# See the top-level classes in no.elixir.e2eTests for details.
20-
if [ "$INTEGRATION" = "FEGA" ]; then
22+
if [ "$E2E_TESTS_INTEGRATION" = "FEGA" ]; then
2123
echo "Running FEGA integration tests"
2224
exec java -jar e2eTests.jar --select-class no.elixir.e2eTests.FEGAIntegrationTest
23-
elif [ "$INTEGRATION" = "GDI" ]; then
25+
elif [ "$E2E_TESTS_INTEGRATION" = "GDI" ]; then
2426
echo "Running GDI integration tests"
2527
exec java -jar e2eTests.jar --select-class no.elixir.e2eTests.GDIIntegrationTest
28+
elif [ "$E2E_TESTS_INTEGRATION" = "EGA_DEV" ]; then
29+
echo "Running EGA_DEV integration tests"
30+
exec java -jar e2eTests.jar --select-class no.elixir.e2eTests.EgaDevIntegrationTest
2631
else
27-
echo "Error: Unknown or unset INTEGRATION value: $INTEGRATION"
28-
echo "Please set INTEGRATION=FEGA or INTEGRATION=GDI"
32+
echo "Error: Unknown or unset E2E_TESTS_INTEGRATION value: $E2E_TESTS_INTEGRATION"
33+
echo "Please set E2E_TESTS_INTEGRATION=FEGA or E2E_TESTS_INTEGRATION=GDI or E2E_TESTS_INTEGRATION=EGA_DEV"
2934
exit 1
3035
fi

e2eTests/env.sh

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -200,38 +200,48 @@ export HEARTBEAT_REDIS_DB=0
200200

201201
# E2E Test
202202
# ---------------------------------------------------------------------------
203+
203204
# Determines the runtime mode for the E2E tests.
204205
# If set to "container", the entire test runs inside a Docker container.
205206
# If set to "local", you can run the test using: `./gradlew :e2eTests:test`.
206207
# Mainly used to switch the host/ports and file systems to fetch the certificates.
207-
export E2E_RUNTIME=container
208+
export E2E_TESTS_RUNTIME=container
209+
210+
# Determines which integration should be run.
211+
# Either FEGA or GDI or EGA_DEV
212+
export E2E_TESTS_INTEGRATION=FEGA
208213

209214
# Helper function to choose value based on runtime
210215
function _runtime_() {
211216
local container_value=$1
212217
local local_value=$2
213218

214-
if [ "$E2E_RUNTIME" = "container" ]; then
219+
if [ "$E2E_TESTS_RUNTIME" = "container" ]; then
215220
echo "$container_value"
216221
else
217222
echo "$local_value"
218223
fi
219224
}
220225

221226
# Use the function for environment variable assignments
222-
export E2E_PROXY_HOST=$(_runtime_ "proxy" "localhost")
223-
export E2E_PROXY_PORT=$(_runtime_ "8080" "10443")
224-
export E2E_SDA_DOA_HOST=$(_runtime_ "doa" "localhost")
225-
export E2E_SDA_DOA_PORT=$(_runtime_ "8080" "80")
226-
export E2E_CEGAMQ_CONN_STR="amqps://$CEGAMQ_USERNAME:$CEGAMQ_PASSWORD@$(_runtime_ $CEGAMQ_HOST "localhost"):$CEGAMQ_PORT/$CEGAMQ_VHOST"
227-
export E2E_CEGAAUTH_USERNAME=$CEGAAUTH_CEGA_USERS_USER
228-
export E2E_CEGAAUTH_PASSWORD=$CEGAAUTH_CEGA_USERS_PASSWORD
229-
export E2E_SDA_DB_HOST=$(_runtime_ "$DB_HOST" "localhost")
230-
export E2E_SDA_DB_PORT=$DB_PORT
231-
export E2E_SDA_DB_USERNAME=$DB_POSTGRES_USER
232-
export E2E_SDA_DB_PASSWORD=$DB_POSTGRES_PASSWORD
233-
export E2E_SDA_DB_DATABASE_NAME=$DB_POSTGRES_DB
234-
export E2E_TRUSTSTORE_PASSWORD=$KEYTOOL_TRUSTSTORE_PASSWORD
235-
export E2E_PROXY_TOKEN_AUDIENCE=$PROXY_TOKEN_AUDIENCE
236-
export E2E_PROXY_ADMIN_USERNAME=$PROXY_ADMIN_USER
237-
export E2E_PROXY_ADMIN_PASSWORD=$PROXY_ADMIN_PASSWORD
227+
export E2E_TESTS_PROXY_HOST=$(_runtime_ "proxy" "localhost")
228+
export E2E_TESTS_PROXY_PORT=$(_runtime_ "8080" "10443")
229+
export E2E_TESTS_SDA_DOA_HOST=$(_runtime_ "doa" "localhost")
230+
export E2E_TESTS_SDA_DOA_PORT=$(_runtime_ "8080" "80")
231+
export E2E_TESTS_CEGAMQ_CONN_STR="amqps://$CEGAMQ_USERNAME:$CEGAMQ_PASSWORD@$(_runtime_ $CEGAMQ_HOST "localhost"):$CEGAMQ_PORT/$CEGAMQ_VHOST"
232+
export E2E_TESTS_CEGAAUTH_USERNAME=$CEGAAUTH_CEGA_USERS_USER
233+
export E2E_TESTS_CEGAAUTH_PASSWORD=$CEGAAUTH_CEGA_USERS_PASSWORD
234+
export E2E_TESTS_SDA_DB_HOST=$(_runtime_ "$DB_HOST" "localhost")
235+
export E2E_TESTS_SDA_DB_PORT=$DB_PORT
236+
export E2E_TESTS_SDA_DB_USERNAME=$DB_POSTGRES_USER
237+
export E2E_TESTS_SDA_DB_PASSWORD=$DB_POSTGRES_PASSWORD
238+
export E2E_TESTS_SDA_DB_DATABASE_NAME=$DB_POSTGRES_DB
239+
export E2E_TESTS_TRUSTSTORE_PASSWORD=$KEYTOOL_TRUSTSTORE_PASSWORD
240+
export E2E_TESTS_PROXY_TOKEN_AUDIENCE=$PROXY_TOKEN_AUDIENCE
241+
export E2E_TESTS_PROXY_ADMIN_USERNAME=$PROXY_ADMIN_USER
242+
export E2E_TESTS_PROXY_ADMIN_PASSWORD=$PROXY_ADMIN_PASSWORD
243+
244+
# New configs introduced for EGA DEV testing
245+
# export E2E_TESTS_EGA_DEV_BASE_DIRECTORY=
246+
# export E2E_TESTS_EGA_DEV_PUBLIC_KEY_FILENAME=
247+
# export E2E_TESTS_LSAAI_TOKEN=
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package no.elixir.e2eTests;
2+
3+
import no.elixir.e2eTests.core.BaseE2ETest;
4+
import no.elixir.e2eTests.features.*;
5+
import no.elixir.e2eTests.utils.CommonUtils;
6+
import org.junit.jupiter.api.*;
7+
8+
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
9+
public class EgaDevIntegrationTest {
10+
11+
@BeforeAll
12+
static void setup() throws Exception {
13+
BaseE2ETest.setupEgaDevTestEnvironment();
14+
}
15+
16+
@AfterAll
17+
static void cleanup() {
18+
BaseE2ETest.cleanupTestEnvironment();
19+
}
20+
21+
@Test
22+
@Order(1)
23+
void UploadTest() throws Exception {
24+
UploadTest.uploadThroughProxy();
25+
// Wait for triggers to be set up at CEGA.
26+
// Not really needed if using local CEGA container.
27+
CommonUtils.waitForProcessing(5000);
28+
}
29+
30+
@Test
31+
@Order(2)
32+
void IngestTest() throws Exception {
33+
IngestTest.publishIngestionMessageToCEGA();
34+
// Wait for the LEGA ingest and verify services
35+
// to complete and update DB.
36+
CommonUtils.waitForProcessing(5000);
37+
}
38+
39+
@Test
40+
@Order(3)
41+
void AccessionTest() throws Exception {
42+
AccessionTest.publishAccessionMessageOnBehalfOfCEGAToLocalEGA();
43+
// Wait for LEGA finalize service to complete and update DB.
44+
CommonUtils.waitForProcessing(5000);
45+
}
46+
47+
@Test
48+
@Order(4)
49+
void MappingTest() throws Exception {
50+
MappingTest.triggerMappingMessageFromCEGA();
51+
// Wait for LEGA mapper service to store mapping
52+
CommonUtils.waitForProcessing(1000);
53+
}
54+
55+
@Test
56+
@Order(5)
57+
void ReleaseTest() throws Exception {
58+
ReleaseTest.triggerReleaseMessageFromCEGA();
59+
// Wait for LEGA mapper service to update dataset status
60+
CommonUtils.waitForProcessing(1000);
61+
}
62+
63+
@Test
64+
@Order(6)
65+
void DownloadTest() throws Exception {
66+
DownloadWithExportRequestTest.testDownloadDatasetUsingFegaExportRequestAndVerifyResults();
67+
}
68+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
package no.elixir.e2eTests;
2+
3+
import static org.junit.jupiter.api.Assertions.assertEquals;
4+
import static org.junit.jupiter.api.Assertions.assertNotNull;
5+
6+
import java.io.File;
7+
import java.nio.charset.StandardCharsets;
8+
import java.nio.file.Path;
9+
import java.security.interfaces.RSAPrivateKey;
10+
import java.security.interfaces.RSAPublicKey;
11+
import no.elixir.e2eTests.utils.TokenUtils;
12+
import org.apache.commons.io.FileUtils;
13+
import org.junit.jupiter.api.Test;
14+
import org.junit.jupiter.api.io.TempDir;
15+
16+
public class TokenUtilsTest {
17+
18+
@TempDir Path tempDir;
19+
20+
@Test
21+
void testPKCS1PrivateKey() throws Exception {
22+
String pkcs1PrivateKey =
23+
"""
24+
-----BEGIN RSA PRIVATE KEY-----
25+
MIIEowIBAAKCAQEAsn+9in5AY3xOauxYlj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
-----END PUBLIC KEY-----
63+
""";
64+
// Write keys to temp files
65+
File privKeyFile = new File(tempDir.toFile(), "pkcs1_private.pem");
66+
File pubKeyFile = new File(tempDir.toFile(), "pkcs1_public.pem");
67+
FileUtils.writeStringToFile(privKeyFile, pkcs1PrivateKey, StandardCharsets.UTF_8);
68+
FileUtils.writeStringToFile(pubKeyFile, publicKey, StandardCharsets.UTF_8);
69+
// Test loading PKCS#1 key (should be handled by BouncyCastle)
70+
RSAPrivateKey privateKey = TokenUtils.getPrivateKey(privKeyFile.getAbsolutePath());
71+
RSAPublicKey publicKey1 = TokenUtils.getPublicKey(pubKeyFile.getAbsolutePath());
72+
assertNotNull(privateKey);
73+
assertNotNull(publicKey1);
74+
assertEquals("RSA", privateKey.getAlgorithm());
75+
assertEquals("RSA", publicKey1.getAlgorithm());
76+
}
77+
}

0 commit comments

Comments
 (0)