Skip to content

Commit

Permalink
test(vcr): automatically redact bearer tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
colinux committed Jun 12, 2024
1 parent d1c2350 commit eeead83
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions spec/support/vcr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,13 @@
c.cassette_library_dir = 'spec/fixtures/cassettes'
c.configure_rspec_metadata!
c.ignore_hosts 'test.host', 'chromedriver.storage.googleapis.com'

c.filter_sensitive_data('redacted') do |interaction|
auth = interaction.request.headers['Authorization']&.first
next if auth.nil?

if (match = auth.match(/^Bearer\s+([^,\s]+)/))
match.captures.first
end
end
end

0 comments on commit eeead83

Please sign in to comment.