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

[Test-Proxy] Disable multipart/mixed sanitization until the additional work is done #2918

Merged
merged 2 commits into from
Mar 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -668,24 +668,24 @@ public void UriStringSanitizerQuietlyExits(string targetValue, string replacemen
}


[Theory]
[InlineData("batchresponse_00000000-0000-0000-0000-000000000000", "batchresponse_boundary", "Test.RecordEntries/multipart_request.json")]
[InlineData("changesetresponse_955358ab-62b1-4d6c-804b-41cebb7c5e42", "changeset_boundry", "Test.RecordEntries/multipart_request.json")]
public void GeneralRegexSanitizerAffectsMultipartRequest(string regex, string replacementValue, string targetFile)
{
var session = TestHelpers.LoadRecordSession(targetFile);
// Re-enable w/ Azure/azure-sdk-tools#2900
//[Theory]
//[InlineData("batchresponse_00000000-0000-0000-0000-000000000000", "batchresponse_boundary", "Test.RecordEntries/multipart_request.json")]
//[InlineData("changesetresponse_955358ab-62b1-4d6c-804b-41cebb7c5e42", "changeset_boundry", "Test.RecordEntries/multipart_request.json")]
//public void GeneralRegexSanitizerAffectsMultipartRequest(string regex, string replacementValue, string targetFile)
//{
// var session = TestHelpers.LoadRecordSession(targetFile);

var targetEntry = session.Session.Entries[0];
var matcher = new RecordMatcher();

var sanitizer = new GeneralRegexSanitizer(value: replacementValue, regex: regex);
session.Session.Sanitize(sanitizer);
// var targetEntry = session.Session.Entries[0];
// var matcher = new RecordMatcher();

var bodyString = Encoding.UTF8.GetString(session.Session.Entries[0].Response.Body);
// var sanitizer = new GeneralRegexSanitizer(value: replacementValue, regex: regex);
// session.Session.Sanitize(sanitizer);

Assert.DoesNotContain(regex, bodyString);
Assert.Contains(replacementValue, bodyString);
}
// var bodyString = Encoding.UTF8.GetString(session.Session.Entries[0].Response.Body);

// Assert.DoesNotContain(regex, bodyString);
// Assert.Contains(replacementValue, bodyString);
//}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public static bool TryGetTextEncoding(string contentType, out Encoding encoding)
const string appJsonPrefix = "application/json";
const string xmlSuffix = "xml";
const string urlEncodedSuffix = "-urlencoded";
const string multipartMixed = "multipart/mixed";

// Default is technically US-ASCII, but will default to UTF-8 which is a superset.
const string appFormUrlEncoded = "application/x-www-form-urlencoded";
Expand All @@ -46,8 +45,7 @@ public static bool TryGetTextEncoding(string contentType, out Encoding encoding)
contentType.EndsWith(xmlSuffix, StringComparison.OrdinalIgnoreCase) ||
contentType.EndsWith(urlEncodedSuffix, StringComparison.OrdinalIgnoreCase) ||
contentType.StartsWith(appJsonPrefix, StringComparison.OrdinalIgnoreCase) ||
contentType.StartsWith(appFormUrlEncoded, StringComparison.OrdinalIgnoreCase) ||
contentType.StartsWith(multipartMixed, StringComparison.OrdinalIgnoreCase))
contentType.StartsWith(appFormUrlEncoded, StringComparison.OrdinalIgnoreCase))
{
encoding = Encoding.UTF8;
return true;
Expand Down