Skip to content

Commit 6dc2705

Browse files
committed
chore: fix password extraction logic and clear keychain after test
1 parent 08e47db commit 6dc2705

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

tests/integration/tools/atlas/dbUsers.test.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@ import { describeWithAtlas, withProject, randomId } from "./atlasHelpers.js";
22
import { expectDefined, getResponseElements } from "../../helpers.js";
33
import { ApiClientError } from "../../../../src/common/atlas/apiClientError.js";
44
import { afterEach, beforeEach, describe, expect, it } from "vitest";
5+
import { Keychain } from "../../../../src/common/keychain.js";
56

67
describeWithAtlas("db users", (integration) => {
78
withProject(integration, ({ getProjectId }) => {
89
let userName: string;
910
beforeEach(() => {
1011
userName = "testuser-" + randomId;
12+
Keychain.root.clearAllSecrets();
13+
});
14+
15+
afterEach(() => {
16+
Keychain.root.clearAllSecrets();
1117
});
1218

1319
const createUserWithMCP = async (password?: string): Promise<unknown> => {
@@ -97,7 +103,11 @@ describeWithAtlas("db users", (integration) => {
97103
const passwordStart = elements[0]?.text.lastIndexOf(":") ?? -1;
98104
const passwordEnd = elements[0]?.text.length ?? 1 - 1;
99105

100-
const password = elements[0]?.text.substring(passwordStart).substring(0, passwordEnd).trim();
106+
const password = elements[0]?.text
107+
.substring(passwordStart + 1, passwordEnd - 1)
108+
.replace("`", "")
109+
.trim();
110+
101111
expect(integration.mcpServer().session.keychain.allSecrets).toEqual([
102112
{
103113
value: userName,

0 commit comments

Comments
 (0)