Skip to content

Commit 289f4fc

Browse files
committed
fix: test
1 parent 72aad53 commit 289f4fc

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

test/mongodb.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ export * from '../src/cmap/auth/gssapi';
119119
export * from '../src/cmap/auth/mongo_credentials';
120120
export * from '../src/cmap/auth/mongodb_aws';
121121
export * from '../src/cmap/auth/mongodb_oidc';
122+
export * from '../src/cmap/auth/mongodb_oidc/automated_callback_workflow';
122123
export * from '../src/cmap/auth/mongodb_oidc/azure_machine_workflow';
123124
export * from '../src/cmap/auth/mongodb_oidc/callback_workflow';
124125
export * from '../src/cmap/auth/plain';

test/unit/cmap/auth/mongodb_oidc/automated_callback_workflow.test.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,38 @@
11
import { expect } from 'chai';
22
import * as sinon from 'sinon';
33

4-
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
5-
import { AutomatedCallbackWorkflow } from '../../../../../src/cmap/auth/mongodb_oidc/automated_callback_workflow';
64
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
75
import { callback } from '../../../../../src/cmap/auth/mongodb_oidc/gcp_machine_workflow';
86
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
97
import { TokenCache } from '../../../../../src/cmap/auth/mongodb_oidc/token_cache';
10-
import { Connection, MongoCredentials } from '../../../../mongodb';
8+
import {
9+
AutomatedCallbackWorkflow,
10+
CallbackWorkflow,
11+
Connection,
12+
MongoCredentials
13+
} from '../../../../mongodb';
1114

1215
describe('AutomatedCallbackWorkflow', function () {
1316
describe('#execute', function () {
1417
context('when the cache has a token', function () {
18+
const sandbox = sinon.createSandbox();
19+
20+
// See NODE-6801 and corresponding PR: https://github.com/mongodb/node-mongodb-native/pull/4438
21+
// This is a test to ensure that we do not regress on the above issue. Do NOT remove this test.
1522
context('when the connection has no token', function () {
1623
const cache = new TokenCache();
17-
const connection = sinon.createStubInstance(Connection);
18-
const credentials = sinon.createStubInstance(MongoCredentials);
24+
const connection = sandbox.createStubInstance(Connection);
25+
const credentials = sandbox.createStubInstance(MongoCredentials);
26+
sandbox.stub(CallbackWorkflow.prototype, 'finishAuthentication').resolves();
1927
const workflow = new AutomatedCallbackWorkflow(cache, callback);
20-
sinon.stub(workflow, 'finishAuthentication').returns(Promise.resolve());
2128

2229
beforeEach(function () {
2330
cache.put({ accessToken: 'test', expiresInSeconds: 7200 });
2431
workflow.execute(connection, credentials);
2532
});
2633

2734
afterEach(function () {
28-
sinon.restore();
35+
sandbox.restore();
2936
});
3037

3138
it('sets the token on the connection', async function () {

0 commit comments

Comments
 (0)