IdentityServer Example for E2E Testing¶
The py/examples/identity-server/ directory contains the configuration for running Duende IdentityServer for end-to-end testing with the py-identity-model library.
Files¶
Dockerfile- Docker build configuration for custom IdentityServer imagestartup.sh- Startup script that waits for certificates before launchingIdentityServer.csproj- .NET project file with Duende IdentityServer dependenciesProgram.cs- IdentityServer application bootstrap codeConfig.cs- Loads clients and scopes fromidentityserver-config.json(reads client secrets from environment)identityserver-config.json- API scope and client definitionsappsettings.json- IdentityServer application settings (issuer URI)generate-certs.sh- Helper for generating a local self-signed certificate outside Docker
Usage¶
Recommended: Use the complete test setup from the py/examples/ directory which includes automatic certificate generation:
This automatically: - Generates SSL certificates - Starts the Identity Server - Configures the FastAPI example - Runs integration tests
Running Identity Server Standalone¶
If you only need the Identity Server:
Note: Certificates are automatically generated and managed via the cert-generator service.
Configuration¶
The IdentityServer is configured with:
- HTTPS Port: 5001 (HTTPS)
- HTTP Port: 5000 (HTTP, for fallback)
- Discovery Endpoint: https://localhost:5001/.well-known/openid-configuration
- JWKS Endpoint: https://localhost:5001/.well-known/openid-configuration/jwks
- Token Endpoint: https://localhost:5001/connect/token
Clients¶
Two test clients are configured:
- py-identity-model-client (Client Credentials)
- Client ID:
py-identity-model-client - Client Secret: Configured via
CLIENT_SECRETenvironment variable (default:py-identity-model-secret) -
Scopes:
py-identity-model -
py-identity-model-test (Authorization Code)
- Client ID:
py-identity-model-test - Client Secret: Configured via
TEST_CLIENT_SECRETenvironment variable (default:test-secret) - Scopes:
openid,profile,py-identity-model - Redirect URI:
https://localhost:5002/signin-oidc
Security: Client secrets are read from environment variables (CLIENT_SECRET, TEST_CLIENT_SECRET), which docker-compose.test.yml passes through with the defaults above.
Health Check¶
The identityserver service in docker-compose.test.yml defines a health check that verifies the discovery endpoint is accessible. Wait for the container to be healthy before running tests.
Testing¶
Use this setup for integration and E2E testing of the py-identity-model library against a real IdentityServer instance.