|
1 | 1 | import { expect } from 'chai'; |
2 | 2 | import * as sinon from 'sinon'; |
3 | 3 |
|
4 | | -// eslint-disable-next-line @typescript-eslint/no-restricted-imports |
5 | | -import { AutomatedCallbackWorkflow } from '../../../../../src/cmap/auth/mongodb_oidc/automated_callback_workflow'; |
6 | 4 | // eslint-disable-next-line @typescript-eslint/no-restricted-imports |
7 | 5 | import { callback } from '../../../../../src/cmap/auth/mongodb_oidc/gcp_machine_workflow'; |
8 | 6 | // eslint-disable-next-line @typescript-eslint/no-restricted-imports |
9 | 7 | 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'; |
11 | 14 |
|
12 | 15 | describe('AutomatedCallbackWorkflow', function () { |
13 | 16 | describe('#execute', function () { |
14 | 17 | 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. |
15 | 22 | context('when the connection has no token', function () { |
16 | 23 | 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(); |
19 | 27 | const workflow = new AutomatedCallbackWorkflow(cache, callback); |
20 | | - sinon.stub(workflow, 'finishAuthentication').returns(Promise.resolve()); |
21 | 28 |
|
22 | 29 | beforeEach(function () { |
23 | 30 | cache.put({ accessToken: 'test', expiresInSeconds: 7200 }); |
24 | 31 | workflow.execute(connection, credentials); |
25 | 32 | }); |
26 | 33 |
|
27 | 34 | afterEach(function () { |
28 | | - sinon.restore(); |
| 35 | + sandbox.restore(); |
29 | 36 | }); |
30 | 37 |
|
31 | 38 | it('sets the token on the connection', async function () { |
|
0 commit comments