# TESTING.md — Pengujian Labs Pentest

## 1. Yang diuji CI (`.github/workflows/ci.yml`)

| Job | Isi | Gate |
|---|---|---|
| `python-lint` | `ruff check --select E9,F` (sintaks + pyflakes) atas `scripts/`, `tests/`, `scripts/advisory-sweep.py` | gagal bila ada temuan |
| `python-tests` | `pip install -r requirements.txt`, lalu `pytest tests/ -q` | 7 tes harus lolos |
| `shellcheck` | `shellcheck -S warning` atas 4 skrip `.sh` | gagal bila ada temuan |
| `static-checks` | `html-validate index.html` + `npm run validate` (gate P0 anti-slop + tag OG/Twitter) | gagal bila ada temuan |
| `advisory-sweep` | `scripts/advisory-sweep.py` — OSV batch atas 6 dependensi produksi di `requirements.txt` | HIGH/CRITICAL = gagal |
| `playwright-e2e` | landing di server lokal (desktop 1280px + mobile 390px): judul, marker, filter mode, redaksi klik-untuk-buka, tanpa overflow horizontal | gagal bila ada temuan |
| `smoke` | semua file deploy ada & tidak kosong | gagal bila ada yang hilang |

## 2. Tes smoke (`tests/test_smoke.py`, 7 tes)

Semua tes **tanpa target nyata** — hanya fixture sintetis + server
lokal `127.0.0.1`:

1. `test_js_secrets_finds_example_key` — bundle JS contoh berisi kunci
   contoh resmi AWS (`AKIAIOSFODNN7EXAMPLE`, bukan kunci asli) +
   endpoint `/api/v1/admin` → `js_secrets.py` menemukannya.
2. `test_jwt_probe_flags_none_alg` — token `alg=none` buatan lokal →
   `jwt_probe.py` menandainya.
3. `test_triage_synthetic_sample` — file biner contoh → `triage.py`
   menghasilkan JSON berisi `sha256`.
4. `test_geetest_gap_synthetic_images` — dua gambar sintetis (PIL)
   dengan kotak 40x40 di x=120 → `geetest_gap.py` mencetak `120`.
5. `test_headers_audit_localhost` — `headers_audit.py` ke
   `http.server` lokal → exit 0, ada baris `[FAIL]` (server polos
   memang tanpa CSP/HSTS — itu yang diharapkan).
6. `test_exposure_localhost` — `exposure.py` ke server lokal → exit 0.
7. `test_supply_audit_self_clean` — `supply_audit.py` atas repo sendiri
   → nol baris `[FAIL]` (dep terpin exact, tanpa install-script).

Plus di CI (bukan pytest): `--help` semua 25 skrip Python — tiap skrip
harus mencetak usage dan keluar 0.

## 3. Jalan lokal

```bash
python3 -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
pip install pytest ruff
ruff check --select E9,F scripts tests scripts/advisory-sweep.py
python3 -m pytest tests/ -q
python3 scripts/advisory-sweep.py
python3 scripts/blue/supply_audit.py .
```

Shellcheck + html-validate + Playwright hanya jalan penuh di CI
(butuh install via apt/npm; VM dev tidak menginstall tooling lokal).

## 4. Yang TIDAK diuji otomatis (dan kenapa)

- Serangan ke target nyata — dilarang oleh SCOPE.md; verifikasi
  manual hanya ke lab lokal / aset sendiri yang tercatat.
- `audio_solver.py` (butuh `GROQ_API_KEY` / model Whisper) dan
  `smb_audit.py` (butuh host SMB) — hanya `--help` di CI.
- Screenshot README + video demo — follow-up browser live
  (Chrome lokal tidak bisa start di VM ini); bukan gate merge.
