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 sensitive data after all request made #167

Open
davenguyen opened this issue Apr 7, 2021 · 1 comment
Open

Filter sensitive data after all request made #167

davenguyen opened this issue Apr 7, 2021 · 1 comment

Comments

@davenguyen
Copy link

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?

@nathany-copia
Copy link

nathany-copia commented Jul 29, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants