middleware/kubernetes: put reverse function in own file (#863)
Move reverse function and (some) test code to reverse*.go
This commit is contained in:
parent
be037a32a5
commit
df1879f9ae
4 changed files with 66 additions and 52 deletions
|
@ -2,7 +2,6 @@ package kubernetes
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"net"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
|
@ -33,33 +32,6 @@ func TestPrimaryZone(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestIsRequestInReverseRange(t *testing.T) {
|
||||
|
||||
tests := []struct {
|
||||
cidr string
|
||||
name string
|
||||
expected bool
|
||||
}{
|
||||
{"1.2.3.0/24", "4.3.2.1.in-addr.arpa.", true},
|
||||
{"1.2.3.0/24", "5.3.2.1.in-addr.arpa.", true},
|
||||
{"1.2.3.0/24", "5.4.2.1.in-addr.arpa.", false},
|
||||
{"5.6.0.0/16", "5.4.2.1.in-addr.arpa.", false},
|
||||
{"5.6.0.0/16", "5.4.6.5.in-addr.arpa.", true},
|
||||
{"5.6.0.0/16", "5.6.0.1.in-addr.arpa.", false},
|
||||
}
|
||||
|
||||
k := Kubernetes{Zones: []string{"inter.webs.test"}}
|
||||
|
||||
for _, test := range tests {
|
||||
_, cidr, _ := net.ParseCIDR(test.cidr)
|
||||
k.ReverseCidrs = []net.IPNet{*cidr}
|
||||
result := k.isRequestInReverseRange(test.name)
|
||||
if result != test.expected {
|
||||
t.Errorf("Expected '%v' for '%v' in %v.", test.expected, test.name, test.cidr)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsNameError(t *testing.T) {
|
||||
k := Kubernetes{Zones: []string{"inter.webs.test"}}
|
||||
if !k.IsNameError(errNoItems) {
|
||||
|
@ -77,7 +49,7 @@ func TestIsNameError(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestSymbolContainsWildcard(t *testing.T) {
|
||||
func TestWildcard(t *testing.T) {
|
||||
var tests = []struct {
|
||||
s string
|
||||
expected bool
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue