[grade=B] DC-083: comprehensive license-manager.js test coverage (77 tests, revenue path)
Added __tests__/license-manager.test.js with 77 tests covering the entire src/managers/license-manager.js module (534 LOC) — the revenue validation path that was previously untested by any dedicated test file. Coverage includes: - load(): credential-store primary, config-backup fallback, no-license, credential-store error → config recovery, re-store after restore - activate(): real crypto round-trip for all durations (30/90/180/365), already-activated idempotency, invalid format, missing code, offline HMAC validation failure, LIFETIME rejection (prod) + acceptance (dev), credential-store save failure, config write, lowercase normalization, whitespace trimming - activate() online path: server success, server unreachable → offline fallback, server explicit rejection (no fallback) - deactivate(): success, no-active-license, credential delete, config clear - getStatus(): free tier, active premium, expired, lifetime, code masking - hasFeature(): no-activation, active, expired, specific-feature, default - isPro()/isExpired()/daysRemaining(): all branches (no-activation, active, expired, lifetime, missing expiresAt) - getMachineFingerprint(): stable 16-char hex - requirePremium() middleware: next() on available, 403 on unavailable, upgrade URL, unknown feature - loadSecret(): file-exists, file-missing, read-error (deterministic fs mock) - _validateOffline(): with-secret valid, forged HMAC mismatch, no-secret structural-only, malformed code, unsupported version (forged v2 payload) - _updateConfig(): creates config, preserves fields, clears on deactivation, nonexistent-directory tolerance - _maskCode(): standard, short, empty - Full lifecycle: activate→status→deactivate→status, load-after-activate restore, freshly-minted-code validation Unlike license-tier-enforcement.test.js (which stubs _validateOffline), these tests exercise the REAL crypto flow end-to-end: generateCode(TEST_SECRET) → activate(code) → _validateOffline(code) → verifyCode(secret, code) → credential store. Uses jest.isolateModules for online tests so the module- level LICENSE_SERVER_URL const is re-read per test. Codex grade: B (urn:ump:vwial6vhrzzmsvpfjdxnk53hvol3wna3o2zwmneqjcquxfgdersq) Full suite: 1738/1738 pass (was 1661, +77 new). Zero new ESLint warnings on src/.
This commit is contained in: