Skip to content

Commit e752751

Browse files
committed
chore: fix tests
1 parent e6ab659 commit e752751

File tree

1 file changed

+21
-23
lines changed

1 file changed

+21
-23
lines changed

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

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -123,27 +123,13 @@ describe("configOverrides", () => {
123123
expect(result.readOnly).toBe(true);
124124
});
125125

126-
it("should override numeric values with override behavior", () => {
127-
const request: RequestContext = {
128-
headers: {
129-
"x-mongodb-mcp-idle-timeout-ms": "300000",
130-
"x-mongodb-mcp-export-timeout-ms": "600000",
131-
},
132-
};
133-
const result = applyConfigOverrides({ baseConfig: baseConfig as UserConfig, request });
134-
expect(result.idleTimeoutMs).toBe(300000);
135-
expect(result.exportTimeoutMs).toBe(600000);
136-
});
137-
138126
it("should override string values with override behavior", () => {
139127
const request: RequestContext = {
140128
headers: {
141-
"x-mongodb-mcp-connection-string": "mongodb://newhost:27017",
142129
"x-mongodb-mcp-vector-search-similarity-function": "cosine",
143130
},
144131
};
145132
const result = applyConfigOverrides({ baseConfig: baseConfig as UserConfig, request });
146-
expect(result.connectionString).toBe("mongodb://newhost:27017");
147133
expect(result.vectorSearchSimilarityFunction).toBe("cosine");
148134
});
149135
});
@@ -174,14 +160,15 @@ describe("configOverrides", () => {
174160
expect(result.previewFeatures).toEqual([]);
175161
});
176162

177-
it("should merge loggers", () => {
163+
it("should not be able to merge loggers", () => {
178164
const request: RequestContext = {
179165
headers: {
180166
"x-mongodb-mcp-loggers": "stderr",
181167
},
182168
};
183-
const result = applyConfigOverrides({ baseConfig: baseConfig as UserConfig, request });
184-
expect(result.loggers).toEqual(["disk", "mcp", "stderr"]);
169+
expect(() => applyConfigOverrides({ baseConfig: baseConfig as UserConfig, request })).toThrow(
170+
"Config key loggers is not allowed to be overridden"
171+
);
185172
});
186173
});
187174

@@ -197,6 +184,8 @@ describe("configOverrides", () => {
197184
"apiBaseUrl",
198185
"apiClientId",
199186
"apiClientSecret",
187+
"connectionString",
188+
"loggers",
200189
"logPath",
201190
"telemetry",
202191
"transport",
@@ -206,7 +195,7 @@ describe("configOverrides", () => {
206195
"maxBytesPerQuery",
207196
"maxDocumentsPerQuery",
208197
"exportsPath",
209-
"voyageApiKey",
198+
"exportCleanupIntervalMs",
210199
"allowRequestOverrides",
211200
]);
212201
});
@@ -231,21 +220,21 @@ describe("configOverrides", () => {
231220
it("should allow overriding secret fields with headers if they have override behavior", () => {
232221
const request: RequestContext = {
233222
headers: {
234-
"x-mongodb-mcp-connection-string": "mongodb://newhost:27017/",
223+
"x-mongodb-mcp-voyage-api-key": "test",
235224
},
236225
};
237226
const result = applyConfigOverrides({ baseConfig: baseConfig as UserConfig, request });
238-
expect(result.connectionString).toBe("mongodb://newhost:27017/");
227+
expect(result.voyageApiKey).toBe("test");
239228
});
240229

241230
it("should not allow overriding secret fields via query params", () => {
242231
const request: RequestContext = {
243232
query: {
244-
mongodbMcpConnectionString: "mongodb://malicious.com/",
233+
mongodbMcpVoyageApiKey: "test",
245234
},
246235
};
247236
expect(() => applyConfigOverrides({ baseConfig: baseConfig as UserConfig, request })).toThrow(
248-
"Config key connectionString can only be overriden with headers"
237+
"Config key voyageApiKey can only be overriden with headers"
249238
);
250239
});
251240
});
@@ -260,7 +249,16 @@ describe("configOverrides", () => {
260249
])
261250
.filter(([, behavior]) => typeof behavior === "function")
262251
.map(([key]) => key)
263-
).toEqual(["readOnly", "indexCheck", "disableEmbeddingsValidation"]);
252+
).toEqual([
253+
"readOnly",
254+
"indexCheck",
255+
"idleTimeoutMs",
256+
"notificationTimeoutMs",
257+
"exportTimeoutMs",
258+
"atlasTemporaryDatabaseUserLifetimeMs",
259+
"disableEmbeddingsValidation",
260+
"previewFeatures",
261+
]);
264262
});
265263

266264
it("should allow readOnly override from false to true", () => {

0 commit comments

Comments
 (0)