Skip to content

Support QueueUrl Plugin override #2148

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions gems/aws-sdk-sqs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Unreleased Changes
------------------

* Issue - Support setting `:disable_queue_url_override` to `true` for disabling endpoint and region override from `:queue_url` value (Github #2114)

1.23.0 (2019-10-23)
------------------

Expand Down
12 changes: 11 additions & 1 deletion gems/aws-sdk-sqs/lib/aws-sdk-sqs/plugins/queue_urls.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,20 @@ module Plugins
# @api private
class QueueUrls < Seahorse::Client::Plugin

option(:disable_queue_url_override,
default: false,
doc_type: 'Boolean',
docstring: <<-DOCS
Set to `true` to disable region and endpoint override from
`:queue_url` value, default to `false`
DOCS
)

class Handler < Seahorse::Client::Handler

def call(context)
if queue_url = context.params[:queue_url]
disable = !!context.config.disable_queue_url_override
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid use of double negation (as per Rubocop). Use .nil?

if !disable && (queue_url = context.params[:queue_url])
update_endpoint(context, queue_url)
update_region(context, queue_url)
end
Expand Down
10 changes: 10 additions & 0 deletions gems/aws-sdk-sqs/spec/client/queue_urls_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ module SQS
client.send(method, params.merge(queue_url: url))
}.to_not raise_error
end

it 'does not override endpoint and region when disabled' do
endpoint = 'https://vpc-123234.sqs.us-west-2.vpc.amazonaws.com'
url = 'https://sqs.us-east-1.amazonaws.com/1234567890/demo'
client = Client.new(stub_responses: true, endpoint: endpoint, disable_queue_url_override: true)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check for 80 chars!

resp = client.send(method, params.merge(queue_url: url))
expect(resp.context.http_request.endpoint.to_s).to eq(endpoint)
expect(resp.context.http_request.headers['authorization']).not_to include('us-east-1')
expect(resp.context.http_request.headers['authorization']).to include('us-stubbed-1')
end
end
end
end
Expand Down