diff --git a/onedns/tests/__init__.py b/onedns/tests/__init__.py index a35c0fa..1eb4355 100644 --- a/onedns/tests/__init__.py +++ b/onedns/tests/__init__.py @@ -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, )