1+ import { expect } from 'chai' ;
2+ import { once } from 'events' ;
3+
4+ import { MongoClient } from '../../../src' ;
15import { loadSpecTests } from '../../spec' ;
26import { CmapTest , runCmapTestSuite } from '../../tools/cmap_spec_runner' ;
37
@@ -16,4 +20,37 @@ describe('Connection Monitoring and Pooling (Node Driver)', function () {
1620 }
1721 ]
1822 } ) ;
23+
24+ describe ( 'ConnectionPoolCreatedEvent' , ( ) => {
25+ let client : MongoClient ;
26+ beforeEach ( async function ( ) {
27+ client = this . configuration . newClient ( ) ;
28+ } ) ;
29+
30+ afterEach ( async function ( ) {
31+ await client . close ( ) ;
32+ } ) ;
33+
34+ describe ( 'constructor()' , ( ) => {
35+ it ( 'when auth is enabled redacts credentials from options' , {
36+ metadata : { requires : { auth : 'enabled' } } ,
37+ async test ( ) {
38+ const poolCreated = once ( client , 'connectionPoolCreated' ) ;
39+ await client . connect ( ) ;
40+ const [ event ] = await poolCreated ;
41+ expect ( event ) . to . have . deep . nested . property ( 'options.credentials' , { } ) ;
42+ }
43+ } ) ;
44+
45+ it ( 'when auth is disabled does not add a credentials property to options' , {
46+ metadata : { requires : { auth : 'disabled' } } ,
47+ async test ( ) {
48+ const poolCreated = once ( client , 'connectionPoolCreated' ) ;
49+ await client . connect ( ) ;
50+ const [ event ] = await poolCreated ;
51+ expect ( event ) . to . not . have . nested . property ( 'options.credentials' ) ;
52+ }
53+ } ) ;
54+ } ) ;
55+ } ) ;
1956} ) ;
0 commit comments