mirror of
https://github.com/alexhopeoconnor/dnsmasq-webui.git
synced 2026-10-04 04:18:13 +10:00
- Effective config: track value sources (ConfigValueSource, EffectiveConfigSources) and show readonly badges/tooltips for non-managed files. Multi-value options use ValueWithSource/PathWithSource for JSON. StatusClient uses camelCase serialization for reliable deserialization. - Parsing: align with dnsmasq (conf-file/conf-dir order, suffix filter, case- sensitive keys). DnsmasqConfIncludeParser and DnsmasqConfigSetService build effective config and sources. New DnsmasqConfigSetServiceTests. - UI: rename Overview/Home to Dnsmasq (page, nav, doc comments). Add EffectiveConfigOptionItem and EffectiveConfigMultiValueRow components. Dnsmasq.razor uses them; Hosts.razor shows addn-hosts with source. Encode server-derived strings in markup to avoid XSS. - Home section namespace: Components.Home -> Components.Dnsmasq (LogsSection, StatusSection, _Imports). - Test data: expand testdata (README, resolv.dnsmasq, hosts.extra, dnsmasq.d configs). dhcp.conf static IP aligned with testnet. - agents.md: add agent instructions for test harness and conventions.
81 lines
2.7 KiB
Markdown
81 lines
2.7 KiB
Markdown
# Agent instructions: dnsmasq-webui
|
|
|
|
## Test harness (Docker)
|
|
|
|
The test harness runs the app and dnsmasq in Docker with DHCP clients so you can test the UI and effective config against real dnsmasq.
|
|
|
|
**Script:** `scripts/prepare-test-mount.sh`
|
|
**Compose file:** `docker-compose.test.yml`
|
|
|
|
### Start the harness
|
|
|
|
From the repo root:
|
|
|
|
```bash
|
|
./scripts/prepare-test-mount.sh
|
|
```
|
|
|
|
This will:
|
|
|
|
1. Clear `testdata-mount/` (unless you pass `--no-clear`)
|
|
2. Sync `testdata/` → `testdata-mount/`
|
|
3. Remove any `*dnsmasq-webui*.conf` in the mount so dnsmasq starts clean
|
|
4. Run `docker compose -f docker-compose.test.yml up -d --build`
|
|
|
|
- **Quick restart (no image rebuild):** `./scripts/prepare-test-mount.sh --no-build`
|
|
- **Prepare mount only (no start):** `./scripts/prepare-test-mount.sh --prepare-only`
|
|
Then start manually: `TESTDATA_MOUNT=./testdata-mount docker compose -f docker-compose.test.yml up -d [--build]`
|
|
- **Preserve mount (e.g. keep leases):** `./scripts/prepare-test-mount.sh --no-clear --no-build`
|
|
|
|
App is at **http://localhost:8080**. Main config path in the container is `/data/dnsmasq-test.conf`; managed file is `zz-dnsmasq-webui.conf` in the same directory.
|
|
|
|
### Stop the harness
|
|
|
|
```bash
|
|
./scripts/prepare-test-mount.sh --stop
|
|
```
|
|
|
|
Runs `docker compose -f docker-compose.test.yml down` (stops and removes containers/networks). Does not change the mount directory.
|
|
|
|
### Clean (stop + clear mount)
|
|
|
|
```bash
|
|
./scripts/prepare-test-mount.sh --tidy
|
|
```
|
|
|
|
Stops the harness and deletes the contents of `testdata-mount/` so the next run starts from a clean sync of `testdata/`.
|
|
|
|
### Custom paths
|
|
|
|
- `--source DIR` — Source to sync from (default: `testdata`)
|
|
- `--mount DIR` — Mount directory (default: `testdata-mount`). The script exports `TESTDATA_MOUNT=./DIR` when you use `--mount`, so compose uses it.
|
|
|
|
Example: sync from a custom dir and start:
|
|
|
|
```bash
|
|
./scripts/prepare-test-mount.sh --source myfixtures --mount mymount
|
|
```
|
|
|
|
### Help
|
|
|
|
```bash
|
|
./scripts/prepare-test-mount.sh -h
|
|
```
|
|
|
|
## Unit tests
|
|
|
|
From the repo root:
|
|
|
|
```bash
|
|
dotnet test
|
|
```
|
|
|
|
Build only: `dotnet build`
|
|
|
|
## Test data
|
|
|
|
- **testdata/** — Source for the harness mount. Synced to `testdata-mount/` by `prepare-test-mount.sh`. Unit tests read from the copy in the test output dir. See **testdata/README** for the full layout.
|
|
- **testdata/dnsmasq-test.conf** — Harness main config (`/data/dnsmasq-test.conf`). Richer config: multiple `server=`, `addn-hosts=`, `address=`, `listen-address=`, `conf-dir=/data/dnsmasq.d`.
|
|
- **testdata/dnsmasq.d/** — Included configs (01-other.conf, 02-servers.conf, dhcp.conf). App creates `zz-dnsmasq-webui.conf` here when running.
|
|
- **testdata/hosts**, **testdata/hosts.extra** — Addn-hosts files so effective config has multiple addn-hosts; UI can show source per path.
|