test(ui): avoid a literal em dash in the em dash check
- test(ui): avoid a literal em dash in the em dash check - fix(cli): accept any positive int64 audit count and share the last active admin rule - fix(api): limit audit before_id to 2^53-1 - fix(api): audit unmatched api requests, bound every request body and record audit write failures - fix(ui): recheck the account in the login transaction and require existing zones on zone pages - fix(api): recheck the acting admin and the stored password hash in change transactions - fix(db): keep committed outcomes on lock release failure, narrow the records contract and trace sql statements - fix(db): make the initial migration restartable and verify the application schema - fix(auth): never move last_seen_at backwards on concurrent session touches - test(api): cover lock release failure after commit and handler tracing without secrets - fix(test): redact credentials from mysql setup errors - fix(audit): retain addressed objects on admin refusals - test(db): cover migration restarts and records contract ranges in mysql - test(api): verify account races and audit rollback in mysql - fix(auth): reject password changes after account deletion - docs: document unknown api audit entries - fix(audit): bound failure retries and redact sensitive sql parameters - fix(test): isolate docker resources and cover image cli commands - test(auth): expect unauthorized after an account deletion race - fix(db): verify application column widths and foreign keys
This commit is contained in:
1 parent
5f17aab6ca
commit
53444bec7a
40 files changed
+2332
-254
No files matched your search
@@ -115,13 +115,13 @@ func newITDatabase(t *testing.T, opts itOptions) *itDatabase {
|
||||
}
|
||||
admin := srv.open(t, "root", srv.rootPassword, "")
|
||||
ctx := context.Background()
|
||||
exec := func(q string, args ...any) {
|
||||
exec := func(operation, query string) {
|
||||
t.Helper()
|
||||
if _, err := admin.ExecContext(ctx, q, args...); err != nil {
|
||||
t.Fatalf("%s: %v", q, err)
|
||||
if err := itExecSetup(ctx, admin, operation, query); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
exec("CREATE DATABASE `" + d.name + "` DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci")
|
||||
exec("create database", "CREATE DATABASE `"+d.name+"` DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci")
|
||||
t.Cleanup(func() {
|
||||
_, _ = admin.ExecContext(ctx, "DROP DATABASE IF EXISTS `"+d.name+"`")
|
||||
_, _ = admin.ExecContext(ctx, "DROP USER IF EXISTS '"+d.appUser+"'@'%'")
|
||||
@@ -132,23 +132,42 @@ func newITDatabase(t *testing.T, opts itOptions) *itDatabase {
|
||||
if ddl == "" {
|
||||
ddl = itRecordsDDL
|
||||
}
|
||||
exec(fmt.Sprintf(ddl, d.name, d.prefix))
|
||||
exec("create records table", fmt.Sprintf(ddl, d.name, d.prefix))
|
||||
}
|
||||
exec("CREATE USER '" + d.appUser + "'@'%' IDENTIFIED BY '" + d.appPassword + "'")
|
||||
exec("CREATE USER '" + d.dnsUser + "'@'%' IDENTIFIED BY '" + d.dnsPassword + "'")
|
||||
exec("create application user", "CREATE USER '"+d.appUser+"'@'%' IDENTIFIED BY '"+d.appPassword+"'")
|
||||
exec("create dns user", "CREATE USER '"+d.dnsUser+"'@'%' IDENTIFIED BY '"+d.dnsPassword+"'")
|
||||
for _, g := range itAppGrants {
|
||||
if !g.create && opts.noRecords {
|
||||
continue
|
||||
}
|
||||
exec(fmt.Sprintf("GRANT %s ON `%s`.`%s%s` TO '%s'@'%%'", g.privs, d.name, d.prefix, g.table, d.appUser))
|
||||
exec("grant application privileges on "+g.table, fmt.Sprintf("GRANT %s ON `%s`.`%s%s` TO '%s'@'%%'", g.privs, d.name, d.prefix, g.table, d.appUser))
|
||||
}
|
||||
if !opts.noRecords {
|
||||
exec(fmt.Sprintf("GRANT SELECT ON `%s`.`%srecords` TO '%s'@'%%'", d.name, d.prefix, d.dnsUser))
|
||||
exec("grant dns read privileges", fmt.Sprintf("GRANT SELECT ON `%s`.`%srecords` TO '%s'@'%%'", d.name, d.prefix, d.dnsUser))
|
||||
}
|
||||
d.root = srv.open(t, "root", srv.rootPassword, d.name)
|
||||
return d
|
||||
}
|
||||
|
||||
func itExecSetup(ctx context.Context, db dbtx, operation, query string) error {
|
||||
if _, err := db.ExecContext(ctx, query); err != nil {
|
||||
if n := mysqlErrNumber(err); n != 0 {
|
||||
return fmt.Errorf("%s: mysql error %d", operation, n)
|
||||
}
|
||||
return fmt.Errorf("%s: database error (%T)", operation, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func TestIntegrationSetupErrorRedactsSQL(t *testing.T) {
|
||||
const sentinel = "setup-password-sentinel"
|
||||
db := newITDatabase(t, itOptions{noRecords: true})
|
||||
err := itExecSetup(t.Context(), db.root, "create test user", "CREATE USER IDENTIFIED BY '"+sentinel+"'")
|
||||
if err == nil || strings.Contains(err.Error(), sentinel) || err.Error() != "create test user: mysql error 1064" {
|
||||
t.Fatalf("unexpected setup diagnostic: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func (d *itDatabase) env() map[string]string {
|
||||
return map[string]string{
|
||||
"DB_HOST": d.server.host,
|
||||
|
||||
Reference in new issue
Block a user