forked from mongodb/node-mongodb-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauth_provider.test.ts
More file actions
28 lines (24 loc) · 946 Bytes
/
auth_provider.test.ts
File metadata and controls
28 lines (24 loc) · 946 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { expect } from 'chai';
import { type AuthContext, AuthProvider } from '../../../../src/cmap/auth/auth_provider';
import { MongoRuntimeError } from '../../../../src/error';
describe('AuthProvider', function () {
describe('#reauth', function () {
context('when the provider is already reauthenticating', function () {
const provider = new (class extends AuthProvider {
override auth(_context: AuthContext): Promise<void> {
throw new Error('Method not implemented.');
}
})();
const context = { reauthenticating: true };
it('returns an error', async function () {
const error = await provider.reauth(context).then(
() => null,
error => error
);
expect(error).to.exist;
expect(error).to.be.instanceOf(MongoRuntimeError);
expect(error?.message).to.equal('Reauthentication already in progress.');
});
});
});
});