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.

Add recovery endpoint regression test

rcourtmana73352a39600
diff --git a/internal/api/security_regression_test.go b/internal/api/security_regression_test.go
index 354a99e83c..a6759acb57 100644
--- a/internal/api/security_regression_test.go
+++ b/internal/api/security_regression_test.go
@@ -2505,3 +2505,17 @@ func TestValidateTokenRequiresSettingsWriteScope(t *testing.T) {
t.Fatalf("expected missing scope response to mention %q, got %q", config.ScopeSettingsWrite, rec.Body.String())
}
}
+
+func TestRecoveryEndpointRejectsRemoteWithoutToken(t *testing.T) {
+ cfg := newTestConfigWithTokens(t)
+ router := NewRouter(cfg, nil, nil, nil, nil, "1.0.0")
+
+ ResetRateLimitForIP("203.0.113.30")
+ req := httptest.NewRequest(http.MethodPost, "/api/security/recovery", strings.NewReader(`{"action":"status"}`))
+ req.RemoteAddr = "203.0.113.30:1234"
+ rec := httptest.NewRecorder()
+ router.Handler().ServeHTTP(rec, req)
+ if rec.Code != http.StatusForbidden {
+ t.Fatalf("expected 403 for remote recovery request, got %d", rec.Code)
+ }
+}