This repository contains end-to-end tests for OAuth2 Proxy, verifying authentication flows with different identity providers like (Dex, Keycloak) or the integration with different environments and loadbalancers and mesh systems like nginx, traefik, istio, etc.
├── infra/ # Infra scripts and configuration files for more complex environments
│ ├── azure/ # Azure setup files
│ └── kind/ # Kind cluster spec files
├── internal/ # Shared test utilities and page objects
│ ├── pages/ # Page object models for test pages
│ └── utils/ # Test utilities (Playwright, Testcontainers)
├── tests/ # Test suites
│ ├── 01_smoke/ # Basic login flow test with dex
│ ├── 02_keycloak/ # Keycloak specific tests
│ └── 03_nginx/ # Nginx integration tests
│ └── 04_ingress-nginx/ # Ingress-Nginx integration tests
└── Makefile # Makefile for triggering setup and test cases
- Go 1.20+
- Docker
- Playwright browser dependencies
go run github.com/playwright-community/playwright-go/cmd/playwright@latest install --with-deps chromium
- Kind (for local Kubernetes testing)
- Helm (for Kubernetes dependencies)
# Run all tests
make test-all
# Run specific test suite
make test-01_smoke
make test-02_keycloak
# For debugging
cd tests/01_smoke/
./setup.sh up # Configure environment (docker-compose in this case)
# Run the test files with your favourite debugger and IDE
# After you are done. Don't forget to cleanup
./setup.sh down
Currently the e2e test suite is only triggered on demand by the maintainers of oauth2-proxy and can be triggered from within PRs in the upstream oauth2-proxy repository by writing comments.
If you are a maintainer / member of the oauth2-proxy organization, you can simple write a comment with the content /e2e
on any PR which will automatically trigger the necessary workflow from within the PR. Which builds a temporary version of oauth2-proxy using the contents of the PR, and execute the test cases against it. Furthermore it attaches a commit status and labels to the PR.
Commands | Description |
---|---|
/e2e |
Executes the tests from the main branch of the e2e test suite repository. |
/e2e <branch-name> |
Executes the tests from a custom branch of the e2e test suite repository. |
/e2e PR-<number> |
Executes the tests from an open PR of the e2e test suite repository. (Useful if new test cases are being added while an upstream PR is still open) |
- Keep test cases focused and independent.
- Use page object pattern for UI interactions whenever possible
- Include necessary setup scripts for new dependencies. Ensure they work locally, with a debugger and in the test workflow
Before starting to write a new test case. Try to identify if a test suite already exists.
- Consider what you are testing for: Provider specifics or environment integration?
- Check if we already have a test suite for the provider or integration
- Locate the corresponding test suite folder (tests/01_smoke, tests/02_keycloak or tests/03_nginx)
- Extend the page objects
internal/pages/
if needed - Create new test cases by adding new It() blocks in the existing test files and follow the established pattern of:
- Container setup
- Page interactions
- Assertions
- Create a new test suite:
- Make a new numbered folder in
tests/
(e.g.:99_myprovider
) - Copy the structure from existing suites:
compose.yaml / kustomize.yaml / values.yaml
- For setting up the provider and infrastructuresetup.sh
- Initialization script for starting and stopping the provider and infrastructureconfigs/
- OAuth2 Proxy configurations for test casese2e_test.go
- Test cases
- Make a new numbered folder in
- Implement provider-specific pages if necessary
- Implement your actual test flows and assertions