Skip to content

Commit c79e7ba

Browse files
chore: fix tests for override behaviour
1 parent ab80e65 commit c79e7ba

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

tests/unit/common/config/configOverrides.test.ts

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ describe("configOverrides", () => {
230230
"maxDocumentsPerQuery",
231231
"exportsPath",
232232
"exportCleanupIntervalMs",
233+
"voyageApiKey",
233234
"allowRequestOverrides",
234235
"dryRun",
235236
]);
@@ -252,24 +253,19 @@ describe("configOverrides", () => {
252253
});
253254

254255
describe("secret fields", () => {
255-
it("should allow overriding secret fields with headers if they have override behavior", () => {
256-
const request: RequestContext = {
257-
headers: {
258-
"x-mongodb-mcp-voyage-api-key": "test",
259-
},
260-
};
261-
const result = applyConfigOverrides({ baseConfig: baseConfig as UserConfig, request });
262-
expect(result.voyageApiKey).toBe("test");
256+
const secretFields = Object.keys(UserConfigSchema.shape).filter((configKey) => {
257+
const meta = getConfigMeta(configKey as keyof UserConfig);
258+
return meta?.isSecret;
263259
});
264260

265-
it("should not allow overriding secret fields via query params", () => {
261+
it.each(secretFields)("should not allow overriding secret fields - $0", () => {
266262
const request: RequestContext = {
267-
query: {
268-
mongodbMcpVoyageApiKey: "test",
263+
headers: {
264+
"x-mongodb-mcp-voyage-api-key": "test",
269265
},
270266
};
271267
expect(() => applyConfigOverrides({ baseConfig: baseConfig as UserConfig, request })).toThrow(
272-
"Config key voyageApiKey can only be overriden with headers"
268+
"Config key voyageApiKey is not allowed to be overridden"
273269
);
274270
});
275271
});

0 commit comments

Comments
 (0)