aboutsummaryrefslogtreecommitdiff
path: root/middleware/reverse/setup_test.go
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2017-02-10 12:48:51 +0000
committerGravatar GitHub <noreply@github.com> 2017-02-10 12:48:51 +0000
commit3e196a6d57eddfb7e05cd6747f85ba02ceeaa0d5 (patch)
tree1629d66a851ad043514bfd6be08f5b45d3c5196d /middleware/reverse/setup_test.go
parent87a39a63531f18359e64b63ba8c56b141b892ef7 (diff)
downloadcoredns-3e196a6d57eddfb7e05cd6747f85ba02ceeaa0d5.tar.gz
coredns-3e196a6d57eddfb7e05cd6747f85ba02ceeaa0d5.tar.zst
coredns-3e196a6d57eddfb7e05cd6747f85ba02ceeaa0d5.zip
middleware/reverse: random updates (#516)
* middleware/reverse: random updates Make the documentation somewhat shorter (and hopefully clearer in the process). Also to be on-par with the *auto* middleware, start counting the referenced zones from 1 (instead of 0). Some variable cleanups and use the NextOrFailure in the ServeDNS function. * More TODOs
Diffstat (limited to 'middleware/reverse/setup_test.go')
-rw-r--r--middleware/reverse/setup_test.go79
1 files changed, 39 insertions, 40 deletions
diff --git a/middleware/reverse/setup_test.go b/middleware/reverse/setup_test.go
index 4ec9e8a55..0a67d5cca 100644
--- a/middleware/reverse/setup_test.go
+++ b/middleware/reverse/setup_test.go
@@ -1,10 +1,10 @@
package reverse
import (
- "testing"
"net"
"reflect"
"regexp"
+ "testing"
"github.com/mholt/caddy"
)
@@ -19,7 +19,7 @@ func TestSetupParse(t *testing.T) {
regexIpv6dynamic, _ := regexp.Compile("^dynamic-" + regexMatchV6 + "-intern\\.dynamic\\.domain\\.com\\.$")
regexIpv4vpndynamic, _ := regexp.Compile("^dynamic-" + regexMatchV4 + "-vpn\\.dynamic\\.domain\\.com\\.$")
- serverBlockKeys := []string{"domain.com.:8053", "dynamic.domain.com.:8053" }
+ serverBlockKeys := []string{"domain.com.:8053", "dynamic.domain.com.:8053"}
tests := []struct {
inputFileRules string
@@ -31,12 +31,12 @@ func TestSetupParse(t *testing.T) {
`reverse fd01::/64`,
false,
networks{network{
- IPnet: net6,
- Template: "ip-{ip}.domain.com.",
- Zone: "domain.com.",
- TTL: 60,
+ IPnet: net6,
+ Template: "ip-{ip}.domain.com.",
+ Zone: "domain.com.",
+ TTL: 60,
RegexMatchIP: regexIP6,
- Fallthrough: false,
+ Fallthrough: false,
}},
},
{
@@ -98,52 +98,52 @@ func TestSetupParse(t *testing.T) {
},
{
`reverse fd01::/64 {
- hostname dynamic-{ip}-intern.{zone[1]}
+ hostname dynamic-{ip}-intern.{zone[2]}
ttl 50
}
reverse 10.1.1.0/24 {
- hostname dynamic-{ip}-vpn.{zone[1]}
+ hostname dynamic-{ip}-vpn.{zone[2]}
fallthrough
}`,
false,
networks{network{
- IPnet: net6,
- Template: "dynamic-{ip}-intern.dynamic.domain.com.",
- Zone: "dynamic.domain.com.",
- TTL: 50,
- RegexMatchIP:regexIpv6dynamic,
- Fallthrough: false,
+ IPnet: net6,
+ Template: "dynamic-{ip}-intern.dynamic.domain.com.",
+ Zone: "dynamic.domain.com.",
+ TTL: 50,
+ RegexMatchIP: regexIpv6dynamic,
+ Fallthrough: false,
}, network{
- IPnet: net4,
- Template: "dynamic-{ip}-vpn.dynamic.domain.com.",
- Zone: "dynamic.domain.com.",
- TTL: 60,
+ IPnet: net4,
+ Template: "dynamic-{ip}-vpn.dynamic.domain.com.",
+ Zone: "dynamic.domain.com.",
+ TTL: 60,
RegexMatchIP: regexIpv4vpndynamic,
- Fallthrough:true,
+ Fallthrough: true,
}},
},
{
// multiple networks in one stanza
`reverse fd01::/64 10.1.1.0/24 {
- hostname dynamic-{ip}-intern.{zone[1]}
+ hostname dynamic-{ip}-intern.{zone[2]}
ttl 50
fallthrough
}`,
false,
networks{network{
- IPnet: net6,
- Template: "dynamic-{ip}-intern.dynamic.domain.com.",
- Zone: "dynamic.domain.com.",
- TTL: 50,
- RegexMatchIP:regexIpv6dynamic,
- Fallthrough: true,
+ IPnet: net6,
+ Template: "dynamic-{ip}-intern.dynamic.domain.com.",
+ Zone: "dynamic.domain.com.",
+ TTL: 50,
+ RegexMatchIP: regexIpv6dynamic,
+ Fallthrough: true,
}, network{
- IPnet: net4,
- Template: "dynamic-{ip}-intern.dynamic.domain.com.",
- Zone: "dynamic.domain.com.",
- TTL: 50,
+ IPnet: net4,
+ Template: "dynamic-{ip}-intern.dynamic.domain.com.",
+ Zone: "dynamic.domain.com.",
+ TTL: 50,
RegexMatchIP: regexIpv4dynamic,
- Fallthrough: true,
+ Fallthrough: true,
}},
},
{
@@ -155,15 +155,14 @@ func TestSetupParse(t *testing.T) {
}`,
false,
networks{network{
- IPnet: net6,
- Template: "dynamic-{ip}-intern.dynamic.domain.com.",
- Zone: "dynamic.domain.com.",
- TTL: 300,
- RegexMatchIP:regexIpv6dynamic,
- Fallthrough: true,
+ IPnet: net6,
+ Template: "dynamic-{ip}-intern.dynamic.domain.com.",
+ Zone: "dynamic.domain.com.",
+ TTL: 300,
+ RegexMatchIP: regexIpv6dynamic,
+ Fallthrough: true,
}},
},
-
}
for i, test := range tests {
c := caddy.NewTestController("dns", test.inputFileRules)
@@ -183,4 +182,4 @@ func TestSetupParse(t *testing.T) {
}
}
}
-} \ No newline at end of file
+}