refactor(api): use audit operation constants and the shared zone not found error in zone handlers
- refactor(api): use audit operation constants and the shared zone not found error in zone handlers - fix(api): return the stored content of rows with check errors - fix(api): return warnings from record deletes, zone creation and import apply - fix(api): allow repairing rows stored with a non canonical zone and invalid SOA sets - fix(check): accept JSON column formatting and an absent SOA serial as canonical content - fix(ui): match audit diff items by identity instead of array index - fix(ui): count the SOA change once, report import warnings and check the request size - fix(ui): edit the selected SOA row, keep the server order, show error rows raw and report write warnings - test(check): cover triggering and clean pairs with exact codes and record ids - test(records): cover SRV port, SOA timer and CAA value boundaries - test(cli): check the exact check output and the exit code of warning-only zones - refactor(import): order current rows with cmp.Compare - test(check): cover malformed stored content and a mailbox stored as an address - test(api): cover zone write failure paths, ambiguous SOA updates and unchanged record detection
This commit is contained in:
1 parent
53444bec7a
commit
a7ba01fc77
21 files changed
+1315
-170
No files matched your search
+39
@@ -1001,3 +1001,42 @@ func TestSQLUserBackend(t *testing.T) {
|
||||
t.Fatalf("%v rollbacks %d", err, state.rollbacks)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCheckCommandGolden(t *testing.T) {
|
||||
broken := append(cleanZoneRows("broken.test."),
|
||||
cliRecord(4, "broken.test.", "www", "A", nil, `{"ip":"192.0.2.7"}`),
|
||||
cliRecord(5, "broken.test.", "", "MX", 3600, `{"host":"ns1.broken.test.","priority":10}`),
|
||||
cliRecord(6, "broken.test.", "Mail", "A", 0, `{"ip":"192.0.2.8"}`),
|
||||
)
|
||||
warned := append(cleanZoneRows("warn.test."), cliRecord(9, "warn.test.", "text", "TXT", 3600, `{"text":"`+strings.Repeat("x", 256)+`"}`))
|
||||
b := &fakeReadBackend{
|
||||
zones: []zoneSummary{{Zone: "broken.test."}, {Zone: "warn.test."}},
|
||||
rows: map[string][]recordRow{"broken.test.": broken, "warn.test.": warned},
|
||||
}
|
||||
h := newCLIHarness(t, "")
|
||||
h.withReadBackend(b)
|
||||
if code := h.run("check"); code != 3 || h.stderr.Len() != 0 {
|
||||
t.Fatalf("exit %d, stderr %q", code, h.stderr.String())
|
||||
}
|
||||
want := "ZONE NAME TYPE ID SEVERITY PROBLEM\n" +
|
||||
"broken.test. www A 4 error ttl_null: stored TTL is NULL\n" +
|
||||
"broken.test. @ MX 5 error mx_priority_key: MX uses the preference key\n" +
|
||||
"broken.test. @ MX 5 error field_invalid: preference: is required\n" +
|
||||
"broken.test. Mail A 6 warning name_case: stored owner name contains uppercase letters\n" +
|
||||
"broken.test. Mail A 6 warning ttl_zero: TTL zero is served as 360 seconds\n" +
|
||||
"warn.test. text TXT 9 warning txt_split: TXT is served in strings of at most 255 bytes\n"
|
||||
if h.stdout.String() != want {
|
||||
t.Fatalf("output:\n%s\nwant:\n%s", h.stdout.String(), want)
|
||||
}
|
||||
|
||||
h = newCLIHarness(t, "")
|
||||
h.withReadBackend(b)
|
||||
if code := h.run("check", "warn.test"); code != 3 || h.stderr.Len() != 0 {
|
||||
t.Fatalf("warning-only zone: exit %d, stderr %q", code, h.stderr.String())
|
||||
}
|
||||
want = "ZONE NAME TYPE ID SEVERITY PROBLEM\n" +
|
||||
"warn.test. text TXT 9 warning txt_split: TXT is served in strings of at most 255 bytes\n"
|
||||
if h.stdout.String() != want {
|
||||
t.Fatalf("warning-only output:\n%s\nwant:\n%s", h.stdout.String(), want)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user