aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Lorenzo Fontana <fontanalorenz@gmail.com> 2018-07-21 19:06:13 +0200
committerGravatar Miek Gieben <miek@miek.nl> 2018-07-21 18:06:13 +0100
commit170e1d6b66d902d326539618896f0153f9349a23 (patch)
tree227748f5e9a0cd430c28aa34226d74bde8d00fd6
parentaba0b4e122e39f068941c4f75ed755082b4c109e (diff)
downloadcoredns-170e1d6b66d902d326539618896f0153f9349a23.tar.gz
coredns-170e1d6b66d902d326539618896f0153f9349a23.tar.zst
coredns-170e1d6b66d902d326539618896f0153f9349a23.zip
Test cases for address normalization with specified protocols (#1993)
Signed-off-by: Lorenzo Fontana <lo@linux.com>
-rw-r--r--core/dnsserver/address_test.go35
1 files changed, 34 insertions, 1 deletions
diff --git a/core/dnsserver/address_test.go b/core/dnsserver/address_test.go
index 137bc8e44..a83824f52 100644
--- a/core/dnsserver/address_test.go
+++ b/core/dnsserver/address_test.go
@@ -11,8 +11,23 @@ func TestNormalizeZone(t *testing.T) {
{".", "dns://.:53", false},
{".:54", "dns://.:54", false},
{"..", "://:", true},
- {"..", "://:", true},
{".:", "://:", true},
+ {"dns://.", "dns://.:53", false},
+ {"dns://.:5353", "dns://.:5353", false},
+ {"dns://..", "://:", true},
+ {"dns://.:", "://:", true},
+ {"tls://.", "tls://.:853", false},
+ {"tls://.:8953", "tls://.:8953", false},
+ {"tls://..", "://:", true},
+ {"tls://.:", "://:", true},
+ {"grpc://.", "grpc://.:443", false},
+ {"grpc://.:8443", "grpc://.:8443", false},
+ {"grpc://..", "://:", true},
+ {"grpc://.:", "://:", true},
+ {"https://.", "https://.:443", false},
+ {"https://.:8443", "https://.:8443", false},
+ {"https://..", "://:", true},
+ {"https://.:", "://:", true},
} {
addr, err := normalizeZone(test.input)
actual := addr.String()
@@ -177,3 +192,21 @@ func TestOverlapAddressChecker(t *testing.T) {
}
}
}
+
+func TestTransport(t *testing.T) {
+ for i, test := range []struct {
+ input string
+ expected string
+ }{
+ {"dns://.:53", TransportDNS},
+ {"2003::1/64.:53", TransportDNS},
+ {"grpc://example.org:1443 ", TransportGRPC},
+ {"tls://example.org ", TransportTLS},
+ {"https://example.org ", TransportHTTPS},
+ } {
+ actual := Transport(test.input)
+ if actual != test.expected {
+ t.Errorf("Test %d: Expected %s but got %s", i, test.expected, actual)
+ }
+ }
+}