-
-
Notifications
You must be signed in to change notification settings - Fork 508
Open
Description
When using filter_sensitive_data with a value extracted dynamically from a query parameter, the cassette fails to replay, apparently because VCR is comparing the URL without substitution to the sanitized one.
There's a simple workaround, but in an ideal world it wouldn't be necessary:
match_requests_on: [VCR.request_matchers.uri_without_param(:secret)]Here is a failing test case:
diff --git a/spec/lib/vcr/configuration_spec.rb b/spec/lib/vcr/configuration_spec.rb
index 5e555e5..85701a9 100644
--- a/spec/lib/vcr/configuration_spec.rb
+++ b/spec/lib/vcr/configuration_spec.rb
@@ -158,6 +158,20 @@ RSpec.describe VCR::Configuration do
end
end
end
+
+ specify 'the filter_sensitive_data option works with dynamic query parameters' do
+ VCR.configure do |c|
+ c.filter_sensitive_data('<SECRET>') do |interaction|
+ Rack::Utils.parse_query(URI(interaction.request.uri).query)['secret']
+ end
+ end
+
+ 2.times do
+ VCR.use_cassette("example") do
+ ::Net::HTTP.get_response(URI("http://localhost:#{VCR::SinatraApp.port}/foo?secret=1234"))
+ end
+ end
+ end
end
[:before_record, :before_playback].each do |hook_type|I've tried fixing this but got lost in hooks...
Metadata
Metadata
Assignees
Labels
No labels