From ebe3ecdf8f1402ced03a8cb63318962544ecb2a8 Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Sun, 7 May 2023 09:27:41 -0400 Subject: [PATCH] CHORE: Move NS test to its own function (#2318) Co-authored-by: Tom Limoncelli --- go.mod | 3 +-- integrationTest/integration_test.go | 38 +++++++++++++++++++++++------ 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/go.mod b/go.mod index d1de8d926..b862b7834 100644 --- a/go.mod +++ b/go.mod @@ -2,8 +2,6 @@ module github.com/StackExchange/dnscontrol/v3 go 1.18 -require gopkg.in/yaml.v3 v3.0.1 - require ( github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns v1.1.0 @@ -67,6 +65,7 @@ require ( github.com/vultr/govultr/v2 v2.17.2 golang.org/x/exp v0.0.0-20230425010034-47ecfdc1ba53 golang.org/x/text v0.9.0 + gopkg.in/yaml.v3 v3.0.1 ) require ( diff --git a/integrationTest/integration_test.go b/integrationTest/integration_test.go index 8aa69543b..2e4df4c4c 100644 --- a/integrationTest/integration_test.go +++ b/integrationTest/integration_test.go @@ -319,14 +319,6 @@ func runTests(t *testing.T, prv providers.DNSServiceProvider, domainName string, } - // Issue https://github.com/StackExchange/dnscontrol/issues/491 - t.Run("No trailing dot in nameserver", func(t *testing.T) { - for _, nameserver := range dc.Nameservers { - if strings.HasSuffix(nameserver.Name, ".") { - t.Errorf("Provider returned nameserver with trailing dot: %s (See issue https://github.com/StackExchange/dnscontrol/issues/491, TL;DR: use models.ToNameserversStripTD in GetNameservers)", nameserver) - } - } - }) } func TestDualProviders(t *testing.T) { @@ -381,6 +373,36 @@ func TestDualProviders(t *testing.T) { } } +func TestNameserverDots(t *testing.T) { + // Issue https://github.com/StackExchange/dnscontrol/issues/491 + // If this fails, the provider's GetNameservers() function uses + // models.ToNameserversStripTD() instead of models.ToNameservers() + // or vise-versa. + + // Setup: + p, domain, _, _ := getProvider(t) + if p == nil { + return + } + if domain == "" { + t.Fatal("NO DOMAIN SET! Exiting!") + } + dc := getDomainConfigWithNameservers(t, p, domain) + if !providers.ProviderHasCapability(*providerToRun, providers.DocDualHost) { + t.Skip("Skipping. DocDualHost == Cannot") + return + } + + t.Run("No trailing dot in nameserver", func(t *testing.T) { + for _, nameserver := range dc.Nameservers { + //fmt.Printf("DEBUG: nameserver.Name = %q\n", nameserver.Name) + if strings.HasSuffix(nameserver.Name, ".") { + t.Errorf("Provider returned nameserver with trailing dot: %q", nameserver) + } + } + }) +} + type TestGroup struct { Desc string required []providers.Capability