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

+5 -5
View File
@@ -197,7 +197,7 @@ type cliHarness struct {
func newCLIHarness(t *testing.T, stdin string) *cliHarness {
h := &cliHarness{
env: map[string]string{
"DB_HOST": "db", "DB_USER": "u", "DB_PASSWORD": "dbpass-secret", "DB_NAME": "coredns", "LOG_LEVEL": "error",
"DB_HOST": "db", "DB_USER": "u", "DB_PASSWORD": "dbpass-secret", "DB_NAME": "coredns", "DB_WEBUI_NAME": "webui", "LOG_LEVEL": "error",
},
users: &fakeUsers{zones: map[int64]int64{}, sessions: map[int64]int64{}},
}
@@ -852,7 +852,7 @@ func TestSQLReadBackend(t *testing.T) {
t.Fatal(err)
}
q := state.Queries()
if len(q) != 3 || !strings.Contains(q[0], "GROUP BY") || !strings.Contains(q[1], "`coredns_records`") || !strings.Contains(q[2], "`coredns_webui_audit`") {
if len(q) != 3 || !strings.Contains(q[0], "GROUP BY") || !strings.Contains(q[1], "`coredns`.`coredns_records`") || !strings.Contains(q[2], "`webui`.`coredns_webui_audit`") {
t.Fatal(q)
}
}
@@ -962,9 +962,9 @@ func TestFormatCLITime(t *testing.T) {
func cliSQLHandler() fdbHandler {
return func(q string, args []any) fdbResponse {
switch {
case strings.HasPrefix(q, "INSERT INTO `coredns_webui_users`"):
case strings.HasPrefix(q, "INSERT INTO `webui`.`coredns_webui_users`"):
return fdbResponse{lastInsertID: 7}
case strings.HasPrefix(q, "INSERT INTO `coredns_webui_audit`"):
case strings.HasPrefix(q, "INSERT INTO `webui`.`coredns_webui_audit`"):
return fdbResponse{lastInsertID: 1}
case strings.Contains(q, "COUNT(*)"):
return fdbResponse{rows: [][]driver.Value{append(userValues(7, "alice", "admin", false), int64(0))}}
@@ -990,7 +990,7 @@ func TestSQLUserBackend(t *testing.T) {
t.Fatalf("commits %d", state.commits)
}
q := state.Queries()
if len(q) != 3 || !strings.HasPrefix(q[1], "INSERT INTO `coredns_webui_users`") || !strings.HasPrefix(q[2], "INSERT INTO `coredns_webui_audit`") {
if len(q) != 3 || !strings.HasPrefix(q[1], "INSERT INTO `webui`.`coredns_webui_users`") || !strings.HasPrefix(q[2], "INSERT INTO `webui`.`coredns_webui_audit`") {
t.Fatalf("queries %v", q)
}
audit := state.Calls()[2].args