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

[Unified Recorder] Option to add session level sanitizer #18223

Closed
HarshaNalluru opened this issue Oct 16, 2021 · 0 comments · Fixed by #21533
Closed

[Unified Recorder] Option to add session level sanitizer #18223

HarshaNalluru opened this issue Oct 16, 2021 · 0 comments · Fixed by #21533
Assignees
Labels
test-utils-recorder Label for the issues related to the common recorder
Milestone

Comments

@HarshaNalluru
Copy link
Member

Sanitizers added at #17379 work at the recording level and not for the test-suite level or session-level.
This issue is to track the work needed to add the option to add the sanitizers at the session level which would encompass multiple tests/test-suites.

@ghost ghost added the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Oct 16, 2021
@HarshaNalluru HarshaNalluru added the test-utils-recorder Label for the issues related to the common recorder label Oct 16, 2021
@ghost ghost removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Oct 16, 2021
@HarshaNalluru HarshaNalluru self-assigned this Oct 16, 2021
@HarshaNalluru HarshaNalluru added this to the [2021] December milestone Nov 20, 2021
timovv added a commit that referenced this issue Jan 27, 2022
)

- Fixes #19809
- Part of work towards #18223

The main motivation of this PR was to add support for the new string sanitizers introduced in Azure/azure-sdk-tools#2530. As part of this, I've also tackled some refactoring that will be required for session-level sanitizer support (#18223) where we will be wanting to enable adding sanitizers without access to an instance of the `Recorder` class. While implementing the new sanitizer logic, I refactored the `addSanitizers` method into smaller chunks to make adding additional sanitizers easier. To summarize the changes:

* Removed the `Sanitizer` class, instead making the `addSanitizers` function in `sanitizer.ts` take in a `HttpClient` and recording ID as parameter.
* Refactored the `addSanitizers` function to call smaller functions for each sanitizer (some of which are a bit FP-style) instead of using if statements + special cases. Hopefully this will make things a bit easier to maintain.
* Some other minor refactors (e.g. extracting duplicated `createRecordingRequest` function into a utility).
* Add support for the string sanitizers in what I think is the most logical way, but there is a **breaking change**:
  * When calling `addSanitizers`, instead of specifying `generalRegexSanitizers: [...]` etc., you now specify `generalSanitizers: [...]`. Both regex sanitizers and string sanitizers can be used in this way, for example:
 ```ts
recorder.addSanitizers({
  generalSanitizers: [
    {
      regex: true, // Regex matching is enabled by setting the 'regex' option to true.
      target: ".*regex",
      value: "sanitized",
    },
    {
      // Note that `regex` defaults to false and doesn't need to be specified when working with bare strings.
      // In my experience, this is the most common scenario anyway.
      target: "Not a regex",
      value: "sanitized",
    }
  ],
});
```
sadasant pushed a commit to sadasant/azure-sdk-for-js that referenced this issue Jan 28, 2022
…re#19954)

- Fixes Azure#19809
- Part of work towards Azure#18223

The main motivation of this PR was to add support for the new string sanitizers introduced in Azure/azure-sdk-tools#2530. As part of this, I've also tackled some refactoring that will be required for session-level sanitizer support (Azure#18223) where we will be wanting to enable adding sanitizers without access to an instance of the `Recorder` class. While implementing the new sanitizer logic, I refactored the `addSanitizers` method into smaller chunks to make adding additional sanitizers easier. To summarize the changes:

* Removed the `Sanitizer` class, instead making the `addSanitizers` function in `sanitizer.ts` take in a `HttpClient` and recording ID as parameter.
* Refactored the `addSanitizers` function to call smaller functions for each sanitizer (some of which are a bit FP-style) instead of using if statements + special cases. Hopefully this will make things a bit easier to maintain.
* Some other minor refactors (e.g. extracting duplicated `createRecordingRequest` function into a utility).
* Add support for the string sanitizers in what I think is the most logical way, but there is a **breaking change**:
  * When calling `addSanitizers`, instead of specifying `generalRegexSanitizers: [...]` etc., you now specify `generalSanitizers: [...]`. Both regex sanitizers and string sanitizers can be used in this way, for example:
 ```ts
recorder.addSanitizers({
  generalSanitizers: [
    {
      regex: true, // Regex matching is enabled by setting the 'regex' option to true.
      target: ".*regex",
      value: "sanitized",
    },
    {
      // Note that `regex` defaults to false and doesn't need to be specified when working with bare strings.
      // In my experience, this is the most common scenario anyway.
      target: "Not a regex",
      value: "sanitized",
    }
  ],
});
```
@timovv timovv modified the milestones: [2022] February, [2022] March Feb 9, 2022
@timovv timovv modified the milestones: [2022] March, [2022] April Mar 14, 2022
openapi-sdkautomation bot pushed a commit to AzureSDKAutomation/azure-sdk-for-js that referenced this issue Mar 15, 2022
update readme (Azure#18223)

* update readme

* Update readme.python.md
openapi-sdkautomation bot pushed a commit to AzureSDKAutomation/azure-sdk-for-js that referenced this issue Mar 15, 2022
update readme (Azure#18223)

* update readme

* Update readme.python.md
openapi-sdkautomation bot pushed a commit to AzureSDKAutomation/azure-sdk-for-js that referenced this issue Mar 15, 2022
update readme (Azure#18223)

* update readme

* Update readme.python.md
openapi-sdkautomation bot pushed a commit to AzureSDKAutomation/azure-sdk-for-js that referenced this issue Mar 15, 2022
update readme (Azure#18223)

* update readme

* Update readme.python.md
timovv added a commit to timovv/azure-sdk-for-js that referenced this issue Apr 20, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Apr 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
test-utils-recorder Label for the issues related to the common recorder
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants