Local noconfirm + referrer test
Docs: docs/POSPRINT-URL.md.
Production blocks localhost referrers. For this harness set:
$env:POSPRINT_ALLOW_LOCAL_REFERRER = "1"
1. Start the verify server
python scripts/test-noconfirm/server.py
GET http://127.0.0.1:8765/verify?code=84923→ 200GET http://127.0.0.1:8765/verify?code=wrong→ 403
2. Build a debug posprint with the feature branch / master
cargo build
$env:POSPRINT_ALLOW_LOCAL_REFERRER = "1"
3. Open the test URL
Generate (from repo root):
cargo run --quiet -- link examples/noconfirm-demo.pos
Then append (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:
$refBad = [uri]::EscapeDataString("http://127.0.0.1:8765/verify?code=nope")
Start-Process "$base&noconfirm=1&referrer=$refBad"
Source
| 1 | # Local noconfirm + referrer test |
| 2 | |
| 3 | Docs: [docs/POSPRINT-URL.md](../../docs/POSPRINT-URL.md). |
| 4 | |
| 5 | Production blocks localhost referrers. For this harness set: |
| 6 | |
| 7 | ```powershell |
| 8 | $env:POSPRINT_ALLOW_LOCAL_REFERRER = "1" |
| 9 | ``` |
| 10 | |
| 11 | ## 1. Start the verify server |
| 12 | |
| 13 | ```powershell |
| 14 | python scripts/test-noconfirm/server.py |
| 15 | ``` |
| 16 | |
| 17 | - `GET http://127.0.0.1:8765/verify?code=84923` → **200** |
| 18 | - `GET http://127.0.0.1:8765/verify?code=wrong` → **403** |
| 19 | |
| 20 | ## 2. Build a debug posprint with the feature branch / master |
| 21 | |
| 22 | ```powershell |
| 23 | cargo build |
| 24 | $env:POSPRINT_ALLOW_LOCAL_REFERRER = "1" |
| 25 | ``` |
| 26 | |
| 27 | ## 3. Open the test URL |
| 28 | |
| 29 | Generate (from repo root): |
| 30 | |
| 31 | ```powershell |
| 32 | cargo run --quiet -- link examples/noconfirm-demo.pos |
| 33 | ``` |
| 34 | |
| 35 | Then append (PowerShell): |
| 36 | |
| 37 | ```powershell |
| 38 | $base = cargo run --quiet -- link examples/noconfirm-demo.pos |
| 39 | $ref = [uri]::EscapeDataString("http://127.0.0.1:8765/verify?code=84923") |
| 40 | $url = "$base&noconfirm=1&referrer=$ref" |
| 41 | $url |
| 42 | Start-Process $url |
| 43 | ``` |
| 44 | |
| 45 | 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). |
| 46 | |
| 47 | Try a bad code to confirm refusal: |
| 48 | |
| 49 | ```powershell |
| 50 | $refBad = [uri]::EscapeDataString("http://127.0.0.1:8765/verify?code=nope") |
| 51 | Start-Process "$base&noconfirm=1&referrer=$refBad" |
| 52 | ``` |