This project provides a modular system for centralized configuration management and robust integration testing of authentication and related services. Built with NestJS, it supports flexible service orchestration, database setup, and mock HTTP/LDAP services for comprehensive test automation.
- Centralized settings management for test environments
- Integration and unit testing for authentication flows
- Mock services (HTTP, LDAP) for isolated testing
- Database orchestration using Docker and Postgres
- Validation and transformation utilities
- Extensible architecture for adding new services and test scenarios
├── src/
│ ├── app.module.ts # Main NestJS application module
│ ├── main.ts # Application entry point
│ ├── auth/ # Authentication module (controller, service, entities, DTOs)
│ ├── common/ # Shared decorators, transformers, and utilities
│ ├── orm/ # ORM module and configuration
│ └── settings/ # Settings management module
│
├── test/
│ ├── integration/ # Integration tests (e.g., auth.integration.spec.ts)
│ ├── e2e/ # End-to-end tests
│ ├── auth/ # Unit tests for auth module
│ ├── examples/ # Example test scenarios
│ ├── setup/ # Test environment setup, factories, and utilities
│ └── sql/ # SQL scripts for test DB
│
├── Dockerfile # Docker setup for test environments
├── docker-compose.yml # Compose file for orchestrating services
├── package.json # Project dependencies and scripts
├── tsconfig.json # TypeScript configuration
└── README.md # Project documentation
npm installnpm start- All tests (with Docker):
npm test - Unit tests only:
npx jest --config jest.unit.config.js
npm run formatSettings are loaded from a configuration file (JSON/YAML) or generated with defaults. The system supports validation and dynamic injection into test environments.
{
"db": {
"type": "postgres",
"dbType": "postgres",
"version": "15",
"user": "postgres",
"password": "password",
"database": "testdb"
},
"auth": {
"type": "http-mock",
"defaultPort": 3001,
"strictPort": false
},
"ldap": {
"type": "ldap",
"defaultPort": 389,
"baseDN": "dc=test,dc=com"
}
}import { loadSettings, getSettings } from '../setup/settings';
await loadSettings();
const settings = getSettings();Integration tests are located in test/integration/ and use Docker to spin up real or mock services. Example: auth.integration.spec.ts tests authentication flows, user creation, validation, and concurrent requests.
- Test setup and teardown are managed via
test/setup/utilities. - Factories for database, HTTP mocks, and LDAP are provided in
test/setup/factories/. - Example test scenarios are in
test/examples/.
- src/auth/: Authentication logic (controller, service, repository, DTOs, entities)
- src/settings/: Settings loader, entities, and validation
- src/common/: Decorators, transformers, and shared utilities
- test/setup/: Test environment management, factories, and helpers
npm start— Run the applicationnpm test— Run all tests (integration + unit)npm run format— Format code with Prettier
See test/examples/usage-example.spec.ts and test/integration/auth.integration.spec.ts for real-world usage and integration scenarios.
Pull requests and issues are welcome! Please ensure code is formatted and tests are passing before submitting.
MIT