test(e2e): add isolated browser journey and cleanup supervision
Add a fake-only end-to-end stack, Firefox journey, and bounded process cleanup for normal, failed, and interrupted runs. Refs #12 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
39
backend/internal/server/bootstrap.go
Normal file
39
backend/internal/server/bootstrap.go
Normal file
@ -0,0 +1,39 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/tradarr/backend/internal/auth"
|
||||
"github.com/tradarr/backend/internal/config"
|
||||
"github.com/tradarr/backend/internal/models"
|
||||
"log"
|
||||
)
|
||||
|
||||
type AdminRepository interface {
|
||||
GetUserByEmail(string) (*models.User, error)
|
||||
CreateUser(string, string, models.Role) (*models.User, error)
|
||||
}
|
||||
|
||||
func EnsureAdmin(repo AdminRepository, cfg *config.Config) error {
|
||||
if cfg.AdminEmail == "" {
|
||||
return nil
|
||||
}
|
||||
existing, err := repo.GetUserByEmail(cfg.AdminEmail)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if existing != nil {
|
||||
return nil
|
||||
}
|
||||
if cfg.AdminPassword == "" {
|
||||
return fmt.Errorf("ADMIN_PASSWORD is required to create the bootstrap admin")
|
||||
}
|
||||
hash, err := auth.HashPassword(cfg.AdminPassword)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if _, err = repo.CreateUser(cfg.AdminEmail, hash, models.RoleAdmin); err != nil {
|
||||
return err
|
||||
}
|
||||
log.Printf("admin account created: %s", cfg.AdminEmail)
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user