mirror of
https://github.com/anand34577/ferrum.git
synced 2026-09-12 05:48:58 +00:00
4dfeb9848e
- internal/events: in-process pub/sub bus; GET /api/v1/events SSE stream - internal/notify/webhooks.go: signed outgoing webhook dispatcher w/ retry + delivery log - internal/api/tags.go, search.go, bulk.go: cross-remote tag aggregation, global search, fleet-wide bulk guest actions - internal/auth/sessions.go: session listing/revocation (self-service + admin), extends the existing stateful session table - internal/poller/certificates.go: cert-expiry + connection-staleness alerting via the existing alert_rules pipeline - web: useEventStream hook, GlobalSearch + BulkOperationsPage (not yet wired into nav), SessionsCard on ProfilePage
39 lines
1.3 KiB
Go
39 lines
1.3 KiB
Go
package api
|
|
|
|
import "testing"
|
|
|
|
func TestBulkTargetValid(t *testing.T) {
|
|
cases := []struct {
|
|
name string
|
|
t bulkTarget
|
|
want bool
|
|
}{
|
|
{"valid qemu", bulkTarget{ConnID: "c1", Type: "qemu", Node: "pve-01", VMID: 100}, true},
|
|
{"valid lxc", bulkTarget{ConnID: "c1", Type: "lxc", Node: "pve-01", VMID: 100}, true},
|
|
{"missing connId", bulkTarget{Type: "qemu", Node: "pve-01", VMID: 100}, false},
|
|
{"missing node", bulkTarget{ConnID: "c1", Type: "qemu", VMID: 100}, false},
|
|
{"zero vmid", bulkTarget{ConnID: "c1", Type: "qemu", Node: "pve-01"}, false},
|
|
{"bad type", bulkTarget{ConnID: "c1", Type: "storage", Node: "pve-01", VMID: 100}, false},
|
|
}
|
|
for _, c := range cases {
|
|
t.Run(c.name, func(t *testing.T) {
|
|
if got := c.t.valid(); got != c.want {
|
|
t.Errorf("valid() = %v, want %v", got, c.want)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestBulkPowerActionsExcludesReset(t *testing.T) {
|
|
// The single-guest power endpoint (allowedPowerActions in inventory.go)
|
|
// includes "reset"; the bulk action set deliberately doesn't.
|
|
if bulkPowerActions["reset"] {
|
|
t.Error(`bulkPowerActions should not include "reset"`)
|
|
}
|
|
for _, a := range []string{"start", "stop", "shutdown", "reboot", "suspend", "resume"} {
|
|
if !bulkPowerActions[a] {
|
|
t.Errorf("bulkPowerActions missing %q", a)
|
|
}
|
|
}
|
|
}
|