@@ -298,6 +298,31 @@ function testEscapeURIPathPreservesDoubleSlashes() {
298298 }
299299}
300300
301+ function testReadCredentialsWithAccessAndSecretKeySet ( ) {
302+ process . env [ 'S3_ACCESS_KEY_ID' ] = 'SOME_ACCESS_KEY' ;
303+ process . env [ 'S3_SECRET_KEY' ] = 'SOME_SECRET_KEY' ;
304+
305+ try {
306+ var credentials = s3gateway . readCredentials ( ) ;
307+ if ( credentials . accessKeyId !== process . env [ 'S3_ACCESS_KEY_ID' ] ) {
308+ throw 'static credentials do not match returned value [accessKeyId]' ;
309+ }
310+ if ( credentials . secretAccessKey !== process . env [ 'S3_SECRET_KEY' ] ) {
311+ throw 'static credentials do not match returned value [secretAccessKey]' ;
312+ }
313+ if ( credentials . sessionToken !== null ) {
314+ throw 'static credentials do not match returned value [sessionToken]' ;
315+ }
316+ if ( credentials . expiration !== null ) {
317+ throw 'static credentials do not match returned value [expiration]' ;
318+ }
319+
320+ } finally {
321+ delete process . env . S3_ACCESS_KEY_ID ;
322+ delete process . env . S3_SECRET_KEY ;
323+ }
324+ }
325+
301326function testReadCredentials ( ) {
302327 var originalCredentialPath = process . env [ 'S3_CREDENTIALS_TEMP_FILE' ] ;
303328 var tempDir = ( process . env [ 'TMPDIR' ] ? process . env [ 'TMPDIR' ] : '/tmp' ) ;
@@ -485,8 +510,9 @@ async function test() {
485510 testEditAmzHeaders ( ) ;
486511 testEditAmzHeadersHeadDirectory ( ) ;
487512 testEscapeURIPathPreservesDoubleSlashes ( ) ;
488- testReadCredentialsFromNonexistentPath ( ) ;
513+ testReadCredentialsWithAccessAndSecretKeySet ( ) ;
489514 testReadCredentials ( ) ;
515+ testReadCredentialsFromNonexistentPath ( ) ;
490516 await testEcsCredentialRetrieval ( ) ;
491517 await testEc2CredentialRetrieval ( ) ;
492518}
0 commit comments