Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Keep CORE memory probes separate from REST fixture authentication

pulse-triage[bot]3d7cbfe6560f
diff --git a/internal/monitoring/truenas_pool_capacity_test.go b/internal/monitoring/truenas_pool_capacity_test.go
index 6668329d38..63d59bb52f 100644
--- a/internal/monitoring/truenas_pool_capacity_test.go
+++ b/internal/monitoring/truenas_pool_capacity_test.go
@@ -10,6 +10,7 @@ import (
"testing"
"time"
+ "github.com/gorilla/websocket"
"github.com/rcourtman/pulse-go-rewrite/internal/mock"
"github.com/rcourtman/pulse-go-rewrite/internal/models"
"github.com/rcourtman/pulse-go-rewrite/internal/truenas"
@@ -42,6 +43,7 @@ func TestTrueNASPoolCapacityCollectionHistory(t *testing.T) {
var cycle atomic.Int32
var poolReads atomic.Int32
+ var memoryProbes atomic.Int32
fields := []string{
`,"size":1000,"allocated":400,"free":600`,
`,"size":1000`, // Must not refresh the last reading as zero.
@@ -53,6 +55,21 @@ func TestTrueNASPoolCapacityCollectionHistory(t *testing.T) {
http.NotFound(w, r)
return
}
+ if r.URL.Path == "/websocket" {
+ // This REST-only fixture has no optional CORE memory stream. DDP
+ // authenticates after upgrading, not with a REST bearer header.
+ // Its absence must not bypass any REST credential assertion or
+ // prevent independent pool collection and History below.
+ memoryProbes.Add(1)
+ if r.Method != http.MethodGet || !websocket.IsWebSocketUpgrade(r) {
+ t.Error("CORE memory probe did not request a WebSocket upgrade")
+ }
+ if r.Header.Get("Authorization") != "" {
+ t.Error("REST credentials sent to an unsupported CORE memory endpoint")
+ }
+ http.NotFound(w, r)
+ return
+ }
if r.Header.Get("Authorization") != "Bearer synthetic-a" && r.Header.Get("Authorization") != "Bearer synthetic-b" {
t.Error("collection lost its connection authentication")
w.WriteHeader(http.StatusUnauthorized)
@@ -147,6 +164,9 @@ func TestTrueNASPoolCapacityCollectionHistory(t *testing.T) {
if poolReads.Load() != 8 || len(targets) != 2 {
t.Fatalf("reads=%d independent pool identities=%d", poolReads.Load(), len(targets))
}
+ if memoryProbes.Load() != 8 {
+ t.Fatalf("CORE memory probes=%d, want one per connection and collection", memoryProbes.Load())
+ }
persistent.Flush()
for _, resource := range adapter.GetAll() {
if resource.Storage == nil {