From 51eb0f6d746b439d3a8a0d7d3952f98065751983 Mon Sep 17 00:00:00 2001 From: Roland Urbano Date: Mon, 18 May 2026 23:31:33 +0200 Subject: [PATCH] test(dns): add T22-T23 - domainSuffix and withDomainSuffix tests --- dns/dns_response_test.go | 43 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 dns/dns_response_test.go diff --git a/dns/dns_response_test.go b/dns/dns_response_test.go new file mode 100644 index 0000000..7009038 --- /dev/null +++ b/dns/dns_response_test.go @@ -0,0 +1,43 @@ +package dns + +import ( + "testing" + + "github.com/hyprspace/hyprspace/config" + "github.com/stretchr/testify/assert" +) + +func TestT22_domainSuffix_hyprspace(t *testing.T) { + cfg := config.Config{Interface: "hyprspace"} + assert.Equal(t, "hyprspace.", domainSuffix(cfg)) +} + +func TestT22_domainSuffix_custom(t *testing.T) { + cfg := config.Config{Interface: "hs0"} + assert.Equal(t, "hs0.hyprspace.", domainSuffix(cfg)) +} + +func TestT22_domainSuffix_other(t *testing.T) { + cfg := config.Config{Interface: "myvpn"} + assert.Equal(t, "myvpn.hyprspace.", domainSuffix(cfg)) +} + +func TestT22_domainSuffix_empty(t *testing.T) { + cfg := config.Config{Interface: ""} + assert.Equal(t, ".hyprspace.", domainSuffix(cfg)) +} + +func TestT23_withDomainSuffix(t *testing.T) { + cfg := config.Config{Interface: "hyprspace"} + assert.Equal(t, "alice.hyprspace.", withDomainSuffix(cfg, "alice")) +} + +func TestT23_withDomainSuffix_customInterface(t *testing.T) { + cfg := config.Config{Interface: "hs0"} + assert.Equal(t, "bob.hs0.hyprspace.", withDomainSuffix(cfg, "bob")) +} + +func TestT23_withDomainSuffix_servicePrefix(t *testing.T) { + cfg := config.Config{Interface: "hs0"} + assert.Equal(t, "http.alice.hs0.hyprspace.", withDomainSuffix(cfg, "http.alice")) +}