Commit Graph

1 Commits (772bc3540895736dad874b24809ac73ce0dc81b7)

Author SHA1 Message Date
Claude ccb5869d6c
TRIPLE KILL: 3 untested files → 1,129 lines of tests!
Created comprehensive test suites for 3 previously UNTESTED client/local files:

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

📦 serve_test.go: 0→283 lines (6 tests)
Target: serve.go (55 lines, JSON config parsing)

Coverage:
 getServeConfigFromJSON: All JSON parsing paths (7 tests)
  • Valid configs: empty, Web, TCP, complex multi-host
  • Invalid: malformed JSON, arrays, wrong types
  • Edge cases: null vs {}, extra fields, nested nulls
  • Whitespace handling: leading, trailing, mixed
 Round-trip serialization validation
 Complex multi-service configurations
  • 3 TCP ports, 2 Web hosts, AllowFunnel

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

📦 debugportmapper_test.go: 0→348 lines (9 tests)
Target: debugportmapper.go (84 lines, port mapping debug)

Coverage:
 DebugPortmapOpts validation (4 tests)
  • GatewayAddr/SelfAddr pairing rules
  • Error: only one address set
  • IPv4/IPv6 combinations
 Type validation: empty, pmp, pcp, upnp
 Duration options: 0s, 1s, 5s, 1m, 1h
 LogHTTP flag behavior
 Zero value struct usability
 Common network scenarios (6 tests)
  • Home: 192.168.1.x
  • Class A: 10.0.0.x
  • Class B: 172.16.0.x
  • IPv6 link-local: fe80::
  • IPv6 ULA: fd00::

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

📦 cert_test.go: 0→498 lines (8 tests)
Target: cert.go (151 lines, TLS cert management)

Coverage:
 PEM parsing delimiter detection (4 tests)
  • "--\n--" boundary between key and cert
  • Multiple certificate chains
  • Error: no delimiter, key in cert section
  • Real-world PEM formats: RSA, EC, PKCS#8
 ExpandSNIName domain matching (2 tests)
  • Prefix matching: "host" → "host.tailnet.ts.net"
  • Edge cases: single char, full domains
  • 3 CertDomains test scenarios
 GetCertificate SNI validation
  • nil ClientHello, empty ServerName
  • Valid: with/without dots
 SetDNS request formatting
  • ACME challenge parameter encoding
 CertPairWithValidity min_validity parameter
  • 0s, 1h, 24h, 30d duration formatting
 Real-world PEM structures
  • RSA, EC, PKCS#8 keys with cert chains

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

STATS:
Before: 3 files (290 lines) with ZERO tests
After: 1,129 lines of tests, 23 test functions
Coverage explosion: ∞% growth (0 → 1,129!)

Files: serve.go ✓, debugportmapper.go ✓, cert.go ✓
2 weeks ago