Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

test: add validation for unrecognized fields in server config update

Victor Hugo dos Santos09279777ceba
diff --git a/backend/e2e-test/routes/v1/admin.spec.ts b/backend/e2e-test/routes/v1/admin.spec.ts
index 547cccfd58..913722f22b 100644
--- a/backend/e2e-test/routes/v1/admin.spec.ts
+++ b/backend/e2e-test/routes/v1/admin.spec.ts
@@ -133,4 +133,14 @@ describe("Admin V1 Router", () => {
});
});
});
+
+ describe("server config unrecognized fields", () => {
+ test("rejects a body that only contains removed fields", async () => {
+ const response = await updateServerConfig({ trustSamlEmails: true });
+
+ expect(response.statusCode).toBe(400);
+ expect(response.json().message).toContain("No recognized instance configuration fields were provided");
+ expect(response.json().message).toContain("trustSamlEmails");
+ });
+ });
});
diff --git a/backend/src/ee/services/ldap-config/ldap-config-service.ts b/backend/src/ee/services/ldap-config/ldap-config-service.ts
index 7e837f677c..b324422811 100644
--- a/backend/src/ee/services/ldap-config/ldap-config-service.ts
+++ b/backend/src/ee/services/ldap-config/ldap-config-service.ts
@@ -501,9 +501,6 @@ export const ldapConfigServiceFactory = ({
const organization = await requestMemoize(requestMemoKeys.orgFindOrgById(orgId), () => orgDAL.findOrgById(orgId));
if (!organization) throw new NotFoundError({ message: `Organization with ID '${orgId}' not found` });
- // When the org enforces SSO, the verified domain + IdP are authoritative, so we skip the
- // separate email-verification step (the email-domain ownership check above already proves the
- // org owns this domain, and password signup is blocked for enforced domains).
const skipEmailVerification = Boolean(organization.authEnforced) || Boolean(serverCfg.trustLdapEmails);
// A stale, still-unverified alias may point at another user's account. Don't mutate that
diff --git a/backend/src/services/super-admin/super-admin-service.ts b/backend/src/services/super-admin/super-admin-service.ts
index 128bf7a951..06cc8d3261 100644
--- a/backend/src/services/super-admin/super-admin-service.ts
+++ b/backend/src/services/super-admin/super-admin-service.ts
@@ -474,11 +474,11 @@ export const superAdminServiceFactory = ({
envOverridesUpdated = true;
}
- // A caller that only sends fields this API no longer recognises (the removed trustSamlEmails /
- // trustOidcEmails switches, for instance) leaves nothing to write. Knex rejects an empty
- // update, so treat it as a no-op instead of failing the request.
if (!Object.values(updatedData).some((value) => value !== undefined)) {
- return getServerCfg();
+ throw new BadRequestError({
+ message:
+ "No recognized instance configuration fields were provided. Settings that have been removed are no longer accepted."
+ });
}
const updatedServerCfg = await serverCfgDAL.updateById(ADMIN_CONFIG_DB_UUID, updatedData);