Note: this config option is also available as define_cassette_placeholder to reflect the fact that it is useful for more than just sensitive data.
The filter_sensitive_data configuration option can be used to prevent sensitive data from being written to your cassette files. This may be important if you commit your cassettes files to source control and do not want your sensitive data exposed. Pass the following arguments to filter_sensitive_data:
- A substitution string. This is the string that will be written to
the cassettte file as a placeholder. It should be unique and you
may want to wrap it in special characters like `{ }` or `< >`.
- A symbol specifying a tag (optional). If a tag is given, the
filtering will only be applied to cassettes with the given tag.
- A block. The block should return the sensitive text that you want
replaced with the substitution string. If your block accepts an
argument, the HTTP interaction will be yielded so that you can
dynamically specify the sensitive text based on the interaction
(see the last scenario for an example of this).
When the interactions are replayed, the sensitive text will replace the substitution string so that the interaction will be identical to what was originally recorded.
Warning, the data you're filtering may have been escaped or encoded. Thus you may need to escape the sensitive text. For example, if "some&password" is in your cassette within a context which is html escaped, you will need to filter "some&password" or CGI::escapeHTML('some&password'). Similarly if it's escaped in a query string, then you will need to filter "some%26password" or CGI::escape('some&password')