Support a separate database for Web UI tables

This commit is contained in:
bryanpedini committed 2026-11-21 20:36:03 +01:00
1 parent a2f8e59d9b
commit f464dc0af9
38 files changed
+880 -302

No files matched your search

+7 -7
View File
@@ -172,7 +172,7 @@ func matrixZoneCases() []matrixCase {
{name: "addressed zone of a refusal", op: opZoneCreate, method: "POST", path: "/zones", persona: "alice", body: mxCreateNew,
status: 403, msg: msgAdminRequired, zone: "new.org."},
{name: "record insert failure", op: opZoneCreate, method: "POST", path: "/zones", persona: "admin", body: mxCreateStale,
status: 500, msg: msgInternalError, zone: mxStale, setup: mxSQLFail(errMatrixInternal, "INSERT INTO `coredns_records`"),
status: 500, msg: msgInternalError, zone: mxStale, setup: mxSQLFail(errMatrixInternal, "INSERT INTO `coredns`.`coredns_records`"),
check: func(t *testing.T, env *matrixEnv, res webResult) {
mxUnchanged(t, env, res)
if !env.h.store.hasDelegation(mxStale, mxUserID("alice")) {
@@ -180,7 +180,7 @@ func matrixZoneCases() []matrixCase {
}
}},
{name: "change audit failure", op: opZoneCreate, method: "POST", path: "/zones", persona: "admin", body: mxCreateNew,
status: 500, msg: msgInternalError, zone: "new.org.", setup: mxSQLFail(errMatrixInternal, "INSERT INTO `coredns_webui_audit`"), check: mxUnchanged},
status: 500, msg: msgInternalError, zone: "new.org.", setup: mxSQLFail(errMatrixInternal, "INSERT INTO `webui`.`coredns_webui_audit`"), check: mxUnchanged},
{name: "zone busy", op: opZoneCreate, method: "POST", path: "/zones", persona: "admin", body: mxCreateNew,
status: 503, msg: msgZoneBusy, zone: "new.org.", setup: mxBusy},
{name: "connection failure", op: opZoneCreate, method: "POST", path: "/zones", persona: "admin", body: mxCreateNew,
@@ -217,7 +217,7 @@ func matrixZoneCases() []matrixCase {
{name: "confirmation mismatch", op: opZoneDelete, method: "DELETE", path: "/zones/example.org.", persona: "admin", body: `{"confirm":"other.org"}`,
status: 422, msg: "validation failed", zone: mxZone, check: mxUnchanged},
{name: "change audit failure", op: opZoneDelete, method: "DELETE", path: "/zones/example.org.", persona: "admin", body: `{"confirm":"example.org"}`,
status: 500, msg: msgInternalError, zone: mxZone, setup: mxSQLFail(errMatrixInternal, "INSERT INTO `coredns_webui_audit`"),
status: 500, msg: msgInternalError, zone: mxZone, setup: mxSQLFail(errMatrixInternal, "INSERT INTO `webui`.`coredns_webui_audit`"),
check: func(t *testing.T, env *matrixEnv, res webResult) {
mxUnchanged(t, env, res)
if !env.h.store.hasDelegation(mxZone, mxUserID("alice")) {
@@ -227,7 +227,7 @@ func matrixZoneCases() []matrixCase {
{name: "zone busy", op: opZoneDelete, method: "DELETE", path: "/zones/example.org.", persona: "admin", body: `{"confirm":"example.org"}`,
status: 503, msg: msgZoneBusy, zone: mxZone, setup: mxBusy, check: mxUnchanged},
{name: "connection failure", op: opZoneDelete, method: "DELETE", path: "/zones/example.org.", persona: "admin", body: `{"confirm":"example.org"}`,
status: 503, msg: msgDatabaseDown, zone: mxZone, setup: mxSQLFail(errMatrixNet, "DELETE FROM `coredns_records`"), check: mxUnchanged},
status: 503, msg: msgDatabaseDown, zone: mxZone, setup: mxSQLFail(errMatrixNet, "DELETE FROM `coredns`.`coredns_records`"), check: mxUnchanged},
{name: "admin", op: opZoneCheck, method: "GET", path: "/zones/example.org./check", persona: "admin", status: 200, zone: mxZone},
{name: "user", op: opZoneCheck, method: "GET", path: "/zones/example.org./check", persona: "alice", status: 200, zone: mxZone},
@@ -265,7 +265,7 @@ func matrixRecordCases() []matrixCase {
return []matrixCase{
{name: "change audit failure", op: op, method: method, path: path, persona: "admin", body: body, ifMatch: ifMatch,
status: 500, msg: msgInternalError, zone: mxZone, record: changed,
setup: mxSQLFail(errMatrixInternal, "INSERT INTO `coredns_webui_audit`"), check: mxUnchanged},
setup: mxSQLFail(errMatrixInternal, "INSERT INTO `webui`.`coredns_webui_audit`"), check: mxUnchanged},
{name: "zone busy", op: op, method: method, path: path, persona: "alice", body: body, ifMatch: ifMatch,
status: 503, msg: msgZoneBusy, zone: mxZone, record: record, setup: mxBusy, check: mxUnchanged},
{name: "connection failure", op: op, method: method, path: path, persona: "admin", body: body, ifMatch: ifMatch,
@@ -415,9 +415,9 @@ func matrixFileCases() []matrixCase {
body: strings.Replace(apply, "192.0.2.10", "not-an-address", 1), status: 422, msg: "the file has errors", zone: mxZone, check: mxUnchanged},
}
for _, c := range []matrixCase{
{name: "change audit failure", persona: "admin", status: 500, msg: msgInternalError, setup: mxSQLFail(errMatrixInternal, "INSERT INTO `coredns_webui_audit`")},
{name: "change audit failure", persona: "admin", status: 500, msg: msgInternalError, setup: mxSQLFail(errMatrixInternal, "INSERT INTO `webui`.`coredns_webui_audit`")},
{name: "zone busy", persona: "alice", status: 503, msg: msgZoneBusy, setup: mxBusy},
{name: "connection failure", persona: "admin", status: 503, msg: msgDatabaseDown, setup: mxSQLFail(errMatrixNet, "INSERT INTO `coredns_records`")},
{name: "connection failure", persona: "admin", status: 503, msg: msgDatabaseDown, setup: mxSQLFail(errMatrixNet, "INSERT INTO `coredns`.`coredns_records`")},
} {
c.op, c.method, c.path, c.body, c.zone, c.check = opZoneImport, "POST", "/zones/example.org./import/apply", apply, mxZone, mxUnchanged
cases = append(cases, c)