File tree Expand file tree Collapse file tree 2 files changed +30
-5
lines changed Expand file tree Collapse file tree 2 files changed +30
-5
lines changed Original file line number Diff line number Diff line change @@ -22,14 +22,17 @@ def google_credentials(options)
22
22
23
23
module GoogleSharedCredentials
24
24
def google_credentials_from_config ( opts = { } )
25
- p = opts [ :profile ] || @profile_name
25
+ google_opts = { }
26
26
if @config_enabled && @parsed_config
27
- google_opts = @parsed_config .
27
+ p = opts [ :profile ] || @profile_name
28
+ google_opts . merge! ( @parsed_config .
28
29
fetch ( p , { } ) . fetch ( 'google' , { } ) .
29
30
transform_keys ( &:to_sym )
30
- if google_opts . merge ( ::Aws ::Google . config ) . has_key? ( :role_arn )
31
- Google . new ( google_opts )
32
- end
31
+ )
32
+ end
33
+ google_opts . merge! ( ::Aws ::Google . config )
34
+ if google_opts . has_key? ( :role_arn )
35
+ Google . new ( google_opts )
33
36
end
34
37
end
35
38
end
Original file line number Diff line number Diff line change 204
204
Aws ::Google . new ( config ) . credentials
205
205
end
206
206
end
207
+
208
+ describe 'no shared config' do
209
+ before do
210
+ Aws . shared_config . fresh (
211
+ config_enabled : true ,
212
+ credentials_path : nil ,
213
+ config_path : nil
214
+ )
215
+ end
216
+
217
+ it 'creates client credentials from Google config' do
218
+ Aws ::Google . stubs ( :config ) . returns ( config )
219
+
220
+ @oauth_default . once
221
+ system . times ( 5 )
222
+
223
+ c = Aws ::STS ::Client . new ( region : 'us-east-1' ) . config . credentials
224
+ _ ( c . credentials . access_key_id ) . must_equal credentials [ :access_key_id ]
225
+ _ ( c . credentials . secret_access_key ) . must_equal credentials [ :secret_access_key ]
226
+ _ ( c . credentials . session_token ) . must_equal credentials [ :session_token ]
227
+ end
228
+ end
207
229
end
208
230
end
You can’t perform that action at this time.
0 commit comments