techservicesillinois / vcrpy-cleaner

Sensitive data cleaners for network cassettes captured by the VCR.py testing library.
0 stars 0 forks source link

Add a `path` option to `clean_if` #30

Open edthedev opened 2 months ago

edthedev commented 2 months ago

Context

Currently the clean_if decorator requires supplying the full URL, which is brittle.

For example:

@clean_if(uri=f"https://example.com/api/user/update")

would be much nicer as:

@clean_if(path=f"/api/user/update")

or, as a stretch goal:

@clean_if(path_contains=f"/api/user/update")
# For URLs like "/api/user/update/9999"

Tasks

Reference:

https://github.com/techservicesillinois/secops-splunk-illinois-midpoint/blob/d16ba37a7329b691f693ceef829d9ad8b08aa043/tests/conftest.py#L83

https://github.com/techservicesillinois/vcrpy-cleaner/blob/9b4c3b816d735a31ccefbe2fa17bc57ea7ef5026/src/vcr_cleaner/__init__.py#L31C1-L31C24

edthedev commented 2 months ago

This would support test suite updates in https://github.com/techservicesillinois/secops-splunk-illinois-midpoint

edthedev commented 2 months ago

Alternately, update our examples in README to show pulling hostname from the environment (and a default CLEANED value) and passing it into clean_url.

edthedev commented 1 month ago

Blocks #35, for practical purposes.

Those proposed cleaners will be much more useful if we have this feature merged first.