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

[feat] Add support for censoring XML, HTML and raw text response bodies #52

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

nwithan8
Copy link
Member

@nwithan8 nwithan8 commented May 19, 2023

Description

XML, HTML and plain text body censoring seem to be working as expected and are ready for release into the wild.

This PR enables XML, HTML and plain text body censoring (content type is determined automatically by the library during censor processing; end-user does not need to define what type of content will be censored).

This PR features a few breaking changes:

  • CensorElement is now an abstract base class that cannot be used directly. All previous uses of CensorElement likely want to be replaced by KeyCensorElement (used to censor the value of a specified JSON/XML key).
    • TextCensorElement is introduced, to censor a specific text value. This works well if users don't know the key of a JSON/XML element they want to censor, but do know the value. For HTML/plain text, this will only work if the entire body text of HTML/plain text matches the provided value; using RegexCensorElement is more effective for HTML/plain text matching.
      CensorHeadersByKeys, CensorBodyElementsByKeys, CensorQueryParametersByKeys and CensorPathElementsByPatterns have been removed. Users should instead use CensorHeaders, CensorBodyElements, CensorQueryParameters and CensorPathElements and pass in lists of CensorElement-subtypes. This will allow users to easily mix-and-match censor elements (e.g. both by-key and by-regex censors on the same body)

Testing

  • New unit tests confirm that the three types of censors (keys, raw text, regex) work on the four types of response contents (JSON, XML, HTML, plain text)
  • New unit test confirms that censors can be mix-and-matched in the same censor run.

Pull Request Type

Please select the option(s) that are relevant to this PR.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Improvement (fixing a typo, updating readme, renaming a variable name, etc)

nwithan8 added 6 commits May 19, 2023 00:51
…gexCensorElement or TextCensorElement

- Add support for censoring raw text/HTML response bodies
- Add unit test to confirm raw text censoring working as excepted
…ent body types

- Remove legacy censor creation methods in favor of new methods
- Update CHANGELOG to clarify breaking change, usage recommendations
- Update README with new method of creating censors
- Bump source code to C# 9
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

Successfully merging this pull request may close these issues.

1 participant