Skip to content

Commit

Permalink
filters/keys: don't try to filter already filtered value
Browse files Browse the repository at this point in the history
Fixes #276 (Specifying `blacklist_keys` with `whitelist_keys` can result in
error)
  • Loading branch information
kyrylo committed Oct 26, 2017
1 parent ab09ab3 commit baee1c8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/airbrake-ruby/filters/keys_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ def validate_patterns

def filter_context_key(notice, key)
return unless notice[:context][key]
return if notice[:context][key] == FILTERED
return filter_hash(notice[:context][key]) unless should_filter?(key)

notice[:context][key] = FILTERED
Expand Down
18 changes: 18 additions & 0 deletions spec/notifier_spec/options_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -226,5 +226,23 @@ def expect_a_request_with_body(body)
include_examples 'sent notice', environment: :development
end
end

describe ":blacklist_keys" do
# Fixes https://github.com/airbrake/airbrake-ruby/issues/276
context "when specified along with :whitelist_keys" do
it "sends a notice" do
params = {
blacklist_keys: %i[password password_confirmation],
whitelist_keys: [:email, /user/i, 'account_id']
}
airbrake = described_class.new(airbrake_params.merge(params))
notice = airbrake.build_notice(ex)
notice[:context][:headers] = 'banana'
airbrake.notify_sync(notice)

expect(a_request(:post, endpoint)).to have_been_made
end
end
end
end
end

0 comments on commit baee1c8

Please sign in to comment.