Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[filter] Filter sensitive data in request url #26

Merged
merged 2 commits into from
Aug 1, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/exvcr/filter.ex
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ defmodule ExVCR.Filter do
strip_query_params(url)
else
url
end
end |> filter_sensitive_data
end

@doc """
Expand All @@ -46,8 +46,8 @@ defmodule ExVCR.Filter do
end

defp is_header_allowed?(header_name) do
Enum.find(ExVCR.Setting.get(:response_headers_blacklist), fn(x) ->
to_string(header_name) == x
Enum.find(ExVCR.Setting.get(:response_headers_blacklist), fn(x) ->
to_string(header_name) == x
end) == nil
end
end
end
10 changes: 5 additions & 5 deletions lib/exvcr/handler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,19 @@ defmodule ExVCR.Handler do
end

defp match_by_url(response, keys, recorder_options) do
if stub_mode?(recorder_options) do
request_url = response[:request].url
key_url = to_string(keys[:url])
request_url = response[:request].url
key_url = to_string(keys[:url]) |> ExVCR.Filter.filter_sensitive_data

if stub_mode?(recorder_options) do
if match = Regex.run(~r/~r\/(.+)\//, request_url) do
pattern = Regex.compile!(Enum.at(match, 1))
Regex.match?(pattern, key_url)
else
request_url == key_url
end
else
request_url = parse_url(response[:request].url, recorder_options)
key_url = parse_url(keys[:url], recorder_options)
request_url = parse_url(request_url, recorder_options)
key_url = parse_url(key_url, recorder_options)

request_url == key_url
end
Expand Down