@@ -758,17 +758,21 @@ describe('MONGODB-OIDC', function () {
758
758
} ) ;
759
759
760
760
describe ( '4.4 Error clears cache' , function ( ) {
761
- before ( function ( ) {
761
+ const authMechanismProperties = {
762
+ REQUEST_TOKEN_CALLBACK : createRequestCallback ( 'test_user1' , 300 ) ,
763
+ REFRESH_TOKEN_CALLBACK : ( ) => {
764
+ return Promise . resolve ( { } ) ;
765
+ }
766
+ } ;
767
+
768
+ before ( async function ( ) {
762
769
cache . clear ( ) ;
763
770
client = new MongoClient ( 'mongodb://localhost/?authMechanism=MONGODB-OIDC' , {
764
- authMechanismProperties : {
765
- REQUEST_TOKEN_CALLBACK : createRequestCallback ( 'test_user1' , 300 ) ,
766
- REFRESH_TOKEN_CALLBACK : ( ) => {
767
- return Promise . resolve ( { } ) ;
768
- }
769
- }
771
+ authMechanismProperties : authMechanismProperties
770
772
} ) ;
771
- collection = client . db ( 'test' ) . collection ( 'test' ) ;
773
+ await client . db ( 'test' ) . collection ( 'test' ) . findOne ( ) ;
774
+ expect ( cache . entries . size ) . to . equal ( 1 ) ;
775
+ await client . close ( ) ;
772
776
} ) ;
773
777
774
778
// Clear the cache.
@@ -778,10 +782,11 @@ describe('MONGODB-OIDC', function () {
778
782
// Ensure that the cached token has been cleared.
779
783
// Close the client.
780
784
it ( 'clears the cache on authentication error' , async function ( ) {
781
- await collection . findOne ( ) ;
782
- expect ( cache . entries . size ) . to . equal ( 1 ) ;
785
+ client = new MongoClient ( 'mongodb://localhost/?authMechanism=MONGODB-OIDC' , {
786
+ authMechanismProperties : authMechanismProperties
787
+ } ) ;
783
788
try {
784
- await collection . findOne ( ) ;
789
+ await client . db ( 'test' ) . collection ( 'test' ) . findOne ( ) ;
785
790
expect . fail ( 'Expected OIDC auth to fail with invalid fields from refresh callback' ) ;
786
791
} catch ( error ) {
787
792
expect ( error ) . to . be . instanceOf ( MongoMissingCredentialsError ) ;
0 commit comments