Open valentijnscholten opened 3 years ago
filter_headers
applies to request headers, so only Cookie
can be taken care of with it. Set-Cookie
on the other hand is a response header, and thus needs to be done with before_record_response
. This appears to work for me with pytest-vcr and pytest-recording:
def remove_set_cookie(response):
response["headers"].pop("Set-Cookie", None)
return response
@pytest.fixture(scope="module")
def vcr_config():
return {
"before_record_response": remove_set_cookie,
"filter_headers": ["Cookie"],
}
Tried to filter out cookies to prevent them from being recorded. Filtering on other headers works fine, but
cookie
andset-cookie
keep appearing in the recordings.Also tried lowercase, different order, etc. In the end I implemented the customer request/response filters to remove the cookie headers. Am I misiing the correct way to filter cookies?