@@ -368,12 +368,14 @@ function testEscapeURIPathPreservesDoubleSlashes() {
368368 }
369369}
370370
371- function testReadCredentialsWithAccessAndSecretKeySet ( ) {
372- printHeader ( 'testReadCredentialsWithAccessAndSecretKeySet ' ) ;
371+ function testReadCredentialsWithAccessSecretKeyAndSessionTokenSet ( ) {
372+ printHeader ( 'testReadCredentialsWithAccessSecretKeyAndSessionTokenSet ' ) ;
373373 let r = { } ;
374374 process . env [ 'S3_ACCESS_KEY_ID' ] = 'SOME_ACCESS_KEY' ;
375375 process . env [ 'S3_SECRET_KEY' ] = 'SOME_SECRET_KEY' ;
376- process . env [ 'S3_SESSION_TOKEN' ] = 'SOME_SESSION_TOKEN' ;
376+ if ( 'S3_SESSION_TOKEN' in process . env ) {
377+ process . env [ 'S3_SESSION_TOKEN' ] = 'SOME_SESSION_TOKEN' ;
378+ }
377379
378380 try {
379381 var credentials = s3gateway . readCredentials ( r ) ;
@@ -383,8 +385,14 @@ function testReadCredentialsWithAccessAndSecretKeySet() {
383385 if ( credentials . secretAccessKey !== process . env [ 'S3_SECRET_KEY' ] ) {
384386 throw 'static credentials do not match returned value [secretAccessKey]' ;
385387 }
386- if ( credentials . sessionToken !== process . env [ 'S3_SESSION_TOKEN' ] ) {
387- throw 'static credentials do not match returned value [sessionToken]' ;
388+ if ( 'S3_SESSION_TOKEN' in process . env ) {
389+ if ( credentials . sessionToken !== process . env [ 'S3_SESSION_TOKEN' ] ) {
390+ throw 'static credentials do not match returned value [sessionToken]' ;
391+ }
392+ } else {
393+ if ( credentials . sessionToken !== null ) {
394+ throw 'static credentials do not match returned value [sessionToken]' ;
395+ }
388396 }
389397 if ( credentials . expiration !== null ) {
390398 throw 'static credentials do not match returned value [expiration]' ;
@@ -710,7 +718,7 @@ async function test() {
710718 testEditHeaders ( ) ;
711719 testEditHeadersHeadDirectory ( ) ;
712720 testEscapeURIPathPreservesDoubleSlashes ( ) ;
713- testReadCredentialsWithAccessAndSecretKeySet ( ) ;
721+ testReadCredentialsWithAccessSecretKeyAndSessionTokenSet ( ) ;
714722 testReadCredentialsFromFilePath ( ) ;
715723 testReadCredentialsFromNonexistentPath ( ) ;
716724 testReadAndWriteCredentialsFromKeyValStore ( ) ;
0 commit comments