test: sweep example data in test files to RFC-5737 + placeholders

Mirrors the .md/.txt sweep across all tracked _test.go, testdata XML,
and .http integration files. Test files are self-contained (producer
+ assertion in the same file), so the matched-pair swap stays green
under `go test ./...`.

Mapping applied:
  192.168.178.[0-9]+   → 192.0.2.[same]
  192.168.1.[0-9]+     → 192.0.2.[same]
  Sound Machinechen    → Living Room SoundTouch
  A Sound Machine      → Kitchen SoundTouch
  A81B6A536A98 + case/separator variants → AABBCCDDEEFF (etc.)
  A81B6A849D99         → AABBCCDDEE01
  A81B6A849D88         → AABBCCDDEE03
  A81B6A536A09         → AABBCCDDEE04
  884AEAEEBD27         → AABBCCDDEE02
  3230304              → 1000001
  9569497              → 1000002

Two semantic fixes alongside the bulk swap:

- pkg/service/zeroconf/zeroconf_test.go: the "private 192" and
  "strips query" cases pin acceptance of RFC-1918 192.168/16. They
  must use a real 192.168 value; doc-range IPs would (correctly) be
  rejected by validateZcBaseURL. Switched to 192.168.10.10 — generic
  enough not to match any home LAN default, real enough for the
  validator. Added a comment explaining why this single test still
  carries a 192.168 literal.

- pkg/service/setup/setup_test.go: TestTestDNSRedirection mocks the
  device's `od -An -tu1` byte output, which is space-separated
  octets ("192 168 1 100"). My sed only matched the dot-separated
  form, so the mock was returning the old IP while the test
  assertions had moved to the doc range. Updated to " 192 0 2 100".

go build ./... clean. go test ./... clean (only TestDocsConsistency
remains failing, which is a pre-existing/untracked-file issue).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Tobias Gesellchen
2026-05-17 22:05:13 +02:00
co-authored by Claude Opus 4.7
parent 249c2586e9
commit feadc478d5
81 changed files with 739 additions and 734 deletions
+8 -3
View File
@@ -324,19 +324,24 @@ func TestValidateZcBaseURL(t *testing.T) {
}{
{"loopback", "http://127.0.0.1:8200/zc", true, "127.0.0.1:8200", "/zc"},
{"loopback no port", "http://127.0.0.1/zc", true, "127.0.0.1", "/zc"},
{"private 192", "http://192.168.1.10:8200/zc", true, "192.168.1.10:8200", "/zc"},
// The "private 192" and "strips query" cases must use an
// RFC-1918 192.168/16 value — validateZcBaseURL only accepts
// loopback, RFC-1918, and link-local. RFC-5737 doc IPs
// (which we use as placeholders elsewhere) would be rejected
// here, so the test uses a generic-but-real 192.168 value.
{"private 192", "http://192.168.10.10:8200/zc", true, "192.168.10.10:8200", "/zc"},
{"private 10", "http://10.0.0.5/zc", true, "10.0.0.5", "/zc"},
{"private 172", "http://172.16.0.1/zc", true, "172.16.0.1", "/zc"},
{"link-local v4", "http://169.254.10.20/zc", true, "169.254.10.20", "/zc"},
{"ipv6 loopback", "http://[::1]:8200/zc", true, "[::1]:8200", "/zc"},
{"ipv6 link-local", "http://[fe80::1]:8200/zc", true, "[fe80::1]:8200", "/zc"},
{"strips query", "http://192.168.1.10:8200/zc?foo=bar", true, "192.168.1.10:8200", "/zc"},
{"strips query", "http://192.168.10.10:8200/zc?foo=bar", true, "192.168.10.10:8200", "/zc"},
{"public IP rejected", "http://1.1.1.1/zc", false, "", ""},
{"public ipv6 rejected", "http://[2001:db8::1]/zc", false, "", ""},
{"hostname rejected", "http://myspeaker.local/zc", false, "", ""},
{"plain hostname rejected", "http://speaker/zc", false, "", ""},
{"ftp scheme rejected", "ftp://192.168.1.10/zc", false, "", ""},
{"ftp scheme rejected", "ftp://192.0.2.10/zc", false, "", ""},
{"file scheme rejected", "file:///etc/passwd", false, "", ""},
{"empty host rejected", "http:///zc", false, "", ""},
{"unparseable rejected", "::not a url::", false, "", ""},