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.

Cover RBAC mutation license gating

rcourtmane3179e49ac4c
diff --git a/internal/api/security_regression_test.go b/internal/api/security_regression_test.go
index ae1e0652d6..519c382dd5 100644
--- a/internal/api/security_regression_test.go
+++ b/internal/api/security_regression_test.go
@@ -2345,6 +2345,35 @@ func TestRBACEndpointsRequireLicenseFeature(t *testing.T) {
}
}
+func TestRBACMutationsRequireLicenseFeature(t *testing.T) {
+ rawToken := "rbac-license-mutation-token-123.12345678"
+ record := newTokenRecord(t, rawToken, []string{config.ScopeSettingsRead}, nil)
+ cfg := newTestConfigWithTokens(t, record)
+ router := NewRouter(cfg, nil, nil, nil, nil, "1.0.0")
+
+ cases := []struct {
+ method string
+ path string
+ body string
+ }{
+ {method: http.MethodPost, path: "/api/admin/roles", body: `{"id":"role-1","name":"Role 1"}`},
+ {method: http.MethodPut, path: "/api/admin/roles/role-1", body: `{"id":"role-1","name":"Role 1"}`},
+ {method: http.MethodDelete, path: "/api/admin/roles/role-1", body: ``},
+ {method: http.MethodPut, path: "/api/admin/users/alice/roles", body: `{"roleIds":["role-1"]}`},
+ {method: http.MethodPost, path: "/api/admin/users/alice/roles", body: `{"roleIds":["role-1"]}`},
+ }
+
+ for _, tc := range cases {
+ req := httptest.NewRequest(tc.method, tc.path, strings.NewReader(tc.body))
+ req.Header.Set("X-API-Token", rawToken)
+ rec := httptest.NewRecorder()
+ router.Handler().ServeHTTP(rec, req)
+ if rec.Code != http.StatusPaymentRequired {
+ t.Fatalf("expected 402 for missing RBAC license on %s %s, got %d", tc.method, tc.path, rec.Code)
+ }
+ }
+}
+
func TestAuditWebhookRequiresLicenseFeature(t *testing.T) {
rawToken := "audit-webhook-license-token-123.12345678"
record := newTokenRecord(t, rawToken, []string{config.ScopeSettingsRead}, nil)