feat: bootstrap console administrator

This commit is contained in:
2026-09-21 05:13:47 +08:00
parent 6af20c2cd4
commit 6a25a718c4
5 changed files with 147 additions and 10 deletions

View File

@@ -0,0 +1,35 @@
package mysql
import (
"context"
"strings"
"testing"
)
func TestBootstrapConsoleAdministratorRequiresUsernameAndPassword(t *testing.T) {
base := BootstrapInput{Application: "app", Namespace: "default", Environment: "test", Queue: "queue"}
for name, in := range map[string]BootstrapInput{
"username without password": func() BootstrapInput {
in := base
in.ConsoleUsername = "admin"
return in
}(),
"password without username": func() BootstrapInput {
in := base
in.ConsolePassword = "a sufficiently long password"
return in
}(),
"display name without account": func() BootstrapInput {
in := base
in.ConsoleDisplayName = "Orbit 管理员"
return in
}(),
} {
t.Run(name, func(t *testing.T) {
err := Bootstrap(context.Background(), nil, in, func(BootstrapResult) error { return nil })
if err == nil || !strings.Contains(err.Error(), "console username and password") {
t.Fatalf("expected console administrator validation error, got %v", err)
}
})
}
}