Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions src/common/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ export class Session extends EventEmitter<{
w: connectOptions.writeConcern,
},
timeoutMS: connectOptions.timeoutMS,
proxy: { useEnvironmentVariableProxies: true },
applyProxyToOIDC: true,
});
}
}
12 changes: 12 additions & 0 deletions tests/unit/common/session.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,17 @@ describe("Session", () => {
}
});
}

it("should configure the proxy to use environment variables", async () => {
await session.connectToMongoDB("mongodb://localhost", config.connectOptions);
expect(session.serviceProvider).toBeDefined();

const connectMock = MockNodeDriverServiceProvider.connect;
expect(connectMock).toHaveBeenCalledOnce();

const connectionConfig = connectMock.mock.calls[0]?.[1];
expect(connectionConfig?.proxy).toEqual({ useEnvironmentVariableProxies: true });
expect(connectionConfig?.applyProxyToOIDC).toEqual(true);
});
});
});
Loading