mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-09-11 14:00:29 +00:00
f5f440dbad
Name command transport explicitly in shared query results and preserve unobserved connection state in topology and Assistant inventory context. Keep parent-node transport distinct from a direct guest connection so monitoring evidence cannot imply command access or collection downtime. Existing execution policy and approval checks remain authoritative.
36 lines
1.4 KiB
Go
36 lines
1.4 KiB
Go
package chat
|
|
|
|
import (
|
|
"encoding/json"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/rcourtman/pulse-go-rewrite/internal/models"
|
|
"github.com/rcourtman/pulse-go-rewrite/internal/unifiedresources"
|
|
)
|
|
|
|
func TestAssistantInventoryDoesNotInventCommandConnectionObservations(t *testing.T) {
|
|
registry := unifiedresources.NewRegistry(nil)
|
|
registry.IngestSnapshot(models.StateSnapshot{
|
|
Nodes: []models.Node{{ID: "node-one", Name: "node-one", Status: "online"}},
|
|
DockerHosts: []models.DockerHost{{ID: "host-one", Hostname: "observed-host", Status: "online", Containers: []models.DockerContainer{{ID: "app-one", Name: "observed-app", State: "running"}}}},
|
|
})
|
|
raw, err := marshalAssistantInventoryTopologyContextFromReadState(registry)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
for _, field := range []string{"agent_connected", "command_agent_connected", "can_execute", "nodes_with_agents", "docker_hosts_with_agents", "nodes_with_command_agents", "docker_hosts_with_command_agents"} {
|
|
if strings.Contains(raw, `"`+field+`"`) {
|
|
t.Fatalf("inventory seed invented %s without observing command connections: %s", field, raw)
|
|
}
|
|
}
|
|
var decoded map[string]any
|
|
if err := json.Unmarshal([]byte(raw), &decoded); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
host := decoded["docker"].(map[string]any)["hosts"].([]any)[0].(map[string]any)
|
|
if host["hostname"] != "observed-host" || host["container_count"] != float64(1) {
|
|
t.Fatalf("monitoring inventory was lost: %+v", host)
|
|
}
|
|
}
|