Skip to content

Commit 7ac0516

Browse files
committed
Support using Aws::Google.config without any shared AWS config
1 parent 4232c19 commit 7ac0516

File tree

2 files changed

+30
-5
lines changed

2 files changed

+30
-5
lines changed

lib/aws/google/credential_provider.rb

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,17 @@ def google_credentials(options)
2222

2323
module GoogleSharedCredentials
2424
def google_credentials_from_config(opts = {})
25-
p = opts[:profile] || @profile_name
25+
google_opts = {}
2626
if @config_enabled && @parsed_config
27-
google_opts = @parsed_config.
27+
p = opts[:profile] || @profile_name
28+
google_opts.merge!(@parsed_config.
2829
fetch(p, {}).fetch('google', {}).
2930
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)
3336
end
3437
end
3538
end

test/aws/google_test.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,5 +204,27 @@
204204
Aws::Google.new(config).credentials
205205
end
206206
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
207229
end
208230
end

0 commit comments

Comments
 (0)