From dfa21b3bb99c76e3100f4addc2b747cac1531a28 Mon Sep 17 00:00:00 2001 From: Scott Beddall <45376673+scbedd@users.noreply.github.com> Date: Thu, 18 Nov 2021 15:53:12 -0800 Subject: [PATCH] [Test-Proxy] Address Matching issues for batch playback (#2310) * resolve matching issues for batch responses from python tables tests * Update tools/test-proxy/Azure.Sdk.Tools.TestProxy/Sanitizers/BodyRegexSanitizer.cs to apply --- tools/test-proxy/Azure.Sdk.Tools.TestProxy/RecordingHandler.cs | 1 + .../Azure.Sdk.Tools.TestProxy/Sanitizers/BodyRegexSanitizer.cs | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/RecordingHandler.cs b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/RecordingHandler.cs index 6feabe8a455..48dd483ec50 100644 --- a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/RecordingHandler.cs +++ b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/RecordingHandler.cs @@ -356,6 +356,7 @@ public async Task HandlePlaybackRequest(string recordingId, HttpRequest incoming var bodyData = CompressBody(match.Response.Body, match.Response.Headers); outgoingResponse.ContentLength = bodyData.Length; + await outgoingResponse.Body.WriteAsync(bodyData).ConfigureAwait(false); } } diff --git a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Sanitizers/BodyRegexSanitizer.cs b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Sanitizers/BodyRegexSanitizer.cs index afb15cab076..5c07a20ad01 100644 --- a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Sanitizers/BodyRegexSanitizer.cs +++ b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/Sanitizers/BodyRegexSanitizer.cs @@ -1,5 +1,6 @@ using Azure.Sdk.Tools.TestProxy.Common; using System; +using System.Text; namespace Azure.Sdk.Tools.TestProxy.Sanitizers { @@ -35,7 +36,7 @@ public override string SanitizeTextBody(string contentType, string body) public override byte[] SanitizeBody(string contentType, byte[] body) { - return body; + return Encoding.UTF8.GetBytes(StringSanitizer.SanitizeValue(Encoding.UTF8.GetString(body), _newValue, _regexValue, _groupForReplace)); } } }