Skip to content

Commit

Permalink
Fixed response stubbing credentials.
Browse files Browse the repository at this point in the history
The `Aws::DefaultCredentialChain` is no longer used when
setting `stub_responses: true`.

Fixes #835
  • Loading branch information
trevorrowe committed Jun 5, 2015
1 parent 166adfe commit 2f0bc10
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Unreleased Changes
------------------

* Issue - Response Stubbing - When enabling response stubbing via
`stub_responses: true` on a client, the default credential chain is longer
used to source credentials. Instead a set of fake stubbed static credentials
are used by default.

See [related GitHub issue #835](https://github.com/aws/aws-sdk-ruby/pull/835)

2.0.48 (2015-06-04)
------------------

Expand Down
1 change: 1 addition & 0 deletions aws-sdk-core/lib/aws-sdk-core/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class Client < Seahorse::Client::Base
'Aws::Plugins::GlobalConfiguration',
'Aws::Plugins::RegionalEndpoint',
'Aws::Plugins::RequestSigner',
'Aws::Plugins::StubResponses',
]

include ClientPaging
Expand Down
5 changes: 0 additions & 5 deletions aws-sdk-core/lib/aws-sdk-core/client_stubs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ module Aws
# behavior.
module ClientStubs

# @api private
def self.included(subclass)
subclass.add_plugin('Aws::Plugins::StubResponses')
end

def initialize(*args)
@stubs = {}
@stub_mutex = Mutex.new
Expand Down
10 changes: 9 additions & 1 deletion aws-sdk-core/spec/aws/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,15 @@ module Aws
secret_access_key: 'secret',
}}

describe '#stub' do
describe 'response stubbing' do

it 'skips the credential provider chain' do
expect(Aws::CredentialProviderChain).not_to receive(:new)
creds = S3::Client.new(stub_responses:true).config.credentials
expect(creds).to be_kind_of(Credentials)
expect(creds.access_key_id).to eq('stubbed-akid')
expect(creds.secret_access_key).to eq('stubbed-secret')
end

it 'raises an error if stubbed_responses is not enabled' do
client = S3::Client.new(options.merge(stub_responses: false))
Expand Down

0 comments on commit 2f0bc10

Please sign in to comment.