@@ -368,12 +368,14 @@ function testEscapeURIPathPreservesDoubleSlashes() {
368
368
}
369
369
}
370
370
371
- function testReadCredentialsWithAccessAndSecretKeySet ( ) {
372
- printHeader ( 'testReadCredentialsWithAccessAndSecretKeySet ' ) ;
371
+ function testReadCredentialsWithAccessSecretKeyAndSessionTokenSet ( ) {
372
+ printHeader ( 'testReadCredentialsWithAccessSecretKeyAndSessionTokenSet ' ) ;
373
373
let r = { } ;
374
374
process . env [ 'S3_ACCESS_KEY_ID' ] = 'SOME_ACCESS_KEY' ;
375
375
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
+ }
377
379
378
380
try {
379
381
var credentials = s3gateway . readCredentials ( r ) ;
@@ -383,8 +385,14 @@ function testReadCredentialsWithAccessAndSecretKeySet() {
383
385
if ( credentials . secretAccessKey !== process . env [ 'S3_SECRET_KEY' ] ) {
384
386
throw 'static credentials do not match returned value [secretAccessKey]' ;
385
387
}
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
+ }
388
396
}
389
397
if ( credentials . expiration !== null ) {
390
398
throw 'static credentials do not match returned value [expiration]' ;
@@ -710,7 +718,7 @@ async function test() {
710
718
testEditHeaders ( ) ;
711
719
testEditHeadersHeadDirectory ( ) ;
712
720
testEscapeURIPathPreservesDoubleSlashes ( ) ;
713
- testReadCredentialsWithAccessAndSecretKeySet ( ) ;
721
+ testReadCredentialsWithAccessSecretKeyAndSessionTokenSet ( ) ;
714
722
testReadCredentialsFromFilePath ( ) ;
715
723
testReadCredentialsFromNonexistentPath ( ) ;
716
724
testReadAndWriteCredentialsFromKeyValStore ( ) ;
0 commit comments