hyprspace/dns/server_test.go
wanderer f1538eef4d
feat: make DNS TLD configurable (#124)
Add a 'domain' option to the NixOS module and JSON config that
controls the domain suffix used for internal DNS names. Defaults to
'hyprspace' for backward compatibility. Supports multi-label domains
(e.g. 'vpn.internal').

Co-authored-by: Max <max@privatevoid.net>
2026-06-22 17:48:14 +00:00

34 lines
896 B
Go

package dns
import (
"testing"
"github.com/hyprspace/hyprspace/config"
)
func TestDomainSuffix(t *testing.T) {
tests := []struct {
name string
iface string
domain string
want string
}{
{"default iface, default domain", "hyprspace", "hyprspace", "hyprspace."},
{"default iface, custom domain", "hyprspace", "vpn", "vpn."},
{"custom iface, default domain", "hs0", "hyprspace", "hs0.hyprspace."},
{"custom iface, custom domain", "hs0", "vpn", "hs0.vpn."},
{"multi-label domain", "hyprspace", "vpn.internal", "vpn.internal."},
{"custom iface, multi-label domain", "hs0", "vpn.internal", "hs0.vpn.internal."},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
cfg := config.Config{Interface: tt.iface, Domain: tt.domain}
got := domainSuffix(cfg)
if got != tt.want {
t.Errorf("domainSuffix() = %q, want %q", got, tt.want)
}
})
}
}