Allow catalog-only zones without file= in --bind-conf mode
Zones without a file= property (e.g. ddns zones) are included in catalog zone output for secondaries but skipped in domains.conf. Previously --bind-conf required every zone to have file= set.
This commit is contained in:
28
main_test.go
28
main_test.go
@@ -482,7 +482,7 @@ zone.example.com catalog1, file=data/zones/example.com
|
||||
}
|
||||
}
|
||||
|
||||
func TestIntegrationCLIBindConfMissingFile(t *testing.T) {
|
||||
func TestIntegrationCLIBindConfCatalogOnlyZone(t *testing.T) {
|
||||
binary := filepath.Join(t.TempDir(), "catalog-zone-gen")
|
||||
cmd := exec.Command("go", "build", "-o", binary, ".")
|
||||
cmd.Dir = projectDir(t)
|
||||
@@ -502,7 +502,7 @@ soa:
|
||||
`
|
||||
writeTestFile(t, dir, "catz.yaml", configContent)
|
||||
|
||||
// Zone without file= property
|
||||
// Zone without file= property (catalog-only, e.g. ddns zone)
|
||||
inputContent := "zone.example.org catalog1\n"
|
||||
writeTestFile(t, dir, "zones.txt", inputContent)
|
||||
|
||||
@@ -514,8 +514,26 @@ soa:
|
||||
"--bind-conf", bindConfPath,
|
||||
filepath.Join(dir, "zones.txt"))
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err == nil {
|
||||
t.Fatal("expected error when file= is missing with --bind-conf")
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v\n%s", err, out)
|
||||
}
|
||||
assertContains(t, string(out), "missing file=")
|
||||
|
||||
// domains.conf should exist but not contain the catalog-only zone
|
||||
data, readErr := os.ReadFile(bindConfPath)
|
||||
if readErr != nil {
|
||||
t.Fatalf("failed to read domains.conf: %v", readErr)
|
||||
}
|
||||
got := string(data)
|
||||
assertContains(t, got, "# THIS FILE IS GENERATED BY catalog-zone-gen")
|
||||
if strings.Contains(got, "zone.example.org") {
|
||||
t.Error("catalog-only zone without file= should not appear in domains.conf")
|
||||
}
|
||||
|
||||
// Catalog zone should still be generated
|
||||
catZonePath := filepath.Join(dir, "catalog1.example.com.zone")
|
||||
catData, catErr := os.ReadFile(catZonePath)
|
||||
if catErr != nil {
|
||||
t.Fatalf("catalog zone not written: %v", catErr)
|
||||
}
|
||||
assertContains(t, string(catData), "zone.example.org")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user