Files
dbbackup/internal/tui/operations.go
Renz 0cf21cd893 feat: Complete MEDIUM priority security features with testing
- Implemented TUI auto-select for automated testing
- Fixed TUI automation: autoSelectMsg handling in Update()
- Auto-database selection in DatabaseSelector
- Created focused test suite (test_as_postgres.sh)
- Created retention policy test (test_retention.sh)
- All 10 security tests passing

Features validated:
 Backup retention policy (30 days, min backups)
 Rate limiting (exponential backoff)
 Privilege checks (root detection)
 Resource limit validation
 Path sanitization
 Checksum verification (SHA-256)
 Audit logging
 Secure permissions
 Configuration persistence
 TUI automation framework

Test results: 10/10 passed
Backup files created with .dump, .sha256, .info
Retention cleanup verified (old files removed)
2025-11-25 15:25:56 +00:00

58 lines
1.1 KiB
Go
Executable File

package tui
import (
"fmt"
"strings"
tea "github.com/charmbracelet/bubbletea"
"dbbackup/internal/config"
"dbbackup/internal/logger"
)
// OperationsViewModel shows active operations
type OperationsViewModel struct {
config *config.Config
logger logger.Logger
parent tea.Model
}
func NewOperationsView(cfg *config.Config, log logger.Logger, parent tea.Model) OperationsViewModel {
return OperationsViewModel{
config: cfg,
logger: log,
parent: parent,
}
}
func (m OperationsViewModel) Init() tea.Cmd {
return nil
}
func (m OperationsViewModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case tea.KeyMsg:
switch msg.String() {
case "ctrl+c", "q", "esc", "enter":
return m.parent, nil
}
}
return m, nil
}
func (m OperationsViewModel) View() string {
var s strings.Builder
header := titleStyle.Render("📊 Active Operations")
s.WriteString(fmt.Sprintf("\n%s\n\n", header))
s.WriteString("Currently running operations:\n\n")
s.WriteString(infoStyle.Render("📭 No active operations"))
s.WriteString("\n\n")
s.WriteString("⌨️ Press any key to return to menu\n")
return s.String()
}