4.0 KiB
Dummy Mode Configuration
This document explains how to use the dummy/mock mode in the legalconsenthub-middleware application.
Overview
Dummy mode allows you to test the middleware API endpoints without requiring a physical smart card connected to your system. Instead of interacting with real smart card hardware via OpenSC, the application returns predefined dummy data.
How to Enable Dummy Mode
Option 1: Using Spring Profiles
Start the application with the dummy profile:
# Using Gradle
./gradlew bootRun --args='--spring.profiles.active=dummy'
# Using JAR
java -jar build/libs/legalconsenthub-middleware-*.jar --spring.profiles.active=dummy
# Using environment variable
export SPRING_PROFILES_ACTIVE=dummy
./gradlew bootRun
Option 2: Using IntelliJ IDEA Run Configuration
A pre-configured run configuration named local-middleware-dummy is available in the .run directory. Simply:
- Open the project in IntelliJ IDEA
- Select "local-middleware-dummy" from the run configurations dropdown
- Click the run button
Option 3: Manual Configuration
You can also manually set the dummy mode property:
./gradlew bootRun --args='--dummy.mode.enabled=true'
What Gets Mocked
Smart Card Information
- Smart Card Info: Always returns a successful response with dummy smart card information
- Certificates: Always returns a successful response with two dummy certificates
Signature Operations
- Sign PDF Hash: Always returns a successful dummy signature
- Verify Signature: Always returns a successful verification result
Dummy Data
Smart Card Info
{
"isPresent": true,
"label": "DUMMY Smart Card",
"serialNumber": "12345678",
"manufacturer": "Dummy Corp",
"model": "DummyCard 2024"
}
Available Certificates
-
Certificate 1:
- ID:
01 - Subject:
CN=John Doe, O=Example Company, L=Berlin, C=DE - Issuer:
CN=Dummy CA, O=Dummy Corp, C=DE
- ID:
-
Certificate 2:
- ID:
02 - Subject:
CN=Jane Smith, O=Test Organization, L=Munich, C=DE - Issuer:
CN=Test CA, O=Test Corp, C=DE
- ID:
Testing Signature Verification
The dummy implementation always returns successful responses:
- All signatures: Any signature verification request will return
isValid: true - Consistent behavior: All requests return successful responses for predictable testing
- No validation: The dummy mode doesn't perform actual signature validation
API Endpoints
All original API endpoints remain the same when running in dummy mode:
GET /smart-card/info- Returns dummy smart card informationGET /smart-card/certificates- Returns dummy certificatesPOST /sign-pdf-hash- Creates dummy signaturesPOST /verify-signature- Verifies dummy signatures
Development Benefits
Using dummy mode provides several advantages during development:
- No Hardware Dependency: Test frontend functionality without smart card hardware
- Consistent Data: Predictable responses make testing easier
- Fast Development: No waiting for smart card operations or PIN entry
- Error Testing: Easily test error scenarios by using invalid certificate IDs
- CI/CD Integration: Run automated tests without smart card hardware
Switching Back to Real Mode
To disable dummy mode and use real smart card operations:
- Remove the
dummyprofile fromSPRING_PROFILES_ACTIVE - Ensure your smart card is connected and OpenSC is properly configured
- Start the application normally
# Normal mode (default)
./gradlew bootRun
# Or explicitly disable dummy mode
./gradlew bootRun --args='--dummy.mode.enabled=false'
Notes
- In dummy mode, all responses are successful and verification details are prefixed with "DUMMY:" to clearly indicate mock responses
- The dummy controllers return hardcoded successful responses without any actual processing
- All dummy responses include realistic data structures that match the real API responses
- Perfect for frontend testing where you need predictable successful responses