Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions tests/integration/common/connectionManager.oidc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,19 @@ describe.skipIf(process.platform !== "linux")("ConnectionManager OIDC Tests", as

addCb?.(oidcIt);
},
() => oidcConfig,
() => ({
...setupDriverConfig({
config: oidcConfig,
defaults: {},
}),
}),
{ runner: true, downloadOptions: { enterprise: true, version: mongodbVersion }, serverArgs }
{
getUserConfig: () => oidcConfig,
getDriverOptions: () =>
setupDriverConfig({
config: oidcConfig,
defaults: {},
}),
downloadOptions: {
runner: true,
downloadOptions: { enterprise: true, version: mongodbVersion },
serverArgs,
},
}
);
}

Expand Down
505 changes: 257 additions & 248 deletions tests/integration/elicitation.test.ts

Large diffs are not rendered by default.

30 changes: 18 additions & 12 deletions tests/integration/indexCheck.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,10 +313,12 @@ describe("IndexCheck integration tests", () => {
});
});
},
() => ({
...defaultTestConfig,
indexCheck: true, // Enable indexCheck
})
{
getUserConfig: () => ({
...defaultTestConfig,
indexCheck: true, // Enable indexCheck
}),
}
);
});

Expand Down Expand Up @@ -424,10 +426,12 @@ describe("IndexCheck integration tests", () => {
expect(content).not.toContain("Index check failed");
});
},
() => ({
...defaultTestConfig,
indexCheck: false, // Disable indexCheck
})
{
getUserConfig: () => ({
...defaultTestConfig,
indexCheck: false, // Disable indexCheck
}),
}
);
});

Expand Down Expand Up @@ -456,10 +460,12 @@ describe("IndexCheck integration tests", () => {
expect(response.isError).toBeFalsy();
});
},
() => ({
...defaultTestConfig,
// indexCheck not specified, should default to false
})
{
getUserConfig: () => ({
...defaultTestConfig,
// indexCheck not specified, should default to false
}),
}
);
});
});
4 changes: 3 additions & 1 deletion tests/integration/resources/exportedData.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,5 +173,7 @@ describeWithMongoDB(
});
});
},
() => userConfig
{
getUserConfig: () => userConfig,
}
);
123 changes: 63 additions & 60 deletions tests/integration/server.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defaultDriverOptions, defaultTestConfig, expectDefined, setupIntegrationTest } from "./helpers.js";
import { defaultTestConfig, expectDefined } from "./helpers.js";
import { describeWithMongoDB } from "./tools/mongodb/mongodbHelpers.js";
import { describe, expect, it } from "vitest";

Expand All @@ -15,81 +15,84 @@ describe("Server integration test", () => {
expect(atlasTools.length).toBeLessThanOrEqual(0);
});
},
() => ({
...defaultTestConfig,
apiClientId: undefined,
apiClientSecret: undefined,
}),
() => defaultDriverOptions
{
getUserConfig: () => ({
...defaultTestConfig,
apiClientId: undefined,
apiClientSecret: undefined,
}),
}
);

describe("with atlas", () => {
const integration = setupIntegrationTest(
() => ({
describeWithMongoDB(
"with atlas",
(integration) => {
describe("list capabilities", () => {
it("should return positive number of tools and have some atlas tools", async () => {
const tools = await integration.mcpClient().listTools();
expectDefined(tools);
expect(tools.tools.length).toBeGreaterThan(0);

const atlasTools = tools.tools.filter((tool) => tool.name.startsWith("atlas-"));
expect(atlasTools.length).toBeGreaterThan(0);
});

it("should return no prompts", async () => {
await expect(() => integration.mcpClient().listPrompts()).rejects.toMatchObject({
message: "MCP error -32601: Method not found",
});
});

it("should return capabilities", () => {
const capabilities = integration.mcpClient().getServerCapabilities();
expectDefined(capabilities);
expectDefined(capabilities?.logging);
expectDefined(capabilities?.completions);
expectDefined(capabilities?.tools);
expectDefined(capabilities?.resources);
expect(capabilities.experimental).toBeUndefined();
expect(capabilities.prompts).toBeUndefined();
});
});
},
{
getUserConfig: () => ({
...defaultTestConfig,
apiClientId: "test",
apiClientSecret: "test",
}),
() => defaultDriverOptions
);
}
);

describe("list capabilities", () => {
it("should return positive number of tools and have some atlas tools", async () => {
describeWithMongoDB(
"with read-only mode",
(integration) => {
it("should only register read and metadata operation tools when read-only mode is enabled", async () => {
const tools = await integration.mcpClient().listTools();
expectDefined(tools);
expect(tools.tools.length).toBeGreaterThan(0);

const atlasTools = tools.tools.filter((tool) => tool.name.startsWith("atlas-"));
expect(atlasTools.length).toBeGreaterThan(0);
});

it("should return no prompts", async () => {
await expect(() => integration.mcpClient().listPrompts()).rejects.toMatchObject({
message: "MCP error -32601: Method not found",
});
});
// Check that we have some tools available (the read and metadata ones)
expect(tools.tools.some((tool) => tool.name === "find")).toBe(true);
expect(tools.tools.some((tool) => tool.name === "collection-schema")).toBe(true);
expect(tools.tools.some((tool) => tool.name === "list-databases")).toBe(true);
expect(tools.tools.some((tool) => tool.name === "atlas-list-orgs")).toBe(true);
expect(tools.tools.some((tool) => tool.name === "atlas-list-projects")).toBe(true);

it("should return capabilities", () => {
const capabilities = integration.mcpClient().getServerCapabilities();
expectDefined(capabilities);
expectDefined(capabilities?.logging);
expectDefined(capabilities?.completions);
expectDefined(capabilities?.tools);
expectDefined(capabilities?.resources);
expect(capabilities.experimental).toBeUndefined();
expect(capabilities.prompts).toBeUndefined();
// Check that non-read tools are NOT available
expect(tools.tools.some((tool) => tool.name === "insert-one")).toBe(false);
expect(tools.tools.some((tool) => tool.name === "update-many")).toBe(false);
expect(tools.tools.some((tool) => tool.name === "delete-one")).toBe(false);
expect(tools.tools.some((tool) => tool.name === "drop-collection")).toBe(false);
});
});
});

describe("with read-only mode", () => {
const integration = setupIntegrationTest(
() => ({
},
{
getUserConfig: () => ({
...defaultTestConfig,
readOnly: true,
apiClientId: "test",
apiClientSecret: "test",
}),
() => defaultDriverOptions
);

it("should only register read and metadata operation tools when read-only mode is enabled", async () => {
const tools = await integration.mcpClient().listTools();
expectDefined(tools);
expect(tools.tools.length).toBeGreaterThan(0);

// Check that we have some tools available (the read and metadata ones)
expect(tools.tools.some((tool) => tool.name === "find")).toBe(true);
expect(tools.tools.some((tool) => tool.name === "collection-schema")).toBe(true);
expect(tools.tools.some((tool) => tool.name === "list-databases")).toBe(true);
expect(tools.tools.some((tool) => tool.name === "atlas-list-orgs")).toBe(true);
expect(tools.tools.some((tool) => tool.name === "atlas-list-projects")).toBe(true);

// Check that non-read tools are NOT available
expect(tools.tools.some((tool) => tool.name === "insert-one")).toBe(false);
expect(tools.tools.some((tool) => tool.name === "update-many")).toBe(false);
expect(tools.tools.some((tool) => tool.name === "delete-one")).toBe(false);
expect(tools.tools.some((tool) => tool.name === "drop-collection")).toBe(false);
});
});
}
);
});
Loading
Loading