Files
felhom.eu/hub/internal/cloudflare/unblock_test.go
T

28 lines
907 B
Go

package cloudflare
import (
"reflect"
"testing"
)
// R-134: the hub's zone lookup must reach the zone for a name more than one label below it, as the
// controller's does. Stripping ONE label tried only [a.b.felhom.eu b.felhom.eu] and never felhom.eu,
// so the geo-unblock no-op'd with "no active zone found".
func TestZoneCandidates(t *testing.T) {
for _, tc := range []struct {
in string
want []string
}{
{"a.b.felhom.eu", []string{"a.b.felhom.eu", "b.felhom.eu", "felhom.eu"}},
{"demo.felhom.eu", []string{"demo.felhom.eu", "felhom.eu"}},
{"felhom.eu", []string{"felhom.eu"}},
{"x.y.z.example.co", []string{"x.y.z.example.co", "y.z.example.co", "z.example.co", "example.co"}},
{"", nil},
{"localhost", []string{"localhost"}},
} {
if got := zoneCandidates(tc.in); !reflect.DeepEqual(got, tc.want) {
t.Errorf("zoneCandidates(%q) = %v, want %v", tc.in, got, tc.want)
}
}
}