mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-07-09 16:00:59 +00:00
Adds positive MonitorDatasets/Pools/Replication booleans to TrueNASInstance and MonitorVMs/Hosts/Datastores to VMwareVCenterInstance, matching the PVE/PBS/PMG scope pattern. NewInstance defaults all surfaces to true; ApplyDefaults migrates legacy all-false records to all-true so existing truenas.json / vmware.json on disk continue monitoring after upgrade. The unified connections aggregator now reads those booleans into the Scope map and flips SupportsScope to true for both types, so the Scope UI in the ConnectionEditor is a straight wire-through to the native config fields — no new storage or adapter layer. Per-type API clients, form state, and the TrueNAS and VMware credential slots render the same three-checkbox "Collection scope" panel used by PVE/PBS/PMG, replacing the old per-type Stop-this-surface dialog end-to-end from the editor's side. Contracts updated: agent-lifecycle, api-contracts, storage-recovery. Tests: truenas.test.ts and vmware.test.ts round-trip the new monitor* flags through list + update payloads; config tests cover the legacy all-false ApplyDefaults migration; aggregator test asserts the scope map and SupportsScope: true for both types. Provider Refresh paths still fetch everything in one trip; honoring Monitor* inside VMware and TrueNAS pollers is deferred to a follow-up.
50 lines
1.6 KiB
Go
50 lines
1.6 KiB
Go
package config
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestVMwareNewInstanceDefaults(t *testing.T) {
|
|
inst := NewVMwareVCenterInstance()
|
|
require.NotEmpty(t, inst.ID)
|
|
require.Equal(t, defaultVMwarePort, inst.Port)
|
|
require.True(t, inst.Enabled)
|
|
require.True(t, inst.MonitorVMs)
|
|
require.True(t, inst.MonitorHosts)
|
|
require.True(t, inst.MonitorDatastores)
|
|
}
|
|
|
|
func TestVMwareApplyDefaultsLegacyScopeMigration(t *testing.T) {
|
|
// A record saved before Monitor* fields existed decodes with
|
|
// zero-value false across the board. ApplyDefaults must treat that
|
|
// as "never configured" and enable every surface so the upgrade
|
|
// doesn't silently stop collecting.
|
|
inst := VMwareVCenterInstance{}
|
|
inst.ApplyDefaults()
|
|
require.Equal(t, defaultVMwarePort, inst.Port)
|
|
require.True(t, inst.MonitorVMs)
|
|
require.True(t, inst.MonitorHosts)
|
|
require.True(t, inst.MonitorDatastores)
|
|
}
|
|
|
|
func TestVMwareApplyDefaultsPreservesExplicitScope(t *testing.T) {
|
|
inst := VMwareVCenterInstance{MonitorVMs: true, MonitorHosts: false, MonitorDatastores: false}
|
|
inst.ApplyDefaults()
|
|
require.True(t, inst.MonitorVMs)
|
|
require.False(t, inst.MonitorHosts)
|
|
require.False(t, inst.MonitorDatastores)
|
|
}
|
|
|
|
func TestVMwareRedactedPreservesMonitorFields(t *testing.T) {
|
|
inst := VMwareVCenterInstance{
|
|
Name: "vc", Host: "vc.lan", Password: "secret",
|
|
MonitorVMs: true, MonitorHosts: false, MonitorDatastores: true,
|
|
}
|
|
redacted := inst.Redacted()
|
|
require.Equal(t, vmwareSensitiveMask, redacted.Password)
|
|
require.True(t, redacted.MonitorVMs)
|
|
require.False(t, redacted.MonitorHosts)
|
|
require.True(t, redacted.MonitorDatastores)
|
|
}
|