fix: close record repair and verification gaps
This commit is contained in:
1 parent
9251c85fd8
commit
adff599e08
27 files changed
+787
-153
No files matched your search
@@ -370,3 +370,48 @@ func TestZoneAPIRepairBlockedByBrokenSOA(t *testing.T) {
|
||||
t.Fatalf("created id %s", id)
|
||||
}
|
||||
}
|
||||
|
||||
func TestZoneAPIRepairApexCNAMEBeforeSOA(t *testing.T) {
|
||||
for _, missing := range []bool{false, true} {
|
||||
name := "non-apex SOA"
|
||||
if missing {
|
||||
name = "missing SOA"
|
||||
}
|
||||
t.Run(name, func(t *testing.T) {
|
||||
rows := zoneAPITestRows(t)
|
||||
rows[0].Name = "below"
|
||||
if missing {
|
||||
rows = rows[1:]
|
||||
}
|
||||
cname := modelRawRow(5, "", "CNAME", 60, `{"host":"target.example.net."}`)
|
||||
f := zoneAPITestDBFor(t, append(slices.Clone(rows), cname))
|
||||
server, state := f.server()
|
||||
c := zoneAPITestRequest(server, f.actor, opRecordCreate, zoneAPITestName, "", "", zoneAPITestRecord)
|
||||
zoneAPITestStatus(t, t.Context(), c, 422)
|
||||
c = zoneAPITestRequest(server, f.actor, opRecordDelete, zoneAPITestName, "5", recordETag(cname), "")
|
||||
zoneAPITestStatus(t, t.Context(), c, 200)
|
||||
if state.commits != 1 || !c.auditDone || len(f.rows) != len(rows) {
|
||||
t.Fatalf("CNAME repair did not commit exactly once: rows %+v, audit %+v", f.rows, c.Entry)
|
||||
}
|
||||
if missing {
|
||||
zoneAPITestAuditIDs(t, c.Entry.Before, []int64{5})
|
||||
zoneAPITestAuditIDs(t, c.Entry.After, nil)
|
||||
c = zoneAPITestRequest(server, f.actor, opRecordCreate, zoneAPITestName, "", "", zoneAPITestSOARecord("@"))
|
||||
zoneAPITestStatus(t, t.Context(), c, 201)
|
||||
zoneAPITestSerialOf(t, zoneAPIFindSOA(f.rows), newSOASerial(modelNow))
|
||||
} else {
|
||||
zoneAPITestAuditIDs(t, c.Entry.Before, []int64{1, 5})
|
||||
zoneAPITestAuditIDs(t, c.Entry.After, []int64{1})
|
||||
zoneAPITestSerialOf(t, f.rows[0], newSOASerial(modelNow)+1)
|
||||
c = zoneAPITestRequest(server, f.actor, opSOAUpdate, zoneAPITestName, "", recordETag(f.rows[0]), zoneAPITestSOA)
|
||||
zoneAPITestStatus(t, t.Context(), c, 200)
|
||||
zoneAPITestSerialOf(t, f.rows[0], newSOASerial(modelNow)+2)
|
||||
}
|
||||
zoneAPITestPreserved(t, f, rows, 2, 3, 4)
|
||||
c = zoneAPITestRequest(server, f.actor, opZoneCheck, zoneAPITestName, "", "", "")
|
||||
if got := zoneAPITestJSON(t, zoneAPITestStatus(t, t.Context(), c, 200).Body); got != `{"problems":[]}` {
|
||||
t.Fatalf("zone after repair: %s", got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user