@@ -13,14 +13,6 @@ module Aws
1313 '..' , 'fixtures' , 'credentials' , 'mock_shared_config' ) )
1414 }
1515
16- let ( :imds_url ) {
17- 'http://169.254.169.254/latest/meta-data/iam/security-credentials/'
18- }
19-
20- let ( :imds_token_url ) {
21- 'http://169.254.169.254/latest/api/token'
22- }
23-
2416 describe "default behavior" do
2517 before ( :each ) do
2618 stub_const ( 'ENV' , { } )
@@ -64,32 +56,28 @@ module Aws
6456 "AR_TOKEN"
6557 )
6658 client = Aws ::S3 ::Client . new ( profile : "ar_plus_creds" , region : "us-east-1" )
67- expect ( client . config . credentials . credentials . access_key_id ) . to eq ( "AR_AKID" )
59+ expect ( client . config . credentials . access_key_id ) . to eq ( "AR_AKID" )
6860 end
6961
7062 it 'prefers shared credential file static credentials over shared config' do
7163 client = Aws ::S3 ::Client . new ( profile : "credentials_first" , region : "us-east-1" )
72- expect ( client . config . credentials . credentials . access_key_id ) . to eq ( "ACCESS_KEY_CRD" )
64+ expect ( client . config . credentials . access_key_id ) . to eq ( "ACCESS_KEY_CRD" )
7365 end
7466
7567 it 'will source static credentials from shared config after shared credentials' do
7668 client = Aws ::S3 ::Client . new ( profile : "incomplete_cred" , region : "us-east-1" )
77- expect ( client . config . credentials . credentials . access_key_id ) . to eq ( "ACCESS_KEY_SC1" )
69+ expect ( client . config . credentials . access_key_id ) . to eq ( "ACCESS_KEY_SC1" )
7870 end
7971
8072 it 'attempts to fetch metadata credentials last' do
81- stub_request ( :put , imds_token_url )
82- . to_return (
83- :status => 200 ,
84- :body => "my-token\n " ,
85- :headers => { "x-aws-ec2-metadata-token-ttl-seconds" : "21600" }
86- )
87- stub_request ( :get , imds_url )
88- . with ( :headers => { "x-aws-ec2-metadata-token" : "my-token" } )
89- . to_return ( :status => 200 , :body => "profile-name\n " )
90- stub_request ( :get , "#{ imds_url } profile-name" )
91- . with ( :headers => { "x-aws-ec2-metadata-token" : "my-token" } )
92- . to_return ( :status => 200 , :body => <<-JSON . strip )
73+ stub_request (
74+ :get ,
75+ "http://169.254.169.254/latest/meta-data/iam/security-credentials/"
76+ ) . to_return ( :status => 200 , :body => "profile-name\n " )
77+ stub_request (
78+ :get ,
79+ "http://169.254.169.254/latest/meta-data/iam/security-credentials/profile-name"
80+ ) . to_return ( :status => 200 , :body => <<-JSON . strip )
9381{
9482 "Code" : "Success",
9583 "LastUpdated" : "2013-11-22T20:03:48Z",
@@ -101,11 +89,11 @@ module Aws
10189}
10290JSON
10391 client = Aws ::S3 ::Client . new ( profile : "nonexistant" , region : "us-east-1" )
104- expect ( client . config . credentials . credentials . access_key_id ) . to eq ( "akid-md" )
92+ expect ( client . config . credentials . access_key_id ) . to eq ( "akid-md" )
10593 end
10694
10795 describe 'Assume Role Resolution' do
108- it 'will not assume a role without a source present' do
96+ it 'will not assume a role without source_profile present' do
10997 expect {
11098 Aws ::S3 ::Client . new ( profile : "ar_no_src" , region : "us-east-1" )
11199 } . to raise_error ( Errors ::NoSourceProfileError )
@@ -126,7 +114,7 @@ module Aws
126114 "AR_TOKEN"
127115 )
128116 client = Aws ::S3 ::Client . new ( profile : "assumerole_sc" , region : "us-east-1" )
129- expect ( client . config . credentials . credentials . access_key_id ) . to eq ( "AR_AKID" )
117+ expect ( client . config . credentials . access_key_id ) . to eq ( "AR_AKID" )
130118 end
131119
132120 it 'will then try to assume a role from shared config' do
@@ -138,7 +126,7 @@ module Aws
138126 "AR_TOKEN"
139127 )
140128 client = Aws ::S3 ::Client . new ( profile : "ar_from_self" , region : "us-east-1" )
141- expect ( client . config . credentials . credentials . access_key_id ) . to eq ( "AR_AKID" )
129+ expect ( client . config . credentials . access_key_id ) . to eq ( "AR_AKID" )
142130 end
143131
144132 it 'will assume a role from config using source credentials in shared credentials' do
@@ -150,10 +138,9 @@ module Aws
150138 "AR_TOKEN"
151139 )
152140 client = Aws ::S3 ::Client . new ( profile : "creds_from_sc" , region : "us-east-1" )
153- expect ( client . config . credentials . credentials . access_key_id ) . to eq ( "AR_AKID" )
141+ expect ( client . config . credentials . access_key_id ) . to eq ( "AR_AKID" )
154142 end
155143 end
156-
157144 end
158145
159146 describe "AWS_SDK_CONFIG_OPT_OUT set" do
@@ -178,7 +165,7 @@ module Aws
178165 profile : "fooprofile" ,
179166 region : "us-east-1"
180167 )
181- expect ( client . config . credentials . credentials . access_key_id ) . to eq ( "ACCESS_DIRECT" )
168+ expect ( client . config . credentials . access_key_id ) . to eq ( "ACCESS_DIRECT" )
182169 end
183170
184171 it 'prefers ENV credentials over shared config' do
@@ -187,7 +174,7 @@ module Aws
187174 "AWS_SECRET_ACCESS_KEY" => "SECRET_ENV_STUB"
188175 } )
189176 client = Aws ::S3 ::Client . new ( profile : "fooprofile" , region : "us-east-1" )
190- expect ( client . config . credentials . credentials . access_key_id ) . to eq ( "AKID_ENV_STUB" )
177+ expect ( client . config . credentials . access_key_id ) . to eq ( "AKID_ENV_STUB" )
191178 end
192179
193180 it 'will not load credentials from shared config' do
@@ -201,18 +188,14 @@ module Aws
201188 end
202189
203190 it 'attempts to fetch metadata credentials last' do
204- stub_request ( :put , imds_token_url )
205- . to_return (
206- :status => 200 ,
207- :body => "my-token\n " ,
208- :headers => { "x-aws-ec2-metadata-token-ttl-seconds" : "21600" }
209- )
210- stub_request ( :get , imds_url )
211- . with ( :headers => { "x-aws-ec2-metadata-token" : "my-token" } )
212- . to_return ( :status => 200 , :body => "profile-name\n " )
213- stub_request ( :get , "#{ imds_url } profile-name" )
214- . with ( :headers => { "x-aws-ec2-metadata-token" : "my-token" } )
215- . to_return ( :status => 200 , :body => <<-JSON . strip )
191+ stub_request (
192+ :get ,
193+ "http://169.254.169.254/latest/meta-data/iam/security-credentials/"
194+ ) . to_return ( :status => 200 , :body => "profile-name\n " )
195+ stub_request (
196+ :get ,
197+ "http://169.254.169.254/latest/meta-data/iam/security-credentials/profile-name"
198+ ) . to_return ( :status => 200 , :body => <<-JSON . strip )
216199{
217200 "Code" : "Success",
218201 "LastUpdated" : "2013-11-22T20:03:48Z",
@@ -224,7 +207,7 @@ module Aws
224207}
225208JSON
226209 client = Aws ::S3 ::Client . new ( profile : "nonexistant" , region : "us-east-1" )
227- expect ( client . config . credentials . credentials . access_key_id ) . to eq ( "akid-md" )
210+ expect ( client . config . credentials . access_key_id ) . to eq ( "akid-md" )
228211 end
229212 end
230213
0 commit comments