@@ -353,6 +353,39 @@ public function testResolveCredentialsWithAccountId()
353
353
354
354
}
355
355
356
+ public function testResolveCredentialsWithAccountIdFromArn ()
357
+ {
358
+ $ testAccountId = 'foo ' ;
359
+ $ testArn = "arn:aws:iam:: $ testAccountId:role/role_name " ;
360
+ $ expiration = time () + 1000 ;
361
+ $ testHandler = function (RequestInterface $ _ ) use ($ expiration , $ testArn ) {
362
+ $ jsonResponse = <<<EOF
363
+ {
364
+ "AccessKeyId": "foo",
365
+ "SecretAccessKey": "foo",
366
+ "Token": "bazz",
367
+ "Expiration": "@ $ expiration",
368
+ "RoleArn": " $ testArn"
369
+ }
370
+ EOF ;
371
+ return Promise \Create::promiseFor (new Response (200 , [], $ jsonResponse ));
372
+ };
373
+ $ provider = new EcsCredentialProvider ([
374
+ 'client ' => $ testHandler
375
+ ]);
376
+ try {
377
+ /** @var Credentials $credentials */
378
+ $ credentials = $ provider ()->wait ();
379
+ $ this ->assertSame ('foo ' , $ credentials ->getAccessKeyId ());
380
+ $ this ->assertSame ('foo ' , $ credentials ->getSecretKey ());
381
+ $ this ->assertSame ('bazz ' , $ credentials ->getSecurityToken ());
382
+ $ this ->assertSame ($ expiration , $ credentials ->getExpiration ());
383
+ $ this ->assertSame ($ testAccountId , $ credentials ->getAccountId ());
384
+ } catch (GuzzleException $ e ) {
385
+ self ::fail ($ e ->getMessage ());
386
+ }
387
+ }
388
+
356
389
/**
357
390
* @dataProvider successTestCases
358
391
*
0 commit comments