# Local noconfirm + referrer test

Docs: [docs/POSPRINT-URL.md](../../docs/POSPRINT-URL.md).

Production blocks localhost referrers. For this harness set:

```powershell
$env:POSPRINT_ALLOW_LOCAL_REFERRER = "1"
```

## 1. Start the verify server

```powershell
python scripts/test-noconfirm/server.py
```

- `GET http://127.0.0.1:8765/verify?code=84923` → **200**
- `GET http://127.0.0.1:8765/verify?code=wrong` → **403**

## 2. Build a debug posprint with the feature branch / master

```powershell
cargo build
$env:POSPRINT_ALLOW_LOCAL_REFERRER = "1"
```

## 3. Open the test URL

Generate (from repo root):

```powershell
cargo run --quiet -- link examples/noconfirm-demo.pos
```

Then append (PowerShell):

```powershell
$base = cargo run --quiet -- link examples/noconfirm-demo.pos
$ref = [uri]::EscapeDataString("http://127.0.0.1:8765/verify?code=84923")
$url = "$base&noconfirm=1&referrer=$ref"
$url
Start-Process $url
```

First run: trust dialog for `127.0.0.1`. After **Trust and print**, the next open with the same URL should print without asking (while the server still returns 200).

Try a bad code to confirm refusal:

```powershell
$refBad = [uri]::EscapeDataString("http://127.0.0.1:8765/verify?code=nope")
Start-Process "$base&noconfirm=1&referrer=$refBad"
```
