Render empty forwarders for forward zones
A forward zone with no forwarders now renders "forwarders { };", which
BIND accepts and treats as disabling forwarding for the zone.
This commit is contained in:
@@ -261,3 +261,19 @@ func TestRenderDeterministicWithShuffledForwards(t *testing.T) {
|
||||
t.Fatalf("render must be independent of forward-zone input order:\n--- A ---\n%s\n--- B ---\n%s", pa, pb)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRenderForwardZoneForwarders(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
fwd []string
|
||||
want string
|
||||
}{
|
||||
{nil, " forwarders { };\n"},
|
||||
{[]string{"198.18.19.15", "198.18.19.16;"}, " forwarders { 198.18.19.15; 198.18.19.16; };\n"},
|
||||
} {
|
||||
z := bindv1alpha1.BindZone{Spec: bindv1alpha1.BindZoneSpec{ZoneName: "spamhaus.org", Type: bindv1alpha1.ZoneForward, Forwarders: tc.fwd}}
|
||||
want := "zone \"spamhaus.org\" {\n type forward;\n forward only;\n" + tc.want + "};\n"
|
||||
if got := renderForwardZone(z, ""); got != want {
|
||||
t.Errorf("forwarders %v:\ngot %q\nwant %q", tc.fwd, got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user