Introducing a new way to review your PRs.

Read the announcement

bunkerity / bunkerweb

🛡️ Open-source and cloud-native Web Application Firewall (WAF)

View on GitHub

19 documents · Updated Nov 23, 2026

docs / integration-test-scenarios

Integration test scenarios

Integration tests check BunkerWeb as a working product in realistic service environments. They start a fixture, apply a product setting or deployment mode, send real requests or UI actions, and then remove the fixture so the next scenario starts clean. The shared test flow is described in test orchestration, and this page focuses on the product scenarios it runs.

Scenario model

The test suite treats each scenario as a product example with a named fixture, setup data, expected checks, and a supported integration mode. The shared runner selects the mode, gives the scenario temporary test domains, runs its checks until they pass or time out, and cleans the scenario data afterward (tests/main.py• L22-33, tests/main.py• L56-80, tests/main.py• L82-155).

The core request checks use status codes, response text, and, where needed, the certificate name. This lets one scenario verify both the service path and the security result seen by a client (tests/Test.py• L98-201).

Core scenarios

Core scenarios verify security and traffic features through small application fixtures. Each fixture provides the upstream content or API behavior needed to make one product rule observable.

The scenarios cover the main product behaviors below:

Scenario groupProduct behavior verified
Access and identityWhitelists, blacklists, basic authentication, country and DNS checks, and client behavior rules
Request handlingRedirects, headers, CORS, caching, compression, limits, error responses, and request injection
Upstream trafficReverse proxying, Redis-backed state, WebSocket behavior, and upstream error handling
Security servicesAntibot, ModSecurity, bad-behavior controls, custom certificates, and certificate automation
OperationsBackups, database use, BunkerNet exchange, and command-line behavior

The antibot scenarios also check challenge expiry, URI preservation, bypass rules, and disabled protection. The CapJS case adds temporary Valkey and challenge-service fixtures so the test can verify a successful external challenge and the separate security policies for the widget frame and its parent page (tests/…/antibot.yml• L84-239, tests/…/antibot.yml• L269-303, tests/…/antibot.yml• L530-565).

The scenario scripts run a sequence of configuration states. They start with a baseline where a feature is off, enable one behavior, test it, and then restore the fixture. The Docker path checks service health before each request set, while the Linux path checks the system service and its logs (tests/…/test.sh• L77-197, tests/…/test.sh• L112-314).

UI scenarios

The UI scenarios verify that an operator can use the web console to manage and inspect BunkerWeb. They run browser actions against a stack that includes BunkerWeb, its scheduler, the UI, a database, and a small upstream application (tests/…/docker-compose.yml• L1-106).

The browser checks cover the operator-facing areas below:

UI areaProduct behavior verified
Setup and accountInitial setup and account operations
Services and instancesView and manage protected services and BunkerWeb instances
ConfigurationGlobal settings, service settings, plugins, and cache controls
OperationsJobs, logs, reports, bans, and related status views

The configuration scenario follows a complete operator flow. It creates and reads a global configuration, applies it to a service, verifies the resulting response, and then checks that deleting the service removes the related configuration and behavior (tests/…/configs.yml• L23-161).

The same UI checks can use a Docker stack or an installed Linux service. The harness waits for the setup page before opening a headless Firefox session, then the launcher returns the browser result and collects service logs when the run fails (tests/…/tests.sh• L3-19, tests/…/tests.sh• L43-72, tests/…/tests.sh• L74-155, tests/…/base.py• L19-62).

Linux scenarios

Linux scenarios verify the packaged product on supported operating systems rather than only in a service image. A distribution fixture builds or supplies the package, installs BunkerWeb and its scheduler, starts the system services, and then runs the same kind of request checks against that installed system (tests/LinuxTest.py• L11-102).

The Linux matrix includes Debian and Ubuntu releases plus Fedora and RHEL releases. The fixture also prepares PHP where the scenario needs it, so the test can check a common web workload across package families (tests/LinuxTest.py• L50-94, tests/…/Linux.sh• L18-88).

Scenario data is copied into the distribution fixture for each run. The test then restarts the services with the scenario configuration and removes its files and logs before the next scenario (tests/LinuxTest.py• L118-179).

Ansible scenarios

Ansible scenarios verify that a fresh remote host can become a usable test runner through the supported provisioning path. The playbooks wait for SSH, apply common host setup, install Docker where the scenario needs containers, and register a short-lived GitHub Actions runner (tests/ansible/docker_playbook#L1-L41, tests/ansible/linux_playbook#L1-L41).

The roles separate shared host preparation from the scenario-specific tool setup. Docker scenarios receive Docker Engine and Compose, while the Linux role provides the package publishing tools needed by the Linux flow (tests/…/main.yml• L1-4, tests/…/main.yml• L2-41, tests/…/main.yml• L2-11).

Terraform scenarios

Terraform scenarios provide the temporary remote machines on which the Ansible and integration checks run. The Linux scenario definition creates a named Scaleway server from a Debian image and writes a sensitive Ansible inventory with the assigned public address (tests/…/linux.tf• L1-39).

The environment flow links infrastructure, provisioning, and test execution. The create script initializes and applies the selected Terraform definition, runs the matching Ansible playbook when an inventory exists, and destroys the infrastructure on provisioning failure. The remove script destroys the saved Terraform environment after the run (tests/create.sh• L9-46, tests/rm.sh• L9-21).

This diagram shows how a remote fixture becomes a test host and then leaves no running test machine behind.

flowchart LR
    A[Terraform scenario] --> B[Temporary remote host]
    B --> C[Ansible provisioning]
    C --> D[Docker or Linux test environment]
    D --> E[Product checks]
    E --> F[Terraform destroy]

Fixture boundaries

Fixtures keep product checks close to real use while controlling the parts that must be stable. Docker scenarios use Compose services and networks, Linux scenarios use a system-service host, and UI scenarios add a database and browser client.

The shared lifecycle is:

  1. Prepare the host or containers.
  2. Load the scenario configuration and test data.
  3. Wait for the product to report readiness.
  4. Run client requests or browser actions.
  5. Collect logs on failure.
  6. Remove scenario state and temporary infrastructure.

Core Docker fixtures replace product images with test images and map scenario data into shared test storage. This makes the same product scenario run against the test build while keeping its upstream services and network shape intact (tests/DockerTest.py• L38-100). Linux fixtures instead copy the scenario into the installed host and restart the product services around it (tests/LinuxTest.py• L118-161).

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the integration names accepted by tests/main.py aligned with the test classes and the Terraform and Ansible entry points.
  • Keep fixture service names, health checks, and external network names aligned between each scenario's Compose files and its launcher.
  • Keep domain placeholders and generated test domains aligned with the request URLs and host mappings used by Docker and Linux fixtures.
  • Keep package distribution names aligned across package builders, Linux image definitions, and the Linux test matrix.
  • Keep UI setup readiness and browser host mappings aligned between tests/…/tests.sh, tests/…/base.py, and the UI Compose files.
  • Keep each Terraform inventory filename aligned with the matching create script and Ansible playbook.

Important failure modes

TriggerConsequenceGuard
A fixture does not report health or the Linux ready messageThe scenario stops before product checks runHealth polling has time limits and prints service or Compose logs (tests/…/tests.sh• L74-140, tests/…/test.sh• L124-189)
A placeholder domain or host mapping is staleRequests reach the wrong service or fail to match the intended scenarioThe runner generates domains and rewrites fixture data before startup (tests/main.py• L56-80, tests/DockerTest.py• L66-69)
Remote provisioning fails after Terraform applyA remote test host can remain allocatedThe create path destroys the Terraform environment on Ansible failure (tests/create.sh• L34-45)
A scenario leaves configuration or state behindA later scenario can pass or fail for the wrong reasonScenario cleanup removes Compose volumes or resets installed-service files and logs (tests/…/test.sh• L54-110, tests/LinuxTest.py• L163-179)
The package is built for a distribution not supported by the test matrixLinux validation cannot install or start the packageThe Linux test class rejects unknown distributions and maps package families to install commands (tests/LinuxTest.py• L15-45)

Key files

FileWhy to read it
tests/main.pyShows the supported integration modes and the shared scenario lifecycle
tests/Test.pyDefines the common request and certificate checks
tests/DockerTest.pyExplains how core fixtures run against test images
tests/LinuxTest.pyExplains installed-package checks inside distribution fixtures
tests/…/test.shIllustrates feature state changes, health checks, and cleanup
tests/…/test.shIllustrates multi-state traffic and upstream checks
tests/…/antibot.ymlShows challenge modes, bypass rules, expiry checks, and the external CapJS fixture
tests/…/configs.ymlShows operator configuration changes and their effect on a protected service
tests/…/tests.shShows Docker and Linux UI setup, readiness, execution, and cleanup
tests/…/docker-compose.ymlShows the UI product fixture and its database and upstream services
tests/…/base.pyShows how browser checks wait for the UI and start the client
tests/create.shConnects Terraform creation to Ansible provisioning
tests/rm.shRemoves the saved remote test environment
tests/…/linux.tfShows the remaining remote host shape for Linux scenarios
tests/ansible/docker_playbookShows Docker host provisioning and runner setup
tests/ansible/linux_playbookShows Linux host provisioning and runner setup