Open davenguyen opened 3 years ago
I have also run into this exact issue. My expectation was that filter_sensitive_data
is for filtering what is saved to the VCR cassette, but unfortunately it also filters out the response received by the test code.
So if I want to filter out the access token provided by one request like this:
config :exvcr,
filter_sensitive_data: [
[pattern: ~s("accessToken":\s*"[a-zA-Z0-9]+"), placeholder: ~s("accessToken": "***")]
]
Then I cannot use that accessToken for a followup request within the same test, because the substitution has been done on the response, not only on the VCR cassette.
@davenguyen What did you end up doing for a work around?
For now I am just doing a single request in the test. Generating an access token via a mix task and specifying it as an environment variable when running the tests.
I have a cassette with two requests in it. The first request is to get back an authorization token, then the second request uses this token to properly authorize. If I filter out the authorization token, the second request gets the placeholder instead and errors out. So, is it possible to send the unredacted information until the cassette is finished, and then filter when writing to the file? Or update the file with placeholders?