Skip to content
This repository was archived by the owner on Oct 12, 2023. It is now read-only.

Commit 41fb8fd

Browse files
williexutroydai
authored andcommitted
added record processor for slashes
1 parent cbc6452 commit 41fb8fd

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

src/azure_devtools/scenario_tests/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from .recording_processors import (
1212
RecordingProcessor, SubscriptionRecordingProcessor,
1313
LargeRequestBodyProcessor, LargeResponseBodyProcessor, LargeResponseBodyReplacer,
14-
OAuthRequestResponsesFilter, DeploymentNameReplacer, GeneralNameReplacer, AccessTokenReplacer,
14+
OAuthRequestResponsesFilter, DeploymentNameReplacer, GeneralNameReplacer, AccessTokenReplacer, SlashReplacer,
1515
)
1616
from .utilities import create_random_name, get_sha1_hash
1717

@@ -22,7 +22,7 @@
2222
'RecordingProcessor', 'SubscriptionRecordingProcessor',
2323
'LargeRequestBodyProcessor', 'LargeResponseBodyProcessor', 'LargeResponseBodyReplacer',
2424
'OAuthRequestResponsesFilter', 'DeploymentNameReplacer', 'GeneralNameReplacer',
25-
'AccessTokenReplacer',
25+
'AccessTokenReplacer', 'SlashReplacer',
2626
'live_only', 'record_only',
2727
'create_random_name', 'get_sha1_hash']
2828
__version__ = '0.5.0'

src/azure_devtools/scenario_tests/base.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import tempfile
1111
import shutil
1212
import logging
13-
import re
1413
import six
1514
import vcr
1615

@@ -143,11 +142,6 @@ def tearDown(self):
143142
os.environ = self.original_env
144143

145144
def _process_request_recording(self, request):
146-
# URL parsing fix to account for '//' vs '/' in different versions of python
147-
# - Python 2.7 for 2.7/3.3/3.4 (...Microsoft.Compute//availabilitySets...)
148-
# - Python 3.5 (...Microsoft.Compute/availabilitySets...)
149-
request.uri = re.sub('(?<!:)//', '/', request.uri)
150-
151145
if self.disable_recording:
152146
return None
153147

src/azure_devtools/scenario_tests/recording_processors.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,3 +175,11 @@ def process_response(self, response):
175175
self.replace_header(response, 'azure-asyncoperation', old, new)
176176

177177
return response
178+
179+
180+
class SlashReplacer(RecordingProcessor):
181+
"""URL parsing fix to account for '//' vs '/' in different versions of python"""
182+
def process_request(self, request):
183+
import re
184+
request.uri = re.sub('(?<!:)//', '/', request.uri)
185+
return request

0 commit comments

Comments
 (0)