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.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Add self-hosted commercial continuity proof
rcourtmanda2537e4ab9e
diff --git a/frontend-modern/src/components/Settings/__tests__/ProLicensePanel.test.tsx b/frontend-modern/src/components/Settings/__tests__/ProLicensePanel.test.tsxindex 8aeaf33c19..e4e4813357 100644--- a/frontend-modern/src/components/Settings/__tests__/ProLicensePanel.test.tsx+++ b/frontend-modern/src/components/Settings/__tests__/ProLicensePanel.test.tsx@@ -888,6 +888,32 @@ describe('ProLicensePanel', () => {expect(screen.queryByRole('link', { name: 'Review plan' })).not.toBeInTheDocument();});+ it('does not treat checkout return parameters as entitlement truth', async () => {+ useLocationMock.mockReturnValue({+ search: `?purchase=${SELF_HOSTED_PRO_BILLING_PURCHASE_ACTIVATED}&intent=${SELF_HOSTED_PRO_BILLING_PLAN_SELECTION_INTENT}`,+ pathname: '/settings/system/billing/plan',+ hash: '',+ });++ renderPanel();++ await waitFor(() => {+ expect(loadLicenseEntitlementsMock).toHaveBeenCalled();+ });++ expect(screen.queryByText('Pulse Pro is now active')).not.toBeInTheDocument();+ expect(+ screen.queryByText(/Checkout completed and this instance is now running Pulse Pro/i),+ ).not.toBeInTheDocument();+ expect(screen.getByText('Current plan: Community')).toBeInTheDocument();+ expect(screen.queryByText('Safe Remediation Workflows')).not.toBeInTheDocument();+ expect(screen.queryByText('Available now on this instance')).not.toBeInTheDocument();+ expect(navigateMock).toHaveBeenCalledWith(SELF_HOSTED_PRO_BILLING_PLAN_HREF, {+ replace: true,+ scroll: false,+ });+ });+it('opens recovery by default when the billing route requests the recovery detail', async () => {useLocationMock.mockReturnValue({search: '?details=recovery',diff --git a/internal/api/contract_test.go b/internal/api/contract_test.goindex dd897b3415..eb3297f35b 100644--- a/internal/api/contract_test.go+++ b/internal/api/contract_test.go@@ -7302,6 +7302,18 @@ func TestContract_SelfHostedPurchaseHandoffJSONSnapshot(t *testing.T) {if returnToken == "" {t.Fatal("expected signed purchase_return_token in success_url")}+ for _, entitlementField := range []string{+ "entitlements",+ "runtime",+ "commercial_posture",+ "subscription_state",+ "tier",+ "plan_version",+ } {+ if got := activationURL.Query().Get(entitlementField); got != "" {+ t.Fatalf("success_url query %s=%q, want omitted checkout UX metadata only", entitlementField, got)+ }+ }signingKey, err := handler.purchaseReturnSigningKey()if err != nil {t.Fatalf("purchaseReturnSigningKey: %v", err)diff --git a/internal/api/entitlement_handlers_test.go b/internal/api/entitlement_handlers_test.goindex 8f3fe3ad2f..90649b0786 100644--- a/internal/api/entitlement_handlers_test.go+++ b/internal/api/entitlement_handlers_test.go@@ -453,6 +453,12 @@ func TestEntitlementHandler_SelfHostedPaidEvaluatorStateIsUncapped(t *testing.T)if payload.PlanVersion != "pro" {t.Fatalf("plan_version=%q, want %q", payload.PlanVersion, "pro")}+ if payload.SubscriptionState != string(entitlements.SubStateActive) {+ t.Fatalf("subscription_state=%q, want %q", payload.SubscriptionState, entitlements.SubStateActive)+ }+ if payload.Tier != string(license.TierPro) {+ t.Fatalf("tier=%q, want %q", payload.Tier, license.TierPro)+ }for _, limit := range payload.Limits {if limit.Key == "max_monitored_systems" || limit.Key == "max_guests" {t.Fatalf("expected self-hosted paid evaluator payload to omit volume caps, got %+v", payload.Limits)@@ -504,6 +510,12 @@ func TestEntitlementHandler_GrandfatheredRecurringEvaluatorStateIsUncapped(t *teif payload.PlanVersion != "v5_pro_monthly_grandfathered" {t.Fatalf("plan_version=%q, want %q", payload.PlanVersion, "v5_pro_monthly_grandfathered")}+ if payload.SubscriptionState != string(entitlements.SubStateActive) {+ t.Fatalf("subscription_state=%q, want %q", payload.SubscriptionState, entitlements.SubStateActive)+ }+ if payload.Tier != string(license.TierPro) {+ t.Fatalf("tier=%q, want %q", payload.Tier, license.TierPro)+ }for _, limit := range payload.Limits {if limit.Key == "max_monitored_systems" || limit.Key == "max_guests" {t.Fatalf("expected grandfathered recurring evaluator payload to omit capped limits, got %+v", payload.Limits)diff --git a/pkg/licensing/purchase_return_test.go b/pkg/licensing/purchase_return_test.goindex 998959160d..27d0eb6cdb 100644--- a/pkg/licensing/purchase_return_test.go+++ b/pkg/licensing/purchase_return_test.go@@ -40,6 +40,9 @@ func TestSignAndVerifyPurchaseReturnToken(t *testing.T) {if claims.InstanceHost != "pulse.example.com" {t.Fatalf("claims.InstanceHost=%q, want %q", claims.InstanceHost, "pulse.example.com")}+ if claims.ReturnURL != "https://pulse.example.com/auth/license-purchase-activate" {+ t.Fatalf("claims.ReturnURL=%q, want activation bridge URL only", claims.ReturnURL)+ }}func TestVerifyPurchaseReturnToken_HostMismatch(t *testing.T) {diff --git a/tests/integration/tests/55-self-hosted-upgrade-return.spec.ts b/tests/integration/tests/55-self-hosted-upgrade-return.spec.tsindex 35f61b4e0f..6ac65ae223 100644--- a/tests/integration/tests/55-self-hosted-upgrade-return.spec.ts+++ b/tests/integration/tests/55-self-hosted-upgrade-return.spec.ts@@ -27,6 +27,12 @@ const PURCHASE_RETURN_TOKEN = "prt_signed_checkout_return";const CHECKOUT_SESSION_ID = "cs_upgrade_return";const MONITORED_SYSTEM_FEATURE = "self_hosted_plan";+const PRO_RUNTIME_IDENTITY = {+ build: "pro",+ label: "Pulse Pro runtime",+ download_url: "https://pulserelay.pro/download.html",+};+const MONITORED_SYSTEM_ENTITLEMENTS = {capabilities: [],limits: [],@@ -86,6 +92,8 @@ const ACTIVATED_PLAN_ENTITLEMENTS = {valid: true,is_lifetime: false,days_remaining: 30,+ max_history_days: 90,+ runtime: PRO_RUNTIME_IDENTITY,};const ACTIVATED_PLAN_RUNTIME_CAPABILITIES = {@@ -93,6 +101,7 @@ const ACTIVATED_PLAN_RUNTIME_CAPABILITIES = {limits: ACTIVATED_PLAN_ENTITLEMENTS.limits,hosted_mode: false,max_history_days: 90,+ runtime: PRO_RUNTIME_IDENTITY,};const ACTIVATED_PLAN_COMMERCIAL_POSTURE = {@@ -135,6 +144,19 @@ const MONITORED_SYSTEM_LEDGER = {limit: 0,};+type BillingFixtureRequests = {+ inactive: {+ runtimeCapabilities: number;+ commercialPosture: number;+ entitlements: number;+ };+ activated: {+ runtimeCapabilities: number;+ commercialPosture: number;+ entitlements: number;+ };+};+function fulfillJSON(route: Route, payload: unknown, status = 200) {return route.fulfill({status,@@ -350,6 +372,18 @@ async function configureBillingFixtures(} = {},) {const activationState = options.activationState ?? { current: false };+ const requestCounts: BillingFixtureRequests = {+ inactive: {+ runtimeCapabilities: 0,+ commercialPosture: 0,+ entitlements: 0,+ },+ activated: {+ runtimeCapabilities: 0,+ commercialPosture: 0,+ entitlements: 0,+ },+ };await context.route("**/api/security/status", async (route) => {await fulfillJSON(route, {@@ -372,6 +406,8 @@ async function configureBillingFixtures(});await context.route("**/api/license/runtime-capabilities", async (route) => {+ const stateKey = activationState.current ? "activated" : "inactive";+ requestCounts[stateKey].runtimeCapabilities += 1;await fulfillJSON(route,activationState.current@@ -381,6 +417,8 @@ async function configureBillingFixtures(});await context.route("**/api/license/commercial-posture", async (route) => {+ const stateKey = activationState.current ? "activated" : "inactive";+ requestCounts[stateKey].commercialPosture += 1;await fulfillJSON(route,activationState.current@@ -390,6 +428,8 @@ async function configureBillingFixtures(});await context.route("**/api/license/entitlements", async (route) => {+ const stateKey = activationState.current ? "activated" : "inactive";+ requestCounts[stateKey].entitlements += 1;await fulfillJSON(route,activationState.current ? ACTIVATED_PLAN_ENTITLEMENTS : MONITORED_SYSTEM_ENTITLEMENTS,@@ -405,6 +445,8 @@ async function configureBillingFixtures(await fulfillJSON(route, payload);},);++ return requestCounts;}async function openMonitoredSystemUpgradeArrival(page: Page) {@@ -498,6 +540,43 @@ test.describe("Self-hosted upgrade return flow", () => {await expect(page.getByRole("link", { name: "Review plan" })).toHaveCount(0);});+ test("keeps checkout return as UX-only until server entitlements refresh paid state", async ({+ page,+ }, testInfo) => {+ test.skip(+ testInfo.project.name.startsWith("mobile-"),+ "Desktop-only billing continuity",+ );++ const context = page.context();+ const activationState = { current: false };+ const requestCounts = await configureBillingFixtures(context, page, { activationState });++ await configurePurchaseStartRoute(context);+ await configurePortalRedirectRoute(context, {+ body: "Checkout complete. Returning to Plans.",+ redirectUrl: buildPurchaseReturnUrl(),+ });+ await configurePurchaseReturnRoute(context, {+ completionTitle: "Plan activated",+ finalRedirectUrl: ACTIVATED_BILLING_URL,+ });++ await openMonitoredSystemUpgradeArrival(page);+ await page.getByRole("link", { name: "Compare plans" }).click();+ await page.goto(buildPortalHandoffUrl(), { waitUntil: "domcontentloaded" });++ await expect(page).toHaveURL(FINAL_BILLING_URL);+ await expect(page.getByText("Pulse Pro is now active", { exact: true })).toHaveCount(0);+ await expect(+ page.getByText("Checkout completed and this instance is now running Pulse Pro."),+ ).toHaveCount(0);+ await expect(page.getByText("Current plan: Community")).toBeVisible();+ await expect(page.getByText("Safe Remediation Workflows")).toHaveCount(0);+ await expect.poll(() => requestCounts.inactive.entitlements).toBeGreaterThan(0);+ expect(requestCounts.activated.entitlements).toBe(0);+ });+test("returns cancelled checkout directly to the owned billing plan route", async ({page,}, testInfo) => {@@ -523,7 +602,7 @@ test.describe("Self-hosted upgrade return flow", () => {await page.goto(buildPortalHandoffUrl(), { waitUntil: "domcontentloaded" });- await expect(page).toHaveURL(CANCELLED_BILLING_URL);+ await expect(page).toHaveURL(FINAL_RESTARTABLE_BILLING_URL);await expect(page.getByText("Checkout cancelled", { exact: true })).toBeVisible();await expect(page.getByRole("link", { name: "Compare plans" })).toHaveAttribute("href",diff --git a/tests/integration/tests/59-self-hosted-plans-entitlement-summary.spec.ts b/tests/integration/tests/59-self-hosted-plans-entitlement-summary.spec.tsindex 16a5c65a0d..81c1ed7cba 100644--- a/tests/integration/tests/59-self-hosted-plans-entitlement-summary.spec.ts+++ b/tests/integration/tests/59-self-hosted-plans-entitlement-summary.spec.ts@@ -1,7 +1,5 @@import { expect, test, type Page } from '@playwright/test';-import { ensureAuthenticated } from './helpers';-const PRO_RUNTIME_IDENTITY = {build: 'pro',label: 'Pulse Pro runtime',@@ -112,6 +110,56 @@ const PRO_PLAN_COMMUNITY_RUNTIME_CAPABILITIES = {],};+async function stubAuthenticatedShell(page: Page) {+ await page.route('**/api/security/status', async (route) => {+ await route.fulfill({+ status: 200,+ contentType: 'application/json',+ body: JSON.stringify({+ hasAuthentication: true,+ hideLocalLogin: false,+ ssoProviders: [],+ sessionCapabilities: {},+ settingsCapabilities: {+ apiAccessRead: true,+ apiAccessWrite: true,+ authenticationRead: true,+ authenticationWrite: true,+ singleSignOnRead: true,+ singleSignOnWrite: true,+ roles: true,+ users: true,+ auditLog: true,+ auditWebhooksRead: true,+ auditWebhooksWrite: true,+ relayRead: true,+ relayWrite: true,+ billingAdmin: true,+ },+ }),+ });+ });++ await page.route('**/api/state', async (route) => {+ await route.fulfill({+ status: 200,+ contentType: 'application/json',+ body: JSON.stringify({ ok: true }),+ });+ });++ await page.route('**/api/system/settings', async (route) => {+ await route.fulfill({+ status: 200,+ contentType: 'application/json',+ body: JSON.stringify({+ theme: 'system',+ fullWidthMode: false,+ }),+ });+ });+}+async function stubSelfHostedPlanEndpoints(page: Page,payloads: {@@ -120,6 +168,8 @@ async function stubSelfHostedPlanEndpoints(runtimeCapabilities?: Record<string, unknown>;} = {},) {+ await stubAuthenticatedShell(page);+const runtimeCapabilities = payloads.runtimeCapabilities ?? PRO_PLAN_RUNTIME_CAPABILITIES;const entitlements = payloads.entitlements ?? PRO_PLAN_ENTITLEMENTS;const commercialPosture = payloads.commercialPosture ?? PRO_PLAN_COMMERCIAL_POSTURE;@@ -156,7 +206,6 @@ test.describe('Self-hosted plans entitlement summary', () => {test.skip(testInfo.project.name.startsWith('mobile-'), 'Desktop-only plans coverage');await stubSelfHostedPlanEndpoints(page);- await ensureAuthenticated(page);await page.goto('/settings/system/billing/plan', { waitUntil: 'domcontentloaded' });await expect(@@ -226,7 +275,6 @@ test.describe('Self-hosted plans entitlement summary', () => {entitlements: unknownRuntimeEntitlements,runtimeCapabilities: unknownRuntimeCapabilities,});- await ensureAuthenticated(page);await page.goto('/settings/system/billing/plan', { waitUntil: 'domcontentloaded' });const currentPlanCard = page@@ -258,7 +306,6 @@ test.describe('Self-hosted plans entitlement summary', () => {},runtimeCapabilities: PRO_PLAN_COMMUNITY_RUNTIME_CAPABILITIES,});- await ensureAuthenticated(page);await page.goto('/settings/system/billing/plan', {waitUntil: 'domcontentloaded',});@@ -293,7 +340,6 @@ test.describe('Self-hosted plans entitlement summary', () => {test.skip(testInfo.project.name.startsWith('mobile-'), 'Desktop-only settings coverage');await stubSelfHostedPlanEndpoints(page);- await ensureAuthenticated(page);await page.goto('/settings/system/billing/plan', { waitUntil: 'domcontentloaded' });const settingsNav = page.locator('[aria-label="Settings navigation"]');diff --git a/tests/integration/tests/70-self-hosted-manual-activation-success.spec.ts b/tests/integration/tests/70-self-hosted-manual-activation-success.spec.tsindex ef91f896c7..a97e4b9113 100644--- a/tests/integration/tests/70-self-hosted-manual-activation-success.spec.ts+++ b/tests/integration/tests/70-self-hosted-manual-activation-success.spec.ts@@ -1,6 +1,10 @@import { expect, test, type Page } from '@playwright/test';-import { ensureAuthenticated } from './helpers';+const PRO_RUNTIME_IDENTITY = {+ build: 'pro',+ label: 'Pulse Pro runtime',+ download_url: 'https://pulserelay.pro/download.html',+};const INACTIVE_ENTITLEMENTS = {capabilities: [],@@ -36,6 +40,8 @@ const ACTIVE_ENTITLEMENTS = {valid: true,is_lifetime: false,days_remaining: 30,+ max_history_days: 90,+ runtime: PRO_RUNTIME_IDENTITY,};const INACTIVE_RUNTIME_CAPABILITIES = {@@ -50,6 +56,7 @@ const ACTIVE_RUNTIME_CAPABILITIES = {limits: ACTIVE_ENTITLEMENTS.limits,hosted_mode: false,max_history_days: 90,+ runtime: PRO_RUNTIME_IDENTITY,};const INACTIVE_COMMERCIAL_POSTURE = {@@ -72,10 +79,89 @@ const ACTIVE_COMMERCIAL_POSTURE = {has_migration_gap: false,};+type ManualActivationRequestCounts = {+ inactive: {+ runtimeCapabilities: number;+ entitlements: number;+ commercialPosture: number;+ };+ active: {+ runtimeCapabilities: number;+ entitlements: number;+ commercialPosture: number;+ };+ activate: number;+};++async function stubAuthenticatedShell(page: Page) {+ await page.route('**/api/security/status', async (route) => {+ await route.fulfill({+ status: 200,+ contentType: 'application/json',+ body: JSON.stringify({+ hasAuthentication: true,+ hideLocalLogin: false,+ ssoProviders: [],+ sessionCapabilities: {},+ settingsCapabilities: {+ apiAccessRead: true,+ apiAccessWrite: true,+ authenticationRead: true,+ authenticationWrite: true,+ singleSignOnRead: true,+ singleSignOnWrite: true,+ roles: true,+ users: true,+ auditLog: true,+ auditWebhooksRead: true,+ auditWebhooksWrite: true,+ relayRead: true,+ relayWrite: true,+ billingAdmin: true,+ },+ }),+ });+ });++ await page.route('**/api/state', async (route) => {+ await route.fulfill({+ status: 200,+ contentType: 'application/json',+ body: JSON.stringify({ ok: true }),+ });+ });++ await page.route('**/api/system/settings', async (route) => {+ await route.fulfill({+ status: 200,+ contentType: 'application/json',+ body: JSON.stringify({+ theme: 'system',+ fullWidthMode: false,+ }),+ });+ });+}+async function stubManualActivationEndpoints(page: Page) {let activated = false;+ const requestCounts: ManualActivationRequestCounts = {+ inactive: {+ runtimeCapabilities: 0,+ entitlements: 0,+ commercialPosture: 0,+ },+ active: {+ runtimeCapabilities: 0,+ entitlements: 0,+ commercialPosture: 0,+ },+ activate: 0,+ };await page.route('**/api/license/runtime-capabilities', async (route) => {+ const stateKey = activated ? 'active' : 'inactive';+ requestCounts[stateKey].runtimeCapabilities += 1;await route.fulfill({status: 200,contentType: 'application/json',@@ -84,6 +170,8 @@ async function stubManualActivationEndpoints(page: Page) {});await page.route('**/api/license/entitlements', async (route) => {+ const stateKey = activated ? 'active' : 'inactive';+ requestCounts[stateKey].entitlements += 1;await route.fulfill({status: 200,contentType: 'application/json',@@ -92,6 +180,8 @@ async function stubManualActivationEndpoints(page: Page) {});await page.route('**/api/license/commercial-posture', async (route) => {+ const stateKey = activated ? 'active' : 'inactive';+ requestCounts[stateKey].commercialPosture += 1;await route.fulfill({status: 200,contentType: 'application/json',@@ -100,6 +190,7 @@ async function stubManualActivationEndpoints(page: Page) {});await page.route('**/api/license/activate', async (route) => {+ requestCounts.activate += 1;activated = true;await route.fulfill({status: 200,@@ -110,6 +201,8 @@ async function stubManualActivationEndpoints(page: Page) {}),});});++ return requestCounts;}test.describe('Self-hosted manual activation success', () => {@@ -118,8 +211,8 @@ test.describe('Self-hosted manual activation success', () => {}, testInfo) => {test.skip(testInfo.project.name.startsWith('mobile-'), 'Desktop-only plans coverage');- await stubManualActivationEndpoints(page);- await ensureAuthenticated(page);+ await stubAuthenticatedShell(page);+ const requestCounts = await stubManualActivationEndpoints(page);await page.goto('/settings/system/billing/plan', { waitUntil: 'domcontentloaded' });const communityPlanCard = page@@ -132,7 +225,7 @@ test.describe('Self-hosted manual activation success', () => {await expect(communityPlanCard.getByText('Expired', { exact: true })).toHaveCount(0);await expect(communityPlanCard.getByText(- 'Community is active on this instance. It includes self-hosted monitoring, 7-day metric history, Pulse Patrol (BYOK), and update alerts.',+ 'Community is active on this instance. It includes self-hosted monitoring, 7-day metric history, Pulse Patrol (BYOK), update alerts, and SSO.',),).toBeVisible();await expect(page.getByText('Optional extras')).toHaveCount(0);@@ -160,6 +253,10 @@ test.describe('Self-hosted manual activation success', () => {await expect(activationSummary.getByText('Available now on this instance')).toBeVisible();await expect(activationSummary.getByText('Safe Remediation Workflows')).toBeVisible();await expect(activationSummary.getByText('Alert Root-Cause Analysis')).toBeVisible();+ await expect.poll(() => requestCounts.activate).toBe(1);+ await expect.poll(() => requestCounts.active.entitlements).toBeGreaterThan(0);+ await expect.poll(() => requestCounts.active.runtimeCapabilities).toBeGreaterThan(0);+ await expect.poll(() => requestCounts.active.commercialPosture).toBeGreaterThan(0);await expect(page.getByText('Current plan: Pulse Pro')).toBeVisible();const currentPlanCard = page