Skip to content

Commit a40cccc

Browse files
committed
chore: fix tests and eslint config
Ignores any javascript or typescript file that is a test fixture.
1 parent e35e00e commit a40cccc

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

eslint.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export default defineConfig([
6464
"eslint.config.js",
6565
"vitest.config.ts",
6666
"src/types/*.d.ts",
67+
"tests/integration/fixtures/",
6768
]),
6869
eslintPluginPrettierRecommended,
6970
]);

src/common/connectionManager.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ export class ConnectionManager extends EventEmitter<ConnectionManagerEvents> {
115115
connectionInfo.driverOptions.oidc.notifyDeviceFlow ??= this.onOidcNotifyDeviceFlow.bind(this);
116116
}
117117

118+
connectionInfo.driverOptions.proxy ??= { useEnvironmentVariableProxies: true };
119+
connectionInfo.driverOptions.applyProxyToOIDC ??= true;
120+
118121
serviceProvider = await NodeDriverServiceProvider.connect(
119122
connectionInfo.connectionString,
120123
{
@@ -203,9 +206,9 @@ export class ConnectionManager extends EventEmitter<ConnectionManagerEvents> {
203206
return newState;
204207
}
205208

206-
private onOidcAuthFailed(error: unknown): void {
209+
private async onOidcAuthFailed(error: unknown): Promise<void> {
207210
if (this.state.tag === "connecting" && this.state.connectionStringAuthType?.startsWith("oidc")) {
208-
this.disconnect();
211+
await this.disconnect();
209212
this.changeState("connection-errored", { tag: "errored", errorReason: String(error) });
210213
}
211214
}

src/tools/mongodb/mongodbTool.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,14 @@ export abstract class MongoDBToolBase extends ToolBase {
6969

7070
const connectToolsNames = connectTools?.map((t) => `"${t.name}"`).join(", ");
7171
const connectionStatus = this.session.connectionManager.currentConnectionState;
72-
const additionalPromptForOidc =
73-
connectionStatus.tag === "connecting" && connectionStatus.oidcConnectionType === "oidc-device-flow"
74-
? `The user needs to finish their OIDC connection by opening '${connectionStatus.oidcLoginUrl}' in the browser and use the following user code: '${connectionStatus.oidcUserCode}'`
75-
: "";
72+
const additionalPromptForOidc: { type: "text"; text: string }[] = [];
73+
74+
if (connectionStatus.tag === "connecting" && connectionStatus.oidcConnectionType === "oidc-device-flow") {
75+
additionalPromptForOidc.push({
76+
type: "text",
77+
text: `The user needs to finish their OIDC connection by opening '${connectionStatus.oidcLoginUrl}' in the browser and use the following user code: '${connectionStatus.oidcUserCode}'`,
78+
});
79+
}
7680

7781
switch (error.code) {
7882
case ErrorCodes.NotConnectedToMongoDB:
@@ -82,10 +86,7 @@ export abstract class MongoDBToolBase extends ToolBase {
8286
type: "text",
8387
text: "You need to connect to a MongoDB instance before you can access its data.",
8488
},
85-
{
86-
type: "text",
87-
text: additionalPromptForOidc,
88-
},
89+
...additionalPromptForOidc,
8990
{
9091
type: "text",
9192
text: connectToolsNames

0 commit comments

Comments
 (0)