-
Notifications
You must be signed in to change notification settings - Fork 139
chore: reduce cleanup time #652
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,8 +18,8 @@ export function describeWithAtlas(name: string, fn: IntegrationTestFunction): vo | |
const integration = setupIntegrationTest( | ||
() => ({ | ||
...defaultTestConfig, | ||
apiClientId: process.env.MDB_MCP_API_CLIENT_ID, | ||
apiClientSecret: process.env.MDB_MCP_API_CLIENT_SECRET, | ||
apiClientId: process.env.MDB_MCP_API_CLIENT_ID || "test-client", | ||
apiClientSecret: process.env.MDB_MCP_API_CLIENT_SECRET || "test-secret", | ||
apiBaseUrl: process.env.MDB_MCP_API_BASE_URL ?? "https://cloud-dev.mongodb.com", | ||
}), | ||
() => defaultDriverOptions | ||
|
@@ -35,6 +35,16 @@ interface ProjectTestArgs { | |
|
||
type ProjectTestFunction = (args: ProjectTestArgs) => void; | ||
|
||
export function withCredentials(integration: IntegrationTest, fn: IntegrationTestFunction): SuiteCollector<object> { | ||
const describeFn = | ||
!process.env.MDB_MCP_API_CLIENT_ID?.length || !process.env.MDB_MCP_API_CLIENT_SECRET?.length | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The credential validation logic is duplicated between Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||
? describe.skip | ||
: describe; | ||
return describeFn("with credentials", () => { | ||
fn(integration); | ||
}); | ||
} | ||
|
||
export function withProject(integration: IntegrationTest, fn: ProjectTestFunction): SuiteCollector<object> { | ||
return describe("with project", () => { | ||
let projectId: string = ""; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,25 @@ | ||
import { expectDefined, getDataFromUntrustedContent, getResponseElements } from "../../helpers.js"; | ||
import { parseTable, describeWithAtlas } from "./atlasHelpers.js"; | ||
import { parseTable, describeWithAtlas, withCredentials } from "./atlasHelpers.js"; | ||
import { describe, expect, it } from "vitest"; | ||
|
||
describeWithAtlas("orgs", (integration) => { | ||
describe("atlas-list-orgs", () => { | ||
it("should have correct metadata", async () => { | ||
const { tools } = await integration.mcpClient().listTools(); | ||
const listOrgs = tools.find((tool) => tool.name === "atlas-list-orgs"); | ||
expectDefined(listOrgs); | ||
}); | ||
withCredentials(integration, () => { | ||
describe("atlas-list-orgs", () => { | ||
it("should have correct metadata", async () => { | ||
const { tools } = await integration.mcpClient().listTools(); | ||
const listOrgs = tools.find((tool) => tool.name === "atlas-list-orgs"); | ||
expectDefined(listOrgs); | ||
}); | ||
|
||
it("returns org names", async () => { | ||
const response = await integration.mcpClient().callTool({ name: "atlas-list-orgs", arguments: {} }); | ||
const elements = getResponseElements(response); | ||
expect(elements[0]?.text).toContain("Found 1 organizations"); | ||
expect(elements[1]?.text).toContain("<untrusted-user-data-"); | ||
const data = parseTable(getDataFromUntrustedContent(elements[1]?.text ?? "")); | ||
expect(data).toHaveLength(1); | ||
expect(data[0]?.["Organization Name"]).toEqual("MongoDB MCP Test"); | ||
it("returns org names", async () => { | ||
const response = await integration.mcpClient().callTool({ name: "atlas-list-orgs", arguments: {} }); | ||
const elements = getResponseElements(response); | ||
expect(elements[0]?.text).toContain("Found 1 organizations"); | ||
Check failure on line 17 in tests/integration/tools/atlas/orgs.test.ts
|
||
expect(elements[1]?.text).toContain("<untrusted-user-data-"); | ||
const data = parseTable(getDataFromUntrustedContent(elements[1]?.text ?? "")); | ||
expect(data).toHaveLength(1); | ||
expect(data[0]?.["Organization Name"]).toEqual("MongoDB MCP Test"); | ||
}); | ||
}); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using hardcoded fallback credentials ('test-client', 'test-secret') creates a security risk. These fallback values should be removed or replaced with proper test environment validation that fails gracefully when credentials are missing.
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just noticed this, why don't we use defaultTestConfig here which ideally should already parse these values?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we use defaultTestConfig but override it with the test items if it's not there