Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
test(e2e): check the license fake against the real module, and document it
Calvinb2647db63344
diff --git a/backend/CLAUDE.md b/backend/CLAUDE.mdindex 558029097a..4a84892a40 100644--- a/backend/CLAUDE.md+++ b/backend/CLAUDE.md@@ -54,7 +54,9 @@ E2E tests live in `e2e-test/routes/`. The custom Vitest environment (`e2e-test/v`isTestMode` branches. Replace the module instead, from `test.alias` in`vitest.e2e.config.mts`, with a double under `e2e-test/fakes/`. Production code stays unawarea fake exists. `e2e-test/fakes/aws-parameter-store-sync-fns.ts` and its connection counterpart-are the worked examples, and the pre-existing `./license-fns` alias is the precedent.+are the worked examples. `e2e-test/fakes/license-fns.ts` does the same for the plan: a spec calls+`fakeLicense.setFeatures({ ... })` to turn plan features on over HTTP, and+`e2e-test/setup/reset-fakes.ts` restores the unlicensed defaults at the start of every file.Four things decide whether this works:diff --git a/backend/e2e-test/fakes/license-fns.ts b/backend/e2e-test/fakes/license-fns.tsindex 48b8921a3f..01d4000cad 100644--- a/backend/e2e-test/fakes/license-fns.ts+++ b/backend/e2e-test/fakes/license-fns.ts@@ -1,6 +1,7 @@import { TFeatureSet } from "@app/ee/services/license/license-types";import { getDefaultOnPremFeatures as getMockDefaults } from "../../src/ee/services/license/__mocks__/license-fns";+import type * as RealLicenseFns from "../../src/ee/services/license/license-fns";// The e2e instance runs on-prem with no license key, so getPlan answers with the feature set the// license service took from getDefaultOnPremFeatures when it booted, by reference. Handing out one@@ -22,7 +23,14 @@ globalScope.infisicalFakeLicenseFeatures ??= getMockDefaults() as TFeatureSet;const features = globalScope.infisicalFakeLicenseFeatures;-export const getDefaultOnPremFeatures = () => features;+export const getDefaultOnPremFeatures = (): TFeatureSet => features;++// Nothing forces a module replaced by an alias to match the module it replaces, so a change to the+// real feature set would otherwise leave this fake quietly wrong. This assignment fails+// type-checking instead.+export const assertFakeMatchesRealLicenseFns: Pick<typeof RealLicenseFns, "getDefaultOnPremFeatures"> = {+ getDefaultOnPremFeatures+};export const fakeLicense = {// Mutates in place rather than replacing the object, since the license service holds a reference