fix e2e tests for garage v2 and uptimerobot v3 api changes

This commit is contained in:
2026-04-10 16:25:54 -04:00
parent f48ad0e21e
commit f093a66580
5 changed files with 111 additions and 65 deletions
+41 -5
View File
@@ -164,19 +164,55 @@ reconnects automatically.
## Testing
Tests live in `tests/` and run with pytest:
Tests live in `tests/` and run with [uv](https://docs.astral.sh/uv/):
```bash
# Install uv: curl -LsSf https://astral.sh/uv/install.sh | sh
uvx pytest tests/ -v
# Live site tests (security headers, TLS, default server)
uvx pytest tests/ -v --ignore=tests/test_app_e2e.py
# E2E tests for tools/app.sh (creates real resources)
uvx pytest tests/test_app_e2e.py -v -x
```
Tests auto-discover sites from `docker/nginx/conf.d/*.conf` — no list to
maintain when adding new sites.
### Live site tests
The `deploy-nginx.yml` workflow runs tests automatically after each nginx
These run against live sites and verify infrastructure invariants:
- **`test_security_headers.py`** — Checks that all sites including
`security-headers.inc` return the expected headers (HSTS, X-Frame-Options,
etc.). Sites are auto-discovered from `docker/nginx/conf.d/*.conf`.
- **`test_tls.py`** — Verifies TLS 1.3 and 1.2 work, TLS 1.1 is rejected.
- **`test_default_server.py`** — Verifies unknown Host headers get dropped
(connection reset) on both HTTP and HTTPS.
The `deploy-nginx.yml` workflow runs these automatically after each nginx
deploy. If tests fail, Gitea sends an email notification.
### E2E tests
`test_app_e2e.py` tests `tools/app.sh` against real services (Vultr, Gitea,
Garage, UptimeRobot). Uses `kgfamily.com` as a throwaway test domain.
**Prerequisites:**
- CLI tools: `bws`, `jq`, `dig`, `ssh`, `curl`, `git`
- `BWS_ACCESS_TOKEN` env var or token at `~/.config/hantim/bws-token`
- Vultr API key must allow requests from the machine's IP
(check https://my.vultr.com/settings/#settingsapi)
**Structure:**
1. **TestAppSubcommands** — Runs each `app.sh` subcommand individually
(dns, repo, files, cert, garage, build, monitor), verifies side effects
via API, then cleans up.
2. **TestAppAll** — Runs `app.sh all kgfamily.com`, verifies the full flow
including site liveness and git commit, then cleans up.
Cleanup runs before and after each phase via APIs (Vultr, Gitea, Garage,
UptimeRobot) + local file deletion. Does not use `remove-app.sh` to avoid
coupling.
## Secrets
### Bitwarden Secrets Manager