Read-only mirror of https://github.com/swiyu-admin-ch/swiyu-generic-application-test — Bundesamt für Justiz. Issues & pull requests at the source.
  • Java 98.8%
  • Shell 1.2%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
KarimKummerBIT 9533d0e1ca
Feature/eidomni 1639 samples (#513)
* feat(EIDOMNI-1639): Work in progress

* feat(EIDOMNI-1639): Add configurable sample smoke test launcher

* feat(EIDOMNI-1639): Simplify sample run logs
2026-12-03 15:23:08 +01:00
.github Feature/eidomni 1639 samples (#513) 2026-12-03 15:23:08 +01:00
.mvn/wrapper build(deps): bump org.apache.maven:apache-maven from 3.10.1 to 3.10.2 (#487) 2026-11-25 06:19:08 +01:00
scripts Feature/eidomni 1639 samples (#513) 2026-12-03 15:23:08 +01:00
test-wallet-application Feature/eidomni 1639 samples (#513) 2026-12-03 15:23:08 +01:00
test-wallet-library test(EIDOMNI-1614): Cover renewal signing key rotation (#510) 2026-12-01 14:16:44 +01:00
.gitattributes feat(EIDOMNI-1193): Preserve CRLF line endings in mvnw.cmd (#497) 2026-11-25 06:18:33 +01:00
.gitignore feat(EIDOMNI-1193): Remove unused files (#433) 2026-10-19 10:46:27 +02:00
CHANGELOG.md Create CHANGELOG.md 2026-01-30 14:20:43 +01:00
compose.yaml build(deps): bump org.mock-server:mockserver-client-java from 8.0.0 to 9.0.0 (#436) 2026-10-20 12:38:58 +02:00
CONTRIBUTING.md Create CONTRIBUTING.md 2026-01-30 13:32:50 +01:00
init.json feat(EIDOMNI-1193): Remove unused files (#433) 2026-10-19 10:46:27 +02:00
LICENSE Update README 2025-12-24 11:53:36 +01:00
mvnw Feature/eidomni 293 add test wallet (#1) 2025-10-14 16:03:48 +02:00
mvnw.cmd build(deps): bump org.apache.maven:apache-maven from 3.10.0 to 3.10.1 (#477) 2026-11-17 10:02:06 +01:00
pom.xml build(deps-dev): bump org.postgresql:postgresql from 42.7.14 to 42.7.15 (#501) 2026-12-01 12:12:24 +01:00
README.md Feature/eidomni 1639 samples (#513) 2026-12-03 15:23:08 +01:00
SECURITY.md Create SECURITY.md 2026-01-30 13:34:10 +01:00

github-banner

swiyu Generic Application Test

The Generic Application Test is a test system designed to run end-to-end (E2E) tests against the generic swiyu Issuer and Verifier components.

Its primary goal is to validate the generic behavior of these components in isolation, without relying on a full trust infrastructure or real wallets. The system focuses on testing the issuance and verification flows, independently of any specific ecosystem or deployment.

This project starts the Issuer and Verifier services inside containers and interacts with them through HTTP calls using a fake (mocked) wallet. All other trust-related services are mocked to keep the test environment simple, deterministic, and focused.

Table of Contents

Overview

The test framework runs the Generic Issuer and Generic Verifier components inside containers, together with their required infrastructure (PostgreSQL and a mock server).

For E2E testing purposes, the Issuer Business System, Verifier Business System, and the Wallet are not deployed as real services. Their behavior is simulated by the tests in order to drive issuance and verification flows.

This setup allows testing the containerized components in isolation, with fully controlled and deterministic external interactions.

flowchart LR
    issuer_bus[Issuer Business System]
    wallet[Test Wallet]
    verifier_bus[Verifier Business System]

    subgraph Containerized
        iss[Generic Issuer Service]
        ver[Generic Verifier Service]
        hsm[SoftHSM Container]

        mock[Mock Trust Server]
        db[(PostgreSQL)]
        tokens[(HSM Token Volume)]
    end

    issuer_bus -- HTTP --- iss
    verifier_bus -- HTTP --- ver
    
    wallet -- OIDC4VCI --- iss
    wallet -- OIDC4VP --- ver

    iss -- HTTP --- mock
    iss --- db
    iss -- Read Tokens --- tokens
    hsm -- Generate & Store Tokens --- tokens
    mock -- Read Private Keys --- tokens

    ver -- HTTP --- mock
    ver --- db
    

Management Pact Publication

The manual Publish Management Pact Contracts workflow generates and publishes:

  • swiyu-business-issuer-reference → swiyu-issuer (IF-113 / IF-114).
  • swiyu-business-verifier-reference → swiyu-verifier (IF-100).

In GitHub Actions, select this workflow, choose Run workflow, and select the branch to publish. The workflow must first be present on the default branch to be available through the manual workflow UI. Provide the same secrets used by issuer and verifier: PACT_BROKER_BASE_URL and PACT_BROKER_TOKEN. Organization secrets must grant this repository access; the token needs permission to publish contracts.

Only the management consumer Pact tests in test-wallet-library run, not the E2E suite. Both V4 contracts are validated before publication. PactFlow records the consumer version as the commit SHA, together with the branch and the GitHub Actions run URL. Generated JSON files stay under test-wallet-library/target/pacts, are uploaded with the test reports, and are not committed. Neither standard Maven builds nor pushes or pull requests publish contracts automatically.

After publication, launch the manual provider verification workflow in issuer and verifier. To select contracts from a feature branch, set consumer_version_selectors to [{"branch":"your-consumer-branch"}]. The providers' default mainBranch selector requires the consumer's main branch to be configured in PactFlow and contracts to have been published from that branch. Publishing alone does not verify the providers.

Prerequisites

Before running the tests, ensure you have the following tools and dependencies installed:

Required Software

Tool Version Purpose
Java 25+ Runtime for Maven and test execution
Maven 3.8+ Build tool and test runner
Docker 20.10+ Container runtime for services

Dependencies

This project uses Testcontainers to manage containerized services. Key dependencies include:

  • testcontainers: Container management framework
  • testcontainers-junit-jupiter: JUnit 5 integration
  • spring-boot-testcontainers: Spring Boot integration
  • mockserver-client-java: Mock server interaction

These are automatically managed by Maven via pom.xml.

Note that container ports are dynamically mapped by Testcontainers, minimizing the risk of local port conflicts.

Docker Compose startup test

Run ./scripts/test-compose.sh from the repository root with Docker Compose and curl available. The script starts compose.yaml in an isolated project with dynamically assigned host ports. It checks the PostgreSQL and MockServer health checks and waits for HTTP 200 from the Issuer and Verifier health endpoints. It prints container status and logs on failure and removes the test project's containers, network, and database volume on exit.

The script runs independently of Maven. To test specific images, set ISSUER_IMAGE_NAME, ISSUER_IMAGE_TAG, VERIFIER_IMAGE_NAME, and VERIFIER_IMAGE_TAG before running it.

On ARM hosts with AMD64 emulation enabled, pull the linux/amd64 images before starting the test.

docker pull --platform linux/amd64 ghcr.io/swiyu-admin-ch/swiyu-issuer:dev
docker pull --platform linux/amd64 ghcr.io/swiyu-admin-ch/swiyu-verifier:dev
./scripts/test-compose.sh

Official Docker Compose sample smoke tests

Run these checks from the repository root with Docker Compose (supporting !reset and !override), curl, jq, and git. The examples assume the component repositories are sibling checkouts. The component images run as linux/amd64, so enable AMD64 emulation when testing on an ARM host.

./scripts/test-sample-compose.sh issuer ../swiyu-issuer/sample.compose.yml
./scripts/test-sample-compose.sh verifier ../swiyu-verifier/sample.compose.yml
./scripts/test-sample-compose.sh issuer ../swiyu-issuer/sample.compose.yml --image ghcr.io/swiyu-admin-ch/swiyu-issuer:stable

Each check uses the sample's declared image by default. It starts the sample in an isolated Compose project with local test fixtures, verifies PostgreSQL health and application readiness, and reads the sample metadata. The Issuer check creates an offer and reads back OFFERED. The Verifier check creates a verification and reads back PENDING.

To run the complete Wallet journey, use JDK 25 or newer and pass the Issuer GHCR tag first and the Verifier tag second. Both samples start in the same Compose project with a local MockServer for DID resolution.

./scripts/run-sample-tests.sh 5.1.1 5.1.1

The Wallet collects one SD-JWT credential through the Pre-Authorized Code Flow, then presents it in a signed DCQL flow using direct_post.jwt. The test reads ISSUED from the Issuer and SUCCESS from the Verifier. The log records each protocol step, one line per Wallet HTTP response, the sample commits, and the executed image digests. On failure, the runner prints the failed phase and saves detailed diagnostics under target/sample-logs/.

The Docker Compose Sample Smoke Tests workflow runs the individual checks with the declared image and with :stable daily at 04:00 UTC and on demand. It also runs the complete Wallet journey with :stable by default. A manual dispatch can select both image tags for that journey. To reproduce an individual check, check out the recorded sample commit and pass --image <repository>@<digest>.

Project Structure

This is a multi-module Maven project organized as follows:

  • test-wallet-library: Contains reusable components including utilities, fixtures, test data builders, assertion helpers, and container configuration
  • test-wallet-application: Contains the actual test classes and Spring Boot configurations. Tests are executed from this module using the Spring Boot Test framework with environment annotations for component variants

The main packages of test-wallet-library:

Package Content
wallet (with credential, artefact, crypto) The fake Wallet. Wallet holds the settings and keys, CredentialIssuerClient (OID4VCI) and VerifierClient (OID4VP) talk to the components, HeldCredential is a credential with its holder key, and artefact builds DPoP proofs, key binding JWTs and SD-JWT credentials, with named deviations for negative tests.
issuer, verifier The Business Systems: BusinessIssuer and BusinessVerifier call the Management APIs of the generic Issuer and Verifier.
mock (with tp2) The external services simulated by MockServer: Base Registry, Status Registry, OAuth token endpoint, webhook callbacks, renewal service, and the Trust Protocol 2.0 registry.
environment, config, regression Containers, Issuer and Verifier variants, image configuration, and the Previous-to-Candidate version regression.
fixture, test_support, identity, util Test data, asserters and protocol parsers, DID and key helpers, and generic infrastructure.

Test Environment Model

E2E tests extend BaseTest, which acts as the environment provider for the test class. A test class declares the generic components it needs, and BaseTest ensures that the matching infrastructure and containers are running before the tests execute.

The environment is shared inside the same Maven/JVM test run:

  • one PostgreSQL container;
  • one schema per generic component configuration, such as swiyu_issuer_default or swiyu_verifier_default;
  • one MockServer container acting as base registry, status list service, TP2 trust service, attestation key service, and callback endpoint;
  • one Keycloak container when requested by a selected component or by @UseSharedServices;
  • one SoftHSM container when requested by a selected component or by @UseSharedServices;
  • one issuer/verifier container per selected variant.

The standard E2E suite groups test classes by their declared issuer, verifier, and optional shared services. Compatible classes run consecutively so the environment registry can reuse their containers. Tests remain sequential, with the same per-class preparation and method order. Version regression tests retain their existing order. The ordering is configured in test-wallet-application/src/test/resources/junit-platform.properties and can be overridden with the standard JUnit junit.jupiter.testclass.order.default configuration parameter when investigating an order-dependent failure.

MockServer routes are component-aware. DID documents, status lists, trust statements, renewal data, and callbacks are resolved by DID, status-list id, business id, or active component context rather than by a single global issuer.

Declaring Components

Use class-level annotations to declare the issuer and verifier variants needed by a test class:

@UseIssuers({IssuerVariant.DEFAULT, IssuerVariant.STRICT})
@UseVerifiers(VerifierVariant.DEFAULT)
class MultiIssuerFlowTest extends BaseTest {
    // tests
}

If no issuer or verifier annotation is present, BaseTest uses the default environment:

class DefaultFlowTest extends BaseTest {
    // equivalent to @UseIssuers(DEFAULT) and @UseVerifiers(DEFAULT)
}

@UseSharedServices is optional. Use it only when a test needs a shared service even though none of its selected component variants implies it:

@UseSharedServices(keycloak = true, hsm = true)
class SharedServiceContractTest extends BaseTest {
    // tests
}

Variants that require Keycloak or HSM start those shared services automatically.

Declaring The Wallet

Before every test BaseTest creates a fresh Wallet from the profile the class declares. By default the wallet uses no DPoP and no payload encryption. Declare what the whole class needs with @UseWallet:

@UseWallet(dpop = true, encryption = true)
class SignedRenewalFlowTest extends BaseTest {
    // every test starts with a wallet that sends DPoP proofs and encrypts its payloads
}

A test that needs something else for itself changes its own wallet (wallet.setUseDPoP(true)); nothing leaks into the next test. For a deliberate protocol violation use the builders in wallet.artefact (DpopProof, KeyBindingJwt, SdJwtCredential) and name the violated requirement in the test.

Using Components In Tests

BaseTest exposes named component handles:

IssuerHandle defaultIssuer = issuer(IssuerVariant.DEFAULT);
IssuerHandle strictIssuer = issuer(IssuerVariant.STRICT);
VerifierHandle defaultVerifier = verifier(VerifierVariant.DEFAULT);

Each handle contains the container URL, business manager, service location, component config, image config, management auth data, and the issuer status list where relevant.

The wallet can switch explicitly between components:

wallet.useIssuer(strictIssuer);
wallet.useVerifier(defaultVerifier);
wallet.useComponents(strictIssuer, defaultVerifier);

For test classes with a single issuer and verifier, the compatibility fields still point to the primary component:

  • issuerManager;
  • issuanceService;
  • verifierManager;
  • issuerConfig;
  • verifierConfig;
  • currentStatusList.

The primary component is the first declared variant. Without annotations, it is DEFAULT.

Adding An Issuer Variant

Add issuer configurations through IssuerVariant.

  1. Add the new enum value in IssuerVariant.
  2. Give it a unique surname; this becomes part of the container/schema identity.
  3. Set the variant flags, such as DPoP enforcement, signed metadata, JWT management auth, encryption enforcement, or HSM.
  4. Extend IssuerImageConfig and IssuerContainerConfig only if the new variant requires a new environment variable.
  5. Update MockServices or SwiyuEnvironmentRegistry only if the variant needs new mocked external behavior.
  6. Use the variant from tests with @UseIssuers(...).
  7. Run a targeted test first, then broaden to the full application suite if the change affects shared environment behavior.

Example:

@UseIssuers(IssuerVariant.STRICT)
class IssuerStrictManagementTest extends BaseTest {
    // issuerManager points to STRICT
}

Adding A Verifier Variant

Add verifier configurations through VerifierVariant.

  1. Add the new enum value in VerifierVariant.
  2. Give it a unique surname.
  3. Set whether it requires HSM or Keycloak.
  4. Extend VerifierImageConfig and VerifierContainerConfig only if the new variant requires a new environment variable.
  5. Update MockServer or registry behavior only when the verifier needs new trust, status, callback, or TP2 mock behavior.
  6. Use the variant from tests with @UseVerifiers(...).
  7. Run a targeted verifier test first, then broaden as needed.

Example:

@UseVerifiers(VerifierVariant.MANAGEMENT_KEYCLOAK)
class KeycloakManagementAuthTest extends BaseTest {
    // verifierManager uses a bearer token issued by the shared Keycloak container
}

Configuration

Environment Variables

The following environment variables can be used to configure the test execution:

Variable Purpose Default Example
ISSUER_IMAGE_NAME Docker image name for the Issuer service ghcr.io/swiyu-admin-ch/swiyu-issuer ghcr.io/swiyu-admin-ch/swiyu-issuer
ISSUER_IMAGE_TAG Docker image tag for the Issuer service dev dev, stable, rc, staging
VERIFIER_IMAGE_NAME Docker image name for the Verifier service ghcr.io/swiyu-admin-ch/swiyu-verifier ghcr.io/swiyu-admin-ch/swiyu-verifier
VERIFIER_IMAGE_TAG Docker image tag for the Verifier service dev dev, stable, rc, staging
TRACE_TEST_REQUESTS Write the HTTP requests and responses of each test (Wallet, Issuer Management API, Verifier Management API) to a Markdown trace false true, false
ISSUER_CONTAINER_LOGS Enable Issuer container logs true true, false
VERIFIER_CONTAINER_LOGS Enable Verifier container logs true true, false
DB_CONTAINER_LOGS Enable PostgreSQL container logs false true, false
MOCKSERVER_CONTAINER_LOGS Enable MockServer container logs false true, false
SOFTHSM_CONTAINER_LOGS Enable SoftHSM container logs false true, false

Container logs are controlled per service. Issuer and Verifier logs are enabled by default; infrastructure container logs are disabled by default.

Trace Output

When TRACE_TEST_REQUESTS=true is set, the HTTP requests and responses exchanged by the Wallet and by the Issuer and Verifier Management API clients are recorded during test execution. They are saved as Markdown files in test-wallet-application/target/request-traces/, one file per test (<TestClass>/<method>.md, with an index suffix for parameterized tests). This feature is particularly useful for understanding the flow of happy path tests and debugging.

Note: Enabling tracing changes the HTTP client used by the Wallet, and some tests then fail. Observed on 2026-10-01 with the full suite: six DPoP tests that expect a 401 error body (DPoPFlowTest and RenewalFlowTest) fail with tracing enabled, because the recorded 401 response has an empty body, while they pass without tracing. It is recommended to use tracing primarily for analyzing happy path test flows.

Version Regression Tests

Version regression tests are opt-in and exercise a stateful Previous to Candidate transition. PostgreSQL and MockServer stay running while the Previous component is stopped and the Candidate component starts and applies its database migrations.

Run it with explicit image versions:

./mvnw -Pversion-regression clean verify \
  -Dregression.issuer.previous.version=4.1.0 \
  -Dregression.issuer.candidate.version=4.2.0 \
  -Dregression.verifier.previous.version=4.1.0 \
  -Dregression.verifier.candidate.version=4.2.0

Previous and Candidate can use different variants and metadata files:

Configuration Previous example Candidate example
Issuer variant -Dregression.issuer.previous.variant=DEFAULT -Dregression.issuer.candidate.variant=STRICT
Issuer metadata -Dregression.issuer.previous.metadata=classpath:issuer/metadata.json -Dregression.issuer.candidate.metadata=file:/tmp/issuer-candidate.json
Verifier variant -Dregression.verifier.previous.variant=DEFAULT -Dregression.verifier.candidate.variant=CACHED
Verifier metadata -Dregression.verifier.previous.metadata=classpath:verifier/metadata.json -Dregression.verifier.candidate.metadata=file:/tmp/verifier-candidate.json

The standard ./mvnw clean verify excludes the version_regression tag and does not start regression components.

Hardware Security Module (HSM) Integration

This test framework includes HSM integration using SoftHSM to simulate a real Hardware Security Module in a containerized test environment. This allows for realistic testing of HSM integration in generic components without requiring physical HSM hardware.

Run the HSM scenarios with Java 25, Docker and OpenSSL, using unhardened AMD64 issuer and verifier images:

./mvnw -pl test-wallet-application -am clean verify \
  -Dhsm=true -Dtest=IssuerHSMTest,VerifierHSMTest \
  -Dsurefire.failIfNoSpecifiedTests=false -DskipITs=true

The manual workflows Run E2E Tests HSM and Run E2E Tests HSM (Branches) run this selection. The first takes published image names and tags; the second builds the selected issuer and verifier branches.

The HSM profile generates fresh P-256 test keys and certificates, packages them as PKCS#12, then imports them through SunPKCS11 with CKA_SENSITIVE=false and CKA_EXTRACTABLE=true. Library 3.2.0 accepts the resulting ECPrivateKey. Signing still uses the PKCS#11 provider. These fixtures exercise credential issuance, status-list signing and verifier Request Object signing, including key overrides. They do not verify private-key non-exportability or hardware protection. The existing library rejects SoftHSM's opaque P11ECPrivateKeyInternal keys; changing their PEM encoding does not fix it. Use these import attributes only for generated test keys.

HSM E2E coverage audit

The HSM workflows select both complete test classes, including parameterized cases. The suite covers these risks:

Boundary Risk / invariant Cases
OID4VCI issuance Default HSM key signs every batch entry; presentations reach SUCCESS 1
OID4VCI issuance Alternate key and matching kid; missing, empty and supplied key_pin 3
OID4VCI issuance An override does not change another offer's default key 1
Signed issuer metadata Default and overridden tenant keys match the metadata signature, kid and subject 2
Deferred issuance The stored override survives DEFERRED → READY → ISSUED 1
OID4VCI issuance An unknown key never falls back to the default or produces a Credential 1
Status Registry v2 Default creation, override creation and rotation use the selected HSM key 3
Status Registry v2 Absent, empty and partial overrides preserve stored fields 3
Status Registry v2 An unknown key sends no PUT and does not persist an invalid override 1
Status Registry v2 Rotating one list does not change another list's key 1
OID4VP Request Object Default and override identities complete encrypted presentations; optional PIN variants 4
OID4VP Request Object The existing key-id override regression works without key_pin 1
OID4VP signer cache Interleaved retrievals retain each request's key, kid and client_id 1
OID4VP signer cache An unknown key cannot reuse a cached default signer or poison subsequent requests 1

Signatures are verified independently with Nimbus and both test public keys, including a negative check against the unselected key. Status Registry captures are scoped to the list's registry ID. The HSM Verifier publishes the token's keys in its DID and receives no software signing key through SIGNING_KEY. The HSM Issuer enables tenant-specific signed metadata. Its default Credential key is 01 (assert-key-01), its default status-list key is 02 (auth-key-01), and the Verifier's default Request Object key is 01 (auth-key-01 in the Verifier DID). Override cases select the other key so falling back to a static signer cannot pass the assertions.

Protocol references are OID4VCI 1.0 sections 8.3, 9 and 12.2.3; OID4VP 1.0 sections 5.9.3 and 8.6; the Swiss issuance profile section 12.2.3, verification profile section 5, VC profile Token Status List section 5.1, and the anchor profile's "JWT Validation with cryptographic keys from DIDs". The management API owns override scope and partial-field merge; OpenID does not define configuration_override. The exact HTTP mapping for a missing HSM key is Unknown, so negative scenarios assert failure and protected side effects rather than prescribing a protocol error code.

SoftHSM PKCS#11 login uses the configured token userPin; library 3.2.0's PKCS11 strategy does not consume key_pin. The optional-field cases do not prove enforcement of a per-key PIN. PIN enforcement for other HSM providers belongs in provider integration tests. Non-exportable keys remain blocked by the library issue described above. Hardware protection, token outages, concurrent provider sessions and renewal-specific override handling need separate fixtures or component integration coverage. These scenarios are not claimed as covered by this suite.

Local Development and Testing

When making modifications to the Issuer or Verifier services, you can build and test these development versions locally without relying on pre-built registry images. This allows you to run full end-to-end tests against your own development builds.

Prerequisites for Local Testing

In addition to the standard prerequisites, you need:

  • Access to the swiyu-issuer repository (for testing Issuer modifications)
  • Access to the swiyu-verifier repository (for testing Verifier modifications)

Building and Preparing Local Images for Testing

Run the prepare-local-testing.sh script to build both development images locally and configure them for E2E testing:

source ./scripts/prepare-local-testing.sh

This script performs the following steps:

  1. Builds Maven packages for both services (mvn clean package -DskipTests)
  2. Creates Docker images with the local tag
  3. Sets environment variables to use the locally built images:
    • ISSUER_IMAGE_NAME=swiyu-issuer and ISSUER_IMAGE_TAG=local
    • VERIFIER_IMAGE_NAME=swiyu-verifier and VERIFIER_IMAGE_TAG=local

After running this script, all subsequent test executions will use your locally built development images.

Custom Repository Paths

By default, the script expects repositories at:

  • ~/Git/swiyu-issuer
  • ~/Git/swiyu-verifier

To use custom paths, set the environment variables before running the script:

Variable Purpose Default
LOCAL_REPOSITORY_ISSUER_ROOT Path to local Issuer repository for development builds ~/Git/swiyu-issuer
LOCAL_REPOSITORY_VERIFIER_ROOT Path to local Verifier repository for development builds ~/Git/swiyu-verifier

Reverting to Registry Images

Once you've finished testing your development builds, you can revert to using the pre-built images from GitHub Container Registry by unsetting the local image environment variables:

source ./scripts/cleanup-local-testing.sh

This script removes the environment variables set by prepare-local-testing.sh, allowing for subsequent tests to use the default registry images again.

Contributions and feedback

We welcome any feedback on the code regarding both the implementation and security aspects. Please follow the guidelines for contributing found in CONTRIBUTING.md.

License

This project is licensed under the terms of the MIT license. See the LICENSE file for details.