aboutsummaryrefslogtreecommitdiff
path: root/middleware/proxy/upstream_test.go
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2017-02-07 18:01:16 +0000
committerGravatar GitHub <noreply@github.com> 2017-02-07 18:01:16 +0000
commitdbe1b2510d609bf37b0874f0aafa91e982cdc5c2 (patch)
tree90762f068772ec41ca027c212227aa49a327f821 /middleware/proxy/upstream_test.go
parente8ebcd3cfddde935ba163e26cd035f902051044f (diff)
downloadcoredns-dbe1b2510d609bf37b0874f0aafa91e982cdc5c2.tar.gz
coredns-dbe1b2510d609bf37b0874f0aafa91e982cdc5c2.tar.zst
coredns-dbe1b2510d609bf37b0874f0aafa91e982cdc5c2.zip
middleware/proxy: fix except keyword (#505)
Fix the except keyword usage - the config would allow it, but it was not enforced in the code. Turns out that **FROM** was also not enforced, fix both, by (basically) copying the code from Caddy. Update the README and tests. Locally test as well, shows that this works: ~~~ .:1053 { proxy miek.nl 8.8.8.8:53 { except a.miek.nl } proxy a.miek.nl 8.8.4.4:53 errors stdout log stdout } ~~~ And gives the desired results, not having a proxy line for `a.miek.nl` results in a SERVFAIL (as expected). Fixes #502
Diffstat (limited to 'middleware/proxy/upstream_test.go')
-rw-r--r--middleware/proxy/upstream_test.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/middleware/proxy/upstream_test.go b/middleware/proxy/upstream_test.go
index 02099468c..6580a569a 100644
--- a/middleware/proxy/upstream_test.go
+++ b/middleware/proxy/upstream_test.go
@@ -13,7 +13,7 @@ import (
func TestHealthCheck(t *testing.T) {
upstream := &staticUpstream{
- from: "",
+ from: ".",
Hosts: testPool(),
Policy: &Random{},
Spray: nil,
@@ -31,7 +31,7 @@ func TestHealthCheck(t *testing.T) {
func TestSelect(t *testing.T) {
upstream := &staticUpstream{
- from: "",
+ from: ".",
Hosts: testPool()[:3],
Policy: &Random{},
FailTimeout: 10 * time.Second,
@@ -59,10 +59,10 @@ func TestRegisterPolicy(t *testing.T) {
}
-func TestAllowedPaths(t *testing.T) {
+func TestAllowedDomain(t *testing.T) {
upstream := &staticUpstream{
from: "miek.nl.",
- IgnoredSubDomains: []string{"download.", "static."}, // closing dot mandatory
+ IgnoredSubDomains: []string{"download.miek.nl.", "static.miek.nl."}, // closing dot mandatory
}
tests := []struct {
name string
@@ -75,7 +75,7 @@ func TestAllowedPaths(t *testing.T) {
}
for i, test := range tests {
- isAllowed := upstream.IsAllowedPath(test.name)
+ isAllowed := upstream.IsAllowedDomain(test.name)
if test.expected != isAllowed {
t.Errorf("Test %d: expected %v found %v for %s", i+1, test.expected, isAllowed, test.name)
}