vcr: scrub ONE xmlrpc auth from recordings
parent
17acd42c7d
commit
2c32c03ab4
|
@ -1,7 +1,23 @@
|
|||
import os
|
||||
import StringIO
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
from vcr import VCR
|
||||
|
||||
|
||||
def scrub_auth(request):
|
||||
xml = StringIO.StringIO(request.body)
|
||||
tree = ET.parse(xml)
|
||||
root = tree.getroot()
|
||||
auth_param = tree.findall('./params/param/value/string')[0]
|
||||
auth_param.text = 'someuser:sometoken'
|
||||
scrubbed = StringIO.StringIO()
|
||||
tree.write(scrubbed)
|
||||
scrubbed.seek(0)
|
||||
request.body = scrubbed.read()
|
||||
return request
|
||||
|
||||
|
||||
vcr = VCR(
|
||||
serializer='yaml',
|
||||
cassette_library_dir=os.path.join(
|
||||
|
@ -10,4 +26,5 @@ vcr = VCR(
|
|||
record_mode='once',
|
||||
decode_compressed_response=True,
|
||||
path_transformer=VCR.ensure_suffix('.yaml'),
|
||||
before_record=scrub_auth,
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue