Skip to content

Commit

Permalink
ignore to set AWS_ACCESS_KEY_ID & AWS_SECRET_ACCESS_KEY
Browse files Browse the repository at this point in the history
  • Loading branch information
giraphme committed Dec 8, 2020
1 parent 28b2f33 commit 9a37e11
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 23 deletions.
8 changes: 3 additions & 5 deletions lib/exception_notifier/sns_notifier.rb
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
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

0 comments on commit 9a37e11

Please sign in to comment.