Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions e2eTests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ dependencies {
testImplementation("org.skyscreamer:jsonassert:1.5.3")
testCompileOnly("org.projectlombok:lombok:1.18.40")
testAnnotationProcessor("org.projectlombok:lombok:1.18.40")
implementation("org.bouncycastle:bcprov-jdk18on:1.82")
implementation("org.bouncycastle:bcpkix-jdk18on:1.82")
}

// Start setup scripts.
Expand Down
26 changes: 23 additions & 3 deletions e2eTests/docker-compose.template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -644,8 +644,8 @@ services:
container_name: e2e-tests
hostname: e2e_tests
build:
context: .
dockerfile: e2e-tests.Dockerfile
context: ..
dockerfile: e2eTests/e2e-tests.Dockerfile
depends_on:
proxy:
condition: service_healthy
Expand All @@ -660,7 +660,27 @@ services:
file-orchestrator:
condition: service_healthy
environment:
- INTEGRATION=FEGA
- E2E_TESTS_RUNTIME=<<E2E_TESTS_RUNTIME>>
- E2E_TESTS_INTEGRATION=<<E2E_TESTS_INTEGRATION>>
- E2E_TESTS_PROXY_HOST=<<E2E_TESTS_PROXY_HOST>>
- E2E_TESTS_PROXY_PORT=<<E2E_TESTS_PROXY_PORT>>
- E2E_TESTS_SDA_DOA_HOST=<<E2E_TESTS_SDA_DOA_HOST>>
- E2E_TESTS_SDA_DOA_PORT=<<E2E_TESTS_SDA_DOA_PORT>>
- E2E_TESTS_CEGAMQ_CONN_STR=<<E2E_TESTS_CEGAMQ_CONN_STR>>
- E2E_TESTS_CEGAAUTH_USERNAME=<<E2E_TESTS_CEGAAUTH_USERNAME>>
- E2E_TESTS_CEGAAUTH_PASSWORD=<<E2E_TESTS_CEGAAUTH_PASSWORD>>
- E2E_TESTS_SDA_DB_HOST=<<E2E_TESTS_SDA_DB_HOST>>
- E2E_TESTS_SDA_DB_PORT=<<E2E_TESTS_SDA_DB_PORT>>
- E2E_TESTS_SDA_DB_USERNAME=<<E2E_TESTS_SDA_DB_USERNAME>>
- E2E_TESTS_SDA_DB_PASSWORD=<<E2E_TESTS_SDA_DB_PASSWORD>>
- E2E_TESTS_SDA_DB_DATABASE_NAME=<<E2E_TESTS_SDA_DB_DATABASE_NAME>>
- E2E_TESTS_TRUSTSTORE_PASSWORD=<<E2E_TESTS_TRUSTSTORE_PASSWORD>>
- E2E_TESTS_PROXY_TOKEN_AUDIENCE=<<E2E_TESTS_PROXY_TOKEN_AUDIENCE>>
- E2E_TESTS_PROXY_ADMIN_USERNAME=<<E2E_TESTS_PROXY_ADMIN_USERNAME>>
- E2E_TESTS_PROXY_ADMIN_PASSWORD=<<E2E_TESTS_PROXY_ADMIN_PASSWORD>>
# - E2E_TESTS_EGA_DEV_BASE_DIRECTORY=<<E2E_TESTS_EGA_DEV_BASE_DIRECTORY>>
# - E2E_TESTS_EGA_DEV_PUBLIC_KEY_FILENAME=<<E2E_TESTS_EGA_DEV_PUBLIC_KEY_FILENAME>>
# - E2E_TESTS_LSAAI_TOKEN=<<E2E_TESTS_LSAAI_TOKEN>>
volumes:
- storage:/storage

Expand Down
25 changes: 18 additions & 7 deletions e2eTests/e2e-tests.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
# Use Temurin 21 as the base image for Java 21
FROM eclipse-temurin:21-jdk-alpine
FROM eclipse-temurin:21-jdk-alpine AS builder

WORKDIR /app

COPY build.gradle.kts settings.gradle.kts gradlew ./
COPY gradle/ ./gradle/
COPY buildSrc ./buildSrc
COPY lib/crypt4gh ./lib/crypt4gh
COPY e2eTests/ ./e2eTests

RUN ./gradlew :lib:crypt4gh:build :e2eTests:jar --no-daemon

FROM eclipse-temurin:21-jre-alpine

# Install bash
RUN apk add --no-cache bash

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

# Copy the application JAR and scripts
COPY /build/libs/e2eTests.jar /fega-norway/e2eTests.jar
COPY env.sh /fega-norway/env.sh
COPY entrypoint.sh /entrypoint.sh
# Copy the application JAR, env, and scripts
COPY --from=builder /app/e2eTests/build/libs/e2eTests.jar /fega-norway/e2eTests.jar
COPY --from=builder /app/e2eTests/entrypoint.sh /fega-norway/entrypoint.sh

# Make entrypoint executable
RUN chmod +x /entrypoint.sh
RUN chmod +x /fega-norway/entrypoint.sh

# Run the entrypoint using bash
CMD ["/bin/bash", "/entrypoint.sh"]
CMD ["/bin/bash", "/fega-norway/entrypoint.sh"]
17 changes: 11 additions & 6 deletions e2eTests/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,26 @@ if [ -f "/storage/certs/rootCA.pem" ]; then
-noprompt \
-storepass changeit
else
echo "Warning: /storage/certs/rootCA.pem not found, skipping certificate import."
echo "Info: /storage/certs/rootCA.pem not found, skipping certificate import."
fi

# Choose which test to run based on the INTEGRATION variable.
# NB! Must be present in the environment.
#
# Choose which test to run based on the E2E_TESTS_INTEGRATION variable.
# If set to "FEGA", run no.elixir.e2eTests.FEGAIntegrationTest.
# Otherwise, run no.elixir.e2eTests.GDIIntegrationTest.
# See the top-level classes in no.elixir.e2eTests for details.
if [ "$INTEGRATION" = "FEGA" ]; then
if [ "$E2E_TESTS_INTEGRATION" = "FEGA" ]; then
echo "Running FEGA integration tests"
exec java -jar e2eTests.jar --select-class no.elixir.e2eTests.FEGAIntegrationTest
elif [ "$INTEGRATION" = "GDI" ]; then
elif [ "$E2E_TESTS_INTEGRATION" = "GDI" ]; then
echo "Running GDI integration tests"
exec java -jar e2eTests.jar --select-class no.elixir.e2eTests.GDIIntegrationTest
elif [ "$E2E_TESTS_INTEGRATION" = "EGA_DEV" ]; then
echo "Running EGA_DEV integration tests"
exec java -jar e2eTests.jar --select-class no.elixir.e2eTests.EgaDevIntegrationTest
else
echo "Error: Unknown or unset INTEGRATION value: $INTEGRATION"
echo "Please set INTEGRATION=FEGA or INTEGRATION=GDI"
echo "Error: Unknown or unset E2E_TESTS_INTEGRATION value: $E2E_TESTS_INTEGRATION"
echo "Please set E2E_TESTS_INTEGRATION=FEGA or E2E_TESTS_INTEGRATION=GDI or E2E_TESTS_INTEGRATION=EGA_DEV"
exit 1
fi
46 changes: 28 additions & 18 deletions e2eTests/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -200,38 +200,48 @@ export HEARTBEAT_REDIS_DB=0

# E2E Test
# ---------------------------------------------------------------------------

# Determines the runtime mode for the E2E tests.
# If set to "container", the entire test runs inside a Docker container.
# If set to "local", you can run the test using: `./gradlew :e2eTests:test`.
# Mainly used to switch the host/ports and file systems to fetch the certificates.
export E2E_RUNTIME=container
export E2E_TESTS_RUNTIME=container

# Determines which integration should be run.
# Either FEGA or GDI or EGA_DEV
export E2E_TESTS_INTEGRATION=FEGA

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

if [ "$E2E_RUNTIME" = "container" ]; then
if [ "$E2E_TESTS_RUNTIME" = "container" ]; then
echo "$container_value"
else
echo "$local_value"
fi
}

# Use the function for environment variable assignments
export E2E_PROXY_HOST=$(_runtime_ "proxy" "localhost")
export E2E_PROXY_PORT=$(_runtime_ "8080" "10443")
export E2E_SDA_DOA_HOST=$(_runtime_ "doa" "localhost")
export E2E_SDA_DOA_PORT=$(_runtime_ "8080" "80")
export E2E_CEGAMQ_CONN_STR="amqps://$CEGAMQ_USERNAME:$CEGAMQ_PASSWORD@$(_runtime_ $CEGAMQ_HOST "localhost"):$CEGAMQ_PORT/$CEGAMQ_VHOST"
export E2E_CEGAAUTH_USERNAME=$CEGAAUTH_CEGA_USERS_USER
export E2E_CEGAAUTH_PASSWORD=$CEGAAUTH_CEGA_USERS_PASSWORD
export E2E_SDA_DB_HOST=$(_runtime_ "$DB_HOST" "localhost")
export E2E_SDA_DB_PORT=$DB_PORT
export E2E_SDA_DB_USERNAME=$DB_POSTGRES_USER
export E2E_SDA_DB_PASSWORD=$DB_POSTGRES_PASSWORD
export E2E_SDA_DB_DATABASE_NAME=$DB_POSTGRES_DB
export E2E_TRUSTSTORE_PASSWORD=$KEYTOOL_TRUSTSTORE_PASSWORD
export E2E_PROXY_TOKEN_AUDIENCE=$PROXY_TOKEN_AUDIENCE
export E2E_PROXY_ADMIN_USERNAME=$PROXY_ADMIN_USER
export E2E_PROXY_ADMIN_PASSWORD=$PROXY_ADMIN_PASSWORD
export E2E_TESTS_PROXY_HOST=$(_runtime_ "proxy" "localhost")
export E2E_TESTS_PROXY_PORT=$(_runtime_ "8080" "10443")
export E2E_TESTS_SDA_DOA_HOST=$(_runtime_ "doa" "localhost")
export E2E_TESTS_SDA_DOA_PORT=$(_runtime_ "8080" "80")
export E2E_TESTS_CEGAMQ_CONN_STR="amqps://$CEGAMQ_USERNAME:$CEGAMQ_PASSWORD@$(_runtime_ $CEGAMQ_HOST "localhost"):$CEGAMQ_PORT/$CEGAMQ_VHOST"
export E2E_TESTS_CEGAAUTH_USERNAME=$CEGAAUTH_CEGA_USERS_USER
export E2E_TESTS_CEGAAUTH_PASSWORD=$CEGAAUTH_CEGA_USERS_PASSWORD
export E2E_TESTS_SDA_DB_HOST=$(_runtime_ "$DB_HOST" "localhost")
export E2E_TESTS_SDA_DB_PORT=$DB_PORT
export E2E_TESTS_SDA_DB_USERNAME=$DB_POSTGRES_USER
export E2E_TESTS_SDA_DB_PASSWORD=$DB_POSTGRES_PASSWORD
export E2E_TESTS_SDA_DB_DATABASE_NAME=$DB_POSTGRES_DB
export E2E_TESTS_TRUSTSTORE_PASSWORD=$KEYTOOL_TRUSTSTORE_PASSWORD
export E2E_TESTS_PROXY_TOKEN_AUDIENCE=$PROXY_TOKEN_AUDIENCE
export E2E_TESTS_PROXY_ADMIN_USERNAME=$PROXY_ADMIN_USER
export E2E_TESTS_PROXY_ADMIN_PASSWORD=$PROXY_ADMIN_PASSWORD

# New configs introduced for EGA DEV testing
# export E2E_TESTS_EGA_DEV_BASE_DIRECTORY=
# export E2E_TESTS_EGA_DEV_PUBLIC_KEY_FILENAME=
# export E2E_TESTS_LSAAI_TOKEN=
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package no.elixir.e2eTests;

import no.elixir.e2eTests.core.BaseE2ETest;
import no.elixir.e2eTests.features.*;
import no.elixir.e2eTests.utils.CommonUtils;
import org.junit.jupiter.api.*;

@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class EgaDevIntegrationTest {

@BeforeAll
static void setup() throws Exception {
BaseE2ETest.setupEgaDevTestEnvironment();
}

@AfterAll
static void cleanup() {
BaseE2ETest.cleanupTestEnvironment();
}

@Test
@Order(1)
void UploadTest() throws Exception {
UploadTest.uploadThroughProxy();
// Wait for triggers to be set up at CEGA.
// Not really needed if using local CEGA container.
CommonUtils.waitForProcessing(5000);
}

@Test
@Order(2)
void IngestTest() throws Exception {
IngestTest.publishIngestionMessageToCEGA();
// Wait for the LEGA ingest and verify services
// to complete and update DB.
CommonUtils.waitForProcessing(5000);
}

@Test
@Order(3)
void AccessionTest() throws Exception {
AccessionTest.publishAccessionMessageOnBehalfOfCEGAToLocalEGA();
// Wait for LEGA finalize service to complete and update DB.
CommonUtils.waitForProcessing(5000);
}

@Test
@Order(4)
void MappingTest() throws Exception {
MappingTest.triggerMappingMessageFromCEGA();
// Wait for LEGA mapper service to store mapping
CommonUtils.waitForProcessing(1000);
}

@Test
@Order(5)
void ReleaseTest() throws Exception {
ReleaseTest.triggerReleaseMessageFromCEGA();
// Wait for LEGA mapper service to update dataset status
CommonUtils.waitForProcessing(1000);
}

@Test
@Order(6)
void DownloadTest() throws Exception {
DownloadWithExportRequestTest.testDownloadDatasetUsingFegaExportRequestAndVerifyResults();
}
}
77 changes: 77 additions & 0 deletions e2eTests/src/test/java/no/elixir/e2eTests/TokenUtilsTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package no.elixir.e2eTests;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

import java.io.File;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;
import no.elixir.e2eTests.utils.TokenUtils;
import org.apache.commons.io.FileUtils;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;

public class TokenUtilsTest {

@TempDir Path tempDir;

@Test
void testPKCS1PrivateKey() throws Exception {
String pkcs1PrivateKey =
"""
-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEAsn+9in5AY3xOauxYljtWFocBEg/SVgTdGDQc/zLPHv2cwPeT
8sidSRofN0UTDH6logNmf5drZlpBUPNFE4lZ24DlLbPZzD1K+ubLAWAHEYUVaDz7
DjiVj5bBQUYMRqPXaz1/tfA5IMXfrmPCqhO2r+6OEXt6C9konsBRGNnGvfSCU8pP
VMxe3OSBz8f57OHjBa5ryZfEBrAFLAB09s3oicbvrfcUjVRxFjUiUW8tHv+gSPVM
8RDxpknwAvBDZ7kr0/xyIbRuNyuLQ7YQoPKf1M25EXqTR6uNaoHrJR9wX1T2757L
IeVjKBiGzNYBTqV8xEd1Ht2jfzAvKYbdcuglqQIDAQABAoIBAGj/uWg5QfkDi0Fc
S/P7bXWM7rVIN0tASypMpW383ld1ifr857ueBN+WjRw+9qiX6yi1ZVrSoGux1dAf
ede3KPN1C9rpe8mnmG6kym/BpAbLST9q96dy4492d7HE2b3H7RT5NSG58HD11NFJ
f536QLGW210vTCiiEkHoEQxUNpNPv/Fy+jRxl7TT/i+8wW60xBK0aDcfDNgNVsRq
yiCmfoHzbdDJy+4vaBhnB0UH6zPJlNjFNX1187TBZoh9ysN2+FBUfWQDkTHafB+A
frLNvnzdkNlbx6ZLEeEZHZYmBslPIG9bv5TMlZJofhInOK+5ep+HkWDlR/hXMWtC
er6Wcl0CgYEA5/W5Oudk4Rk1PeHYvtnRxEI7aDFJJcxL99M1iADysPGDCyw/ndDy
yX55DcIKmuw2SyPQhTLbkVdBorinKP2gO7dn6bVXUJro/TQnllnwh627CY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a5ryZfEBrAFLAB09s3o
icbvrfcUjVRxFjUiUW8tHv+gSPVM8RDxpknwAvBDZ7kr0/xyIbRuNyuLQ7YQoPKf
1M25EXqTR6uNaoHrJR9wX1T2757LIeVjKBiGzNYBTqV8xEd1Ht2jfzAvKYbdcugl
qQIDAQAB
-----END PUBLIC KEY-----
""";
// Write keys to temp files
File privKeyFile = new File(tempDir.toFile(), "pkcs1_private.pem");
File pubKeyFile = new File(tempDir.toFile(), "pkcs1_public.pem");
FileUtils.writeStringToFile(privKeyFile, pkcs1PrivateKey, StandardCharsets.UTF_8);
FileUtils.writeStringToFile(pubKeyFile, publicKey, StandardCharsets.UTF_8);
// Test loading PKCS#1 key (should be handled by BouncyCastle)
RSAPrivateKey privateKey = TokenUtils.getPrivateKey(privKeyFile.getAbsolutePath());
RSAPublicKey publicKey1 = TokenUtils.getPublicKey(pubKeyFile.getAbsolutePath());
assertNotNull(privateKey);
assertNotNull(publicKey1);
assertEquals("RSA", privateKey.getAlgorithm());
assertEquals("RSA", publicKey1.getAlgorithm());
}
}
Loading
Loading