Verify: ScrubLinesWithReplace does not inject the whole line into the delegate, just the property value
Preamble
Development Stack
- Rider 2022.1.2
- .net 6.0
- Verfify.XUnit 17.10.2
Describe the bug
When calling ScrubLinesWithReplace(Func<string, string?> replaceLine) on VerifySettings and passing that into the Verify() method along with an object. When that object is serialized as JSON, only the property value is injected into the delegate/func for each line.
Example .recieved.txt
{
Id: kxdi7ZanHj,
ForeignObjectId: TaqKSdYXCs,
Name: Name Of Person
}
Will call ScrubLinesWithReplace with the values kxdi7ZanHj, TaqKSdYXCs and Name Of Person. It does not include the property name.
This prevents me from Scrubbing that line, or replacing its value where I need to know the property name to correctly scrub the value.
What does work?
If you serialize the object to a string first, then this works as expected.
Minimal Repro
Submit a PR that fixes the bug
If this is confirmed as a bug, I will consider a PR.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 16 (8 by maintainers)
it scrubs lines of text content. in the context of a string (using
Verifier.Verify(rawJson)) it will work as you expected. In the context of a serialized object (which is what VerifyJson does since it creates a node model under the covers) it will process string members.As i said, if u want an option to opt into have ScrubLinesWithReplace (scrubbers in general) operate on the full resulting string, I am happy to consider a PR
@SimonCropp - thanks, this worked. I could have sworn I tried this a couple of days ago and it didn’t work - hence my earlier comment about it not seeming to do anything at all. I think I can refactor our tests to use this approach.
I also echo @dracan’s comment about the method feeling less useful. Furthermore, it feels like the method is now mis-named as it doesn’t necessarily scrub (whole) lines!
Anyway, thanks for all your effort on this project. It really is appreciated 👍🏽
Hey, this is affecting us too. On v16.9.0 the scrubber received the whole line, which made it easy to write a regex to scrub the value based on the property name.
As-of v17.6 of the nuget package, the scrubber just receives the value, which as @kaddyuk mentions, makes it impossible to write a regex.
I tried v17.5 and the behaviour was the same as v16.9.0 - it seems PR #571 is the culprit.
Would it be possible to consider a global flag to opt in or out of this behaviour please?