Skip to content

Commit

Permalink
Update add_sanitizer and doc (Azure#20769)
Browse files Browse the repository at this point in the history
  • Loading branch information
mccoyp authored Sep 21, 2021
1 parent 0e20469 commit f8ff686
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion doc/dev/test_proxy_migration_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ adding something like the following in the package's `conftest.py` file:
```python
from devtools_testutils import add_sanitizer

@pytest.fixture(scope="session")
# autouse=True will trigger this fixture on each pytest run, even if it's not explicitly used by a test method
@pytest.fixture(scope="session", autouse=True)
def sanitize_uris():
add_sanitizer(ProxyRecordingSanitizer.URI, value="fakeendpoint")
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ def add_sanitizer(sanitizer, **kwargs):
"""
request_args = {}
request_args["value"] = kwargs.get("value") or "fakevalue"
request_args["regex"] = kwargs.get("regex") or "[a-z]+(?=(?:-secondary)\\.(?:table|blob|queue)\\.core\\.windows\\.net)"
request_args["regex"] = (
kwargs.get("regex") or "(?<=\\/\\/)[a-z]+(?=(?:|-secondary)\\.(?:table|blob|queue)\\.core\\.windows\\.net)"
)
request_args["group_for_replace"] = kwargs.get("group_for_replace")

if sanitizer == ProxyRecordingSanitizer.URI:
Expand All @@ -62,7 +64,7 @@ def add_sanitizer(sanitizer, **kwargs):
json={
"regex": request_args["regex"],
"value": request_args["value"],
"groupForReplace": request_args["group_for_replace"]
"groupForReplace": request_args["group_for_replace"],
},
)

Expand Down

0 comments on commit f8ff686

Please sign in to comment.