mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-26 20:56:48 +00:00
* Hide Stripe Client User Agent header, it contains the hostname of the machine generating the cassettes * Hide client_secret
29 lines
924 B
Ruby
29 lines
924 B
Ruby
# frozen_string_literal: true
|
|
|
|
require 'vcr'
|
|
|
|
VCR.configure do |config|
|
|
config.cassette_library_dir = "spec/fixtures/vcr_cassettes"
|
|
config.hook_into :webmock
|
|
config.ignore_localhost = true
|
|
config.configure_rspec_metadata!
|
|
config.ignore_hosts('localhost', '127.0.0.1', '0.0.0.0', 'api.knapsackpro.com')
|
|
|
|
# Filter sensitive environment variables
|
|
%w[
|
|
STRIPE_INSTANCE_SECRET_KEY
|
|
STRIPE_CUSTOMER
|
|
STRIPE_ACCOUNT
|
|
STRIPE_CLIENT_ID
|
|
STRIPE_ENDPOINT_SECRET
|
|
].each do |env_var|
|
|
config.filter_sensitive_data("<HIDDEN-#{env_var}>") { ENV.fetch(env_var, nil) }
|
|
end
|
|
config.filter_sensitive_data('<HIDDEN-STRIPE-USER-AGENT>') { |interaction|
|
|
interaction.request.headers['X-Stripe-Client-User-Agent']&.public_send(:[], 0)
|
|
}
|
|
config.filter_sensitive_data('<HIDDEN-CLIENT-SECRET>') { |interaction|
|
|
interaction.response.body.match(/"client_secret": "(pi_.+)"/)&.public_send(:[], 1)
|
|
}
|
|
end
|