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
Gate licensing test helpers out of release builds
rcourtmana44cde6b926b
diff --git a/docs/release-control/v6/internal/subsystems/cloud-paid.md b/docs/release-control/v6/internal/subsystems/cloud-paid.mdindex 434880a99b..8215b35d33 100644--- a/docs/release-control/v6/internal/subsystems/cloud-paid.md+++ b/docs/release-control/v6/internal/subsystems/cloud-paid.md@@ -90,6 +90,7 @@ agreement, and cloud-specific enforcement rules.68. `pulse-pro:V6_LAUNCH_CHECKLIST.md`69. `pkg/licensing/trial_activation_public_key_override_dev.go`70. `pkg/licensing/trial_activation_public_key_override_release.go`+71. `pkg/licensing/testing_helpers.go`## Shared Boundaries@@ -158,7 +159,7 @@ Community limit enforcement.facts line plus one next-action row before the list, but it must not turnthat summary into a second overview deck, metric grid, or competing shell.7. Add or change Stripe provisioning plan resolution through `internal/cloudcp/stripe/provisioner.go`-8. Add or change activation/grant lifecycle or dev-mode capability widening through `pkg/licensing/dev_mode_features.go`, `pkg/licensing/service.go`, `pkg/licensing/grant_refresh.go`, and `pkg/licensing/revocation_poll.go`+8. Add or change activation/grant lifecycle, release build helper gating, or dev-mode capability widening through `pkg/licensing/dev_mode_features.go`, `pkg/licensing/service.go`, `pkg/licensing/testing_helpers.go`, `pkg/licensing/grant_refresh.go`, and `pkg/licensing/revocation_poll.go`9. Add or change license-server transport through `pkg/licensing/license_server_client.go` and `pkg/licensing/quickstart_bootstrap.go`10. Add or change encrypted activation persistence through `pkg/licensing/persistence.go` and `pkg/licensing/activation_store.go`That persistence boundary must encrypt new state only with the persistent@@ -1598,6 +1599,10 @@ to `pkg/licensing/service.go`, `pkg/licensing/grant_refresh.go`,`pkg/licensing/persistence.go`, `pkg/licensing/activation_store.go`, and`pkg/licensing/trial_activation.go` should carry their dedicated proof filesinstead of relying only on the generic cloud runtime policy.+That same activation-service boundary also owns test-only helper exclusion from+release builds: legacy JWT fixtures and grant JWT generators used by tests must+live in non-release build-tagged helpers instead of shipping inside the primary+runtime service file.The remaining cloud-paid runtime families now follow the same rule as well:feature/limit primitives, billing and entitlement type shapes, commercialmigration and trial flow, conversion telemetry, host lifecycle tracking, anddiff --git a/docs/release-control/v6/internal/subsystems/registry.json b/docs/release-control/v6/internal/subsystems/registry.jsonindex 1f8539243f..bd7d30d72f 100644--- a/docs/release-control/v6/internal/subsystems/registry.json+++ b/docs/release-control/v6/internal/subsystems/registry.json@@ -1925,7 +1925,8 @@"pkg/licensing/dev_mode_features.go","pkg/licensing/grant_refresh.go","pkg/licensing/revocation_poll.go",- "pkg/licensing/service.go"+ "pkg/licensing/service.go",+ "pkg/licensing/testing_helpers.go"],"allow_same_subsystem_tests": false,"test_prefixes": [],diff --git a/internal/license/license.go b/internal/license/license.goindex a57ae8c038..7814e83ad8 100644--- a/internal/license/license.go+++ b/internal/license/license.go@@ -5,7 +5,6 @@ import ("os""strings""sync"- "time""github.com/rcourtman/pulse-go-rewrite/internal/license/entitlements"pkglicensing "github.com/rcourtman/pulse-go-rewrite/pkg/licensing"@@ -103,10 +102,6 @@ func ValidateLicense(licenseKey string) (*License, error) {return pkglicensing.ValidateLicense(licenseKey)}-func GenerateLicenseForTesting(email string, tier Tier, expiresIn time.Duration) (string, error) {- return pkglicensing.GenerateLicenseForTesting(email, tier, expiresIn)-}-func isLicenseValidationDevMode() bool {return strings.EqualFold(strings.TrimSpace(os.Getenv("PULSE_LICENSE_DEV_MODE")), "true")}diff --git a/internal/license/testing_helpers_test.go b/internal/license/testing_helpers_test.gonew file mode 100644index 0000000000..3bb4134d9c--- /dev/null+++ b/internal/license/testing_helpers_test.go@@ -0,0 +1,11 @@+package license++import (+ "time"++ pkglicensing "github.com/rcourtman/pulse-go-rewrite/pkg/licensing"+)++func GenerateLicenseForTesting(email string, tier Tier, expiresIn time.Duration) (string, error) {+ return pkglicensing.GenerateLicenseForTesting(email, tier, expiresIn)+}diff --git a/pkg/licensing/service.go b/pkg/licensing/service.goindex b52b10f579..a752212a7c 100644--- a/pkg/licensing/service.go+++ b/pkg/licensing/service.go@@ -1163,51 +1163,3 @@ func generateFingerprint() (string, error) {return fmt.Sprintf("%08x-%04x-%04x-%04x-%012x",uuid[0:4], uuid[4:6], uuid[6:8], uuid[8:10], uuid[10:16]), nil}--// GenerateLicenseForTesting creates a test license (DO NOT USE IN PRODUCTION).-// This is only for development/testing without a real license server.-func GenerateLicenseForTesting(email string, tier Tier, expiresIn time.Duration) (string, error) {- claims := Claims{- LicenseID: fmt.Sprintf("test_%d", time.Now().UnixNano()),- Email: email,- Tier: tier,- IssuedAt: time.Now().Unix(),- }- if expiresIn > 0 {- claims.ExpiresAt = time.Now().Add(expiresIn).Unix()- }-- // Create unsigned JWT (for testing only)- header := base64.RawURLEncoding.EncodeToString([]byte(`{"alg":"EdDSA","typ":"JWT"}`))- payloadBytes, err := json.Marshal(claims)- if err != nil {- return "", fmt.Errorf("marshal test license claims: %w", err)- }- payload := base64.RawURLEncoding.EncodeToString(payloadBytes)-- // Fake signature (testing only - real licenses need proper signing)- signature := base64.RawURLEncoding.EncodeToString([]byte("test-signature-not-valid"))-- return header + "." + payload + "." + signature, nil-}--// GenerateGrantJWTForTesting creates a signed grant JWT and returns the matching-// public key so tests can install it via SetPublicKey before verification.-// DO NOT USE IN PRODUCTION.-func GenerateGrantJWTForTesting(claims GrantClaims) (string, ed25519.PublicKey, error) {- publicKey, privateKey, err := ed25519.GenerateKey(rand.Reader)- if err != nil {- return "", nil, fmt.Errorf("generate grant test key pair: %w", err)- }-- header := base64.RawURLEncoding.EncodeToString([]byte(`{"alg":"EdDSA"}`))- payloadBytes, err := json.Marshal(claims)- if err != nil {- return "", nil, fmt.Errorf("marshal grant test claims: %w", err)- }- payload := base64.RawURLEncoding.EncodeToString(payloadBytes)- signedData := []byte(header + "." + payload)- signature := ed25519.Sign(privateKey, signedData)-- return header + "." + payload + "." + base64.RawURLEncoding.EncodeToString(signature), publicKey, nil-}diff --git a/pkg/licensing/service_activate_test.go b/pkg/licensing/service_activate_test.goindex caa7b4ea1e..5f3b8a693e 100644--- a/pkg/licensing/service_activate_test.go+++ b/pkg/licensing/service_activate_test.go@@ -100,6 +100,16 @@ func TestServiceActivate_ExchangesLegacyJWTOutsideDevMode(t *testing.T) {}}+func TestTestingHelpersRemainNonReleaseOnly(t *testing.T) {+ content, err := os.ReadFile("testing_helpers.go")+ if err != nil {+ t.Fatalf("read testing_helpers.go: %v", err)+ }+ if !strings.HasPrefix(string(content), "//go:build !release\n") {+ t.Fatalf("testing_helpers.go must stay excluded from release builds")+ }+}+func TestServiceActivateWithKey_SendsClientVersion(t *testing.T) {t.Setenv("PULSE_LICENSE_DEV_MODE", "false")setupTestPublicKey(t)diff --git a/pkg/licensing/testing_helpers.go b/pkg/licensing/testing_helpers.gonew file mode 100644index 0000000000..2eacb148c2--- /dev/null+++ b/pkg/licensing/testing_helpers.go@@ -0,0 +1,57 @@+//go:build !release++package licensing++import (+ "crypto/ed25519"+ "crypto/rand"+ "encoding/base64"+ "encoding/json"+ "fmt"+ "time"+)++// GenerateLicenseForTesting creates a test license (DO NOT USE IN PRODUCTION).+// This helper is intentionally excluded from release builds.+func GenerateLicenseForTesting(email string, tier Tier, expiresIn time.Duration) (string, error) {+ claims := Claims{+ LicenseID: fmt.Sprintf("test_%d", time.Now().UnixNano()),+ Email: email,+ Tier: tier,+ IssuedAt: time.Now().Unix(),+ }+ if expiresIn > 0 {+ claims.ExpiresAt = time.Now().Add(expiresIn).Unix()+ }++ header := base64.RawURLEncoding.EncodeToString([]byte(`{"alg":"EdDSA","typ":"JWT"}`))+ payloadBytes, err := json.Marshal(claims)+ if err != nil {+ return "", fmt.Errorf("marshal test license claims: %w", err)+ }+ payload := base64.RawURLEncoding.EncodeToString(payloadBytes)+ signature := base64.RawURLEncoding.EncodeToString([]byte("test-signature-not-valid"))++ return header + "." + payload + "." + signature, nil+}++// GenerateGrantJWTForTesting creates a signed grant JWT and returns the matching+// public key so tests can install it via SetPublicKey before verification.+// This helper is intentionally excluded from release builds.+func GenerateGrantJWTForTesting(claims GrantClaims) (string, ed25519.PublicKey, error) {+ publicKey, privateKey, err := ed25519.GenerateKey(rand.Reader)+ if err != nil {+ return "", nil, fmt.Errorf("generate grant test key pair: %w", err)+ }++ header := base64.RawURLEncoding.EncodeToString([]byte(`{"alg":"EdDSA"}`))+ payloadBytes, err := json.Marshal(claims)+ if err != nil {+ return "", nil, fmt.Errorf("marshal grant test claims: %w", err)+ }+ payload := base64.RawURLEncoding.EncodeToString(payloadBytes)+ signedData := []byte(header + "." + payload)+ signature := ed25519.Sign(privateKey, signedData)++ return header + "." + payload + "." + base64.RawURLEncoding.EncodeToString(signature), publicKey, nil+}