-
Notifications
You must be signed in to change notification settings - Fork 5
Changing things in the recording
Specifically, changing, redacting, and all that.
new MarkdownRecorder()
.withReplacementInRecording("'password': '.*'",
"'password': 'REDACTED_PASSWORD'")
.withReplacementInRecording("'date': '.*'",
"'date': 'TODAYS_DATE_CCYY-MM-DD'")
In this case we're wanting to replace password and date in the recording. Password, as each team member might have a password for the "real" down-stack service, and the team has a policy of not sharing passwords/secrets, which means they don't do into source control. Date, as the intent of a recording is that it is viable for reliable replay for multiple days if not weeks. Whereas you may leave the password in it's redacted form, the date might need to be real in a response body. It would needs to be changed back to something like 2019-08-16, and we can programmatically perform that:
new MarkdownReplayer()
.withReplacementInPlayback("'date': 'TODAYS_DATE_CCYY-MM-DD'",
"'date': '" + todaysDateInCCYYMMDDfmt() + "'")
Note the 'from' for replacements is a regular expression. See https://en.wikipedia.org/wiki/Regular_expression and play with regular expressions at https://regex101.com/.