Skip to content

Commit 91c5d8a

Browse files
committed
chore: Enable proxy for OIDC and MongoDB connections
By providing { useEnvironmentVariableProxies: true } the NodeDriverServiceProvider already reads the relevant environment variables and sets up the proxy internally.
1 parent 5fcbf05 commit 91c5d8a

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/common/session.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ export class Session extends EventEmitter<{
113113
w: connectOptions.writeConcern,
114114
},
115115
timeoutMS: connectOptions.timeoutMS,
116+
proxy: { useEnvironmentVariableProxies: true },
117+
applyProxyToOIDC: true,
116118
});
117119
}
118120
}

tests/unit/common/session.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,17 @@ describe("Session", () => {
5656
}
5757
});
5858
}
59+
60+
it("should configure the proxy to use environment variables", async () => {
61+
await session.connectToMongoDB("mongodb://localhost", config.connectOptions);
62+
expect(session.serviceProvider).toBeDefined();
63+
64+
const connectMock = MockNodeDriverServiceProvider.connect;
65+
expect(connectMock).toHaveBeenCalledOnce();
66+
67+
const connectionConfig = connectMock.mock.calls[0]?.[1];
68+
expect(connectionConfig?.proxy).toEqual({ useEnvironmentVariableProxies: true });
69+
expect(connectionConfig?.applyProxyToOIDC).toEqual(true);
70+
});
5971
});
6072
});

0 commit comments

Comments
 (0)