Skip to content
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

Ignore to set access_key_id & secret_access_key on AWS SNS Notifier #502

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
8 changes: 3 additions & 5 deletions lib/exception_notifier/sns_notifier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@ class SnsNotifier < BaseNotifier
def initialize(options)
super

allowed_keys = %i[region access_key_id secret_access_key]

raise ArgumentError, "You must provide 'region' option" unless options[:region]
raise ArgumentError, "You must provide 'access_key_id' option" unless options[:access_key_id]
raise ArgumentError, "You must provide 'secret_access_key' option" unless options[:secret_access_key]

@notifier = Aws::SNS::Client.new(
region: options[:region],
access_key_id: options[:access_key_id],
secret_access_key: options[:secret_access_key]
**options.select { |k, _| allowed_keys.include?(k) }
)
@options = default_options.merge(options)
end
Expand Down
18 changes: 0 additions & 18 deletions test/exception_notifier/sns_notifier_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,6 @@ def setup
assert_equal "You must provide 'region' option", error.message
end

test 'should raise an exception on publish if access_key_id is not received' do
@options[:access_key_id] = nil
error = assert_raises ArgumentError do
ExceptionNotifier::SnsNotifier.new(@options)
end

assert_equal "You must provide 'access_key_id' option", error.message
end

test 'should raise an exception on publish if secret_access_key is not received' do
@options[:secret_access_key] = nil
error = assert_raises ArgumentError do
ExceptionNotifier::SnsNotifier.new(@options)
end

assert_equal "You must provide 'secret_access_key' option", error.message
end

# call

test 'should send a sns notification in background' do
Expand Down