-
Notifications
You must be signed in to change notification settings - Fork 161
Expand file tree
/
Copy pathvcr.rb
More file actions
48 lines (45 loc) · 1.74 KB
/
vcr.rb
File metadata and controls
48 lines (45 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
require 'vcr'
VCR.configure do |c|
c.cassette_library_dir = 'spec/cassettes'
c.hook_into :webmock
# c.preserve_exact_body_bytes do |http_message, cassette|
# http_message.body.encoding.name == 'UTF-8' ||
# !http_message.body.valid_encoding?
# end
c.configure_rspec_metadata!
c.filter_sensitive_data("<YT_TEST_API_KEY>") { ENV['YT_TEST_API_KEY'] }
c.filter_sensitive_data("<YT_TEST_CLIENT_ID>") { ENV['YT_TEST_CLIENT_ID'] }
c.filter_sensitive_data("<YT_TEST_CLIENT_SECRET>") { ENV['YT_TEST_CLIENT_SECRET'] }
c.filter_sensitive_data("<YT_TEST_REFRESH_TOKEN>") { CGI.escape(ENV['YT_TEST_REFRESH_TOKEN']) }
c.filter_sensitive_data("<YT_TEST_ACCESS_TOKEN>") do |interaction|
begin
body = JSON.parse(interaction.response.body)
body['access_token']
rescue
# noop
end
end
c.filter_sensitive_data("<YT_TEST_ID_TOKEN>") do |interaction|
begin
body = JSON.parse(interaction.response.body)
body['id_token']
rescue
# noop
end
end
c.filter_sensitive_data("<YT_AUTH_HEADER>") do |interaction|
interaction.request.headers['Authorization'].first rescue nil
end
c.filter_sensitive_data("<YT_TEST_CONTENT_OWNER_NAME>") { ENV['YT_TEST_CONTENT_OWNER_NAME'] }
c.filter_sensitive_data("<YT_TEST_PARTNER_CLIENT_ID>") { ENV['YT_TEST_PARTNER_CLIENT_ID'] }
c.filter_sensitive_data("<YT_TEST_PARTNER_CLIENT_SECRET>") { ENV['YT_TEST_PARTNER_CLIENT_SECRET'] }
c.filter_sensitive_data("<YT_TEST_CONTENT_OWNER_REFRESH_TOKEN>") { CGI.escape(ENV['YT_TEST_CONTENT_OWNER_REFRESH_TOKEN']) }
c.filter_sensitive_data("<YT_TEST_CONTENT_OWNER_ACCESS_TOKEN>") do |interaction|
begin
body = JSON.parse(interaction.response.body)
body['access_token']
rescue
# noop
end
end
end