This directory contains the integration testing setup for the Simple SAML Proxy project, implementing the solution designed in Issue #26.
The integration testing environment uses a Multi-Keycloak setup to test the proxy's IDP selection functionality:
- Keycloak IdP (port 11001): Acts as the first Identity Provider ("Development IdP") with test users
- Keycloak IdP2 (port 11002): Acts as the second Identity Provider ("Enterprise IdP") with enterprise users
- Keycloak SP (port 12000): Acts as the Service Provider consuming authentication
- Simple SAML Proxy (port 10000): The proxy being tested, bridges multiple IDPs and SP
- Docker and Docker Compose
- Make (optional, for easier commands)
# Generate certificates and start all services
make test # Run full integration test suite
# Or manually:
make setup # Generate certificates
make start # Start all services (automatically waits for health)
make test-e2e # Run integration testsThe make start command uses Docker Compose's --wait flag to automatically wait for all services to be healthy before returning. This eliminates the need for manual sleep commands or additional scripts.
Docker Compose monitors:
- Container health status via built-in healthchecks
- Service dependencies with
depends_onandcondition: service_healthy - Automatic retries and startup delays
The services will start in the correct order:
- Keycloak IdPs and SP start first
- SAML Proxy waits for all Keycloak services to be healthy
- Tests can run immediately after
make startcompletes
- Keycloak IdP Admin: http://localhost:11001/admin (admin/admin)
- Keycloak IdP2 Admin: http://localhost:11002/admin (admin/admin)
- Keycloak SP Admin: http://localhost:12000/admin (admin/admin)
- SAML Proxy: http://localhost:10000
- testuser/testpassword - Standard test user
- enterpriseuser/enterprisepassword - Enterprise user
- testuser/testpassword - Test user (IDP2 variant)
With the multi-IDP setup, you can now test the proxy's IDP selection functionality:
- Start the environment:
make dev-setup - Access Keycloak SP: http://localhost:12000
- Initiate SAML login through the SP's SAML broker
- Observe IDP selection screen at the proxy (should show "Development IdP" and "Enterprise IdP")
- Test different IDPs by selecting each option and logging in with respective users
Note: Tests now exit automatically without requiring user input. The HTML report server no longer starts automatically after test completion.
# Run all tests
make test-e2e
# Run specific test suites
cd tests
npm run test:flow # Run simplified SAML flow tests
npm run test:proxy # Run detailed proxy flow tests
# Run with different modes
npm run test:verbose # Verbose output
npm run test:headed # Run in headed browser
npm run test:ui # Run with Playwright UI
npm run test:debug # Run in debug modeThe tests validate the complete SAML proxy flows:
SP →[SAML AuthnRequest]→ Proxy →[New SAML AuthnRequest]→ IdP →[SAML Response]→ Proxy →[New SAML Response]→ SP
Key test files:
tests/saml-flow.spec.js- Simplified flow teststests/saml-proxy-flow.spec.js- Detailed proxy flow validation
When running tests in verbose mode, you get:
- Detailed HTTP traffic: All requests/responses with headers and status codes
- SAML message inspection: Base64 encoded/decoded SAML requests
- Step-by-step logging: Each action in the flow is logged
- Response content: First N characters of responses for debugging
- Network timing: Time taken for each request
- Browser console logs: JavaScript errors and console messages
- Screenshots/videos: Automatic capture in verbose mode (Playwright)
- HAR recording: Full network traffic recording (Playwright)
example/
├── docker-compose.yml # Main orchestration file
├── Dockerfile # Simple SAML Proxy container
├── Makefile # Automation commands
├── README.md # This file
├── certs/ # Test certificates
│ ├── generate-certs.sh # Certificate generation
│ ├── proxy.crt/key # Proxy certificates
│ ├── keycloak-idp.crt/key # IdP certificates
│ └── keycloak-sp.crt/key # SP certificates
├── keycloak-idp/ # Keycloak IdP configuration
│ └── test-realm.json # Test realm with users
├── keycloak-sp/ # Keycloak SP configuration
│ └── test-realm.json # Test realm with IdP config
├── scripts/ # Configuration scripts
│ └── configure-keycloak.sh # Post-startup Keycloak configuration
└── tests/ # Playwright E2E tests
├── package.json
├── playwright.config.js
└── tests/
└── saml-flow.spec.js # Comprehensive SAML flow tests
The Simple SAML Proxy is configured via environment variables in docker-compose.yml:
# Proxy configuration
PROXY_ENTITY_ID: "http://localhost:8082/metadata"
PROXY_ACS_URL: "http://localhost:8082/acs"
PROXY_SSO_URL: "http://localhost:8082/sso"
# IdP configuration (Multiple IDPs)
IDP_0_ID: "keycloak-idp"
IDP_0_NAME: "Development IdP"
IDP_0_METADATA_URL: "http://keycloak-idp:8080/realms/test/protocol/saml/descriptor"
IDP_1_ID: "keycloak-idp2"
IDP_1_NAME: "Enterprise IdP"
IDP_1_METADATA_URL: "http://keycloak-idp2:8083/realms/test2/protocol/saml/descriptor"
# SP configuration
PROXY_ALLOWED_SP_0_ENTITY_ID: "http://keycloak-sp:8080/realms/test"
PROXY_ALLOWED_SP_0_ACS_URL: "http://keycloak-sp:8080/realms/test/broker/saml/endpoint"
# SLO Signature Validation (optional, default: false)
PROXY_REQUIRE_SIGNED_LOGOUT_REQUESTS: "false" # Global setting
PROXY_ALLOWED_SP_0_REQUIRE_SIGNED_LOGOUT_REQUESTS: "false" # Per-SP setting- IdP Realm: Contains test users and SAML client configuration
- SP Realm: Contains SAML identity provider configuration pointing to the proxy
# Start development environment
make start # Starts services with automatic health checking
# View logs
make logs # All services
make logs-proxy # Proxy only
make logs-idp # IdP only
make logs-sp # SP only
# Get shell access
make shell-proxy # Proxy container
make shell-idp # IdP container
make shell-sp # SP container
# Clean up
make clean # Stop and remove volumes
make stop # Stop services only
# Rebuild and restart
make rebuild # Rebuild and restart all services with health waiting- Run Full Test Suite:
make test(includes setup, start, and test execution) - Check Logs:
make logs(if tests fail) - Clean Up:
make clean
For manual testing:
- Start Services:
make start(Docker Compose waits for health) - Run E2E Tests:
make test-e2e - Check Logs:
make logs - Clean Up:
make clean
- Services not starting: Check if ports 10000, 11001, 11002, 12000 are available
- Certificate errors: Regenerate certificates with
make setup - Network issues: Ensure Docker daemon is running
- Test failures: Check service logs with
make logs - Health check timeout: Services may take longer to start on slower machines
- Service connection issues: Check
docker-compose logsfor detailed errors
# Check service status
make status
# Follow logs in real-time
make logs
# Access container directly
make shell-proxyThis setup was designed based on the requirements and discussion in Issue #26:
- Free OSS Solution: Uses Keycloak (Apache 2.0 license)
- Production-Ready: Keycloak provides enterprise-grade SAML support
- Docker-Based: Easy local development and CI/CD integration
- Consistent Technology: Same technology stack for both IdP and SP
- Extensible: Easy to add more test scenarios and configurations
The example setup has been optimized to reduce code duplication and improve maintainability:
- Docker Compose: Reduced ~50 lines by using YAML anchors for shared Keycloak configuration
- Certificate Generation: Refactored to use functions, reducing ~15 lines of duplicate code
- SAML Decoding: Merged duplicate Python scripts into one flexible tool with
--simpleflag
- Unified SAML Decoder:
decode-saml.pynow supports both XML and regex parsing modes - Validation Script: Added
validate-setup.shto verify configuration integrity - Streamlined Package Scripts: Cleaned up npm test scripts in
package.json
- Reduced Maintenance: Common configurations are centralized
- Improved Consistency: Shared templates ensure uniform behavior
- Better Documentation: Consolidated tools with clear usage instructions
When adding new tests:
- Add E2E tests to
tests/tests/ - Use verbose mode for debugging:
VERBOSE=true npm test - Update Makefile if needed
- Update this README with new instructions
- Run
bash validate-setup.shto ensure changes don't break setup
This testing setup follows the same license as the main project.