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

vcr_config fixture doesn't filter DELETE request #30

Open
gegnew opened this issue Aug 28, 2019 · 0 comments
Open

vcr_config fixture doesn't filter DELETE request #30

gegnew opened this issue Aug 28, 2019 · 0 comments

Comments

@gegnew
Copy link

gegnew commented Aug 28, 2019

It's possible that I've done something wrong, but I've overridden the vcr config in conftest.py as below:

@pytest.fixture(scope='module')
def vcr_config():
    """Pytest hook for vcr config"""
    return {
        'filter_headers': ['Cookie'],
        'before_record_response': scrub_header('set-cookie',
                                               repl='safetoken'),
        'cassette_library_dir': 'tests/cassettes'
                        }

Where scrub_header replaces headers as such:

def scrub_header(string, repl=''):
    """Remove secrets from stored vcr cassettes"""
    def before_record_response(response):
        response['headers'][string] = repl
        return response
    return before_record_response

This works great for every other request method (works for GET, POST, PATCH, PUT), but those headers are not removed before the delete request .yaml is saved.

Note that headers are removed by two methods:

  1. 'filter_headers' is passed to vcr to remove "Cookie"
  2. the 'set-cookie' header is replaced with 'safetoken' in before_record_response
    Interestingly, neither of these methods works for the delete request.

Thoughts?

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

No branches or pull requests

1 participant