@@ -90,6 +90,26 @@ describe('connection secrets', function () {
9090 } ,
9191 } as ConnectionInfo ) ;
9292 } ) ;
93+
94+ it ( 'merges secrets for a cosmosdb connection string' , function ( ) {
95+ const originalConnectionInfo : ConnectionInfo = {
96+ connectionOptions : {
97+ connectionString :
98+ 'mongodb://[email protected] :8888/?ssl=true&replicaSet=globaldb&retrywrites=false&maxIdleTimeMS=120000&appName=@database-haha@' , 99+ } ,
100+ } ;
101+
102+ const newConnectionInfo = mergeSecrets ( originalConnectionInfo , {
103+ password : 'userPassword' ,
104+ } ) ;
105+
106+ expect ( newConnectionInfo ) . to . be . deep . equal ( {
107+ connectionOptions : {
108+ connectionString :
109+ 'mongodb://database-ut:[email protected] :8888/?ssl=true&replicaSet=globaldb&retrywrites=false&maxIdleTimeMS=120000&appName=@database-haha@' , 110+ } ,
111+ } as ConnectionInfo ) ;
112+ } ) ;
93113 } ) ;
94114
95115 describe ( 'extractSecrets' , function ( ) {
@@ -321,5 +341,47 @@ describe('connection secrets', function () {
321341 ) ;
322342 expect ( secretsNoFle ) . to . deep . equal ( _ . omit ( secrets , 'autoEncryption' ) ) ;
323343 } ) ;
344+
345+ it ( 'extracts secrets for a cosmosdb connection string' , function ( ) {
346+ const originalConnectionInfo : ConnectionInfo = {
347+ connectionOptions : {
348+ connectionString :
349+ 'mongodb://database-ut:[email protected] :8888/?ssl=true&replicaSet=globaldb&retrywrites=false&maxIdleTimeMS=120000&appName=@database-haha@' , 350+ } ,
351+ } ;
352+
353+ const { connectionInfo : newConnectionInfo , secrets } = extractSecrets (
354+ originalConnectionInfo
355+ ) ;
356+
357+ expect ( newConnectionInfo ) . to . be . deep . equal ( {
358+ connectionOptions : {
359+ connectionString :
360+ 'mongodb://[email protected] :8888/?ssl=true&replicaSet=globaldb&retrywrites=false&maxIdleTimeMS=120000&appName=@database-haha@' , 361+ } ,
362+ } as ConnectionInfo ) ;
363+
364+ expect ( secrets ) . to . be . deep . equal ( {
365+ password : 'somerandomsecret' ,
366+ } as ConnectionSecrets ) ;
367+
368+ const { connectionInfo : newConnectionInfoNoFle , secrets : secretsNoFle } =
369+ extractSecrets (
370+ _ . set (
371+ _ . cloneDeep ( originalConnectionInfo ) ,
372+ 'connectionOptions.fleOptions.storeCredentials' ,
373+ false
374+ )
375+ ) ;
376+
377+ expect ( newConnectionInfoNoFle ) . to . deep . equal (
378+ _ . set (
379+ _ . cloneDeep ( newConnectionInfo ) ,
380+ 'connectionOptions.fleOptions.storeCredentials' ,
381+ false
382+ )
383+ ) ;
384+ expect ( secretsNoFle ) . to . deep . equal ( _ . omit ( secrets , 'autoEncryption' ) ) ;
385+ } ) ;
324386 } ) ;
325387} ) ;
0 commit comments