From f2d11b29928d1b1b6fbea1f16933d3f55b8a2d43 Mon Sep 17 00:00:00 2001 From: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com> Date: Tue, 14 May 2024 18:36:12 -0700 Subject: [PATCH] Correct test proxy swagger (#44012) * Correct test proxy swagger * Fix ManagementRecordedTestBase.cs * Fix call sites * Value * more * fix mgmt * fix mgmt --- .../Redesign/ManagementRecordedTestBase.cs | 28 ++++++------- .../tests/Scenario/LoggerTests.cs | 6 +-- .../tests/AutomanageTestBase.cs | 6 +-- .../BatchApplicationPackageCollectionTests.cs | 2 +- .../BatchApplicationPackageOperationTests.cs | 2 +- ...lAutomationClientAutomatedLiveTestsBase.cs | 8 ++-- .../CallAutomationClientLiveTestsBase.cs | 4 +- .../CallAutomationClientLiveTestsBase.cs | 2 +- .../tests/Infrastructure/ChatLiveTestBase.cs | 4 +- .../tests/EmailClientLiveTestBase.cs | 6 +-- ...CommunicationIdentityClientLiveTestBase.cs | 4 +- .../Infrastructure/RouterLiveTestBase.cs | 2 +- .../Infrastructure/MessagesLiveTestBase.cs | 2 +- .../PhoneNumbersClientLiveTestBase.cs | 8 ++-- .../SipRoutingClientLiveTestBase.cs | 4 +- .../ProgrammableConnectivityClientTest.cs | 7 +++- .../Infrastructure/RoomsClientLiveTestBase.cs | 8 ++-- .../tests/SmsClientLiveTestBase.cs | 2 +- .../ContainerRegistryRecordedTestBase.cs | 8 ++-- .../Models/BodyKeySanitizer.Serialization.cs | 10 ++--- .../src/Generated/Models/BodyKeySanitizer.cs | 18 ++++---- .../BodyRegexSanitizer.Serialization.cs | 7 +++- .../Generated/Models/BodyRegexSanitizer.cs | 11 ++--- .../HeaderRegexSanitizer.Serialization.cs | 7 +++- .../Generated/Models/HeaderRegexSanitizer.cs | 11 ++--- .../Models/HeaderTransform.Serialization.cs | 7 +++- .../src/Generated/Models/HeaderTransform.cs | 11 ++--- .../Models/UriRegexSanitizer.Serialization.cs | 7 +++- .../src/Generated/Models/UriRegexSanitizer.cs | 11 ++--- .../src/HeaderRegexSanitizer.cs | 7 ++-- .../src/RecordedTestBase.cs | 5 ++- .../src/TestRecording.cs | 4 +- .../src/UriRegexSanitizer.cs | 7 ++-- .../src/testproxy.json | 14 +++---- .../DocumentIntelligenceLiveTestBase.cs | 2 +- .../DocumentAnalysisLiveTestBase.cs | 2 +- .../tests/HealthcareApisManagementTestBase.cs | 24 +++++++++-- .../tests/IdentityRecordedTestBase.cs | 10 ++--- .../tests/LoadTestTestsBase.cs | 3 +- .../tests/MetricsAdvisorLiveTestBase.cs | 2 +- .../tests/Tests/MigrationSapDiscoveryTests.cs | 2 +- .../Scenario/MySqlFlexibleServerTests.cs | 4 +- .../tests/NetworkCloudManagementTestBase.cs | 4 +- .../tests/AssistantsTestBase.cs | 14 +++---- .../Azure.AI.OpenAI/tests/OpenAITestBase.cs | 8 ++-- .../tests/ReceivedSharesClientTestBase.cs | 23 ++++++++-- .../tests/SentSharesClientTestBase.cs | 23 ++++++---- .../tests/ShareResourcesClientTestBase.cs | 17 ++++++-- .../tests/QuantumJobClientLiveTests.cs | 42 +++++++++++-------- .../tests/Tests/AzDevOpsTests.cs | 2 +- .../tests/Tests/GitHubTests.cs | 2 +- .../ServiceBusManagementClientLiveTests.cs | 18 ++++---- .../Tests/WebAppWebPubSubConnectionTests.cs | 2 +- .../tests/BlobBatchClientTests.cs | 5 ++- .../tests/Shared/StorageTestBase.cs | 25 ++++++----- .../tests/SubscriptionManagementTestBase.cs | 12 +++--- .../tests/TableServiceLiveTestsBase.cs | 2 +- .../tests/ImageAnalysisTestBase.cs | 4 +- 58 files changed, 282 insertions(+), 220 deletions(-) diff --git a/common/ManagementTestShared/Redesign/ManagementRecordedTestBase.cs b/common/ManagementTestShared/Redesign/ManagementRecordedTestBase.cs index 595fa61d0866..0af83311687f 100644 --- a/common/ManagementTestShared/Redesign/ManagementRecordedTestBase.cs +++ b/common/ManagementTestShared/Redesign/ManagementRecordedTestBase.cs @@ -73,44 +73,40 @@ private void Initialize() protected void IgnoreNetworkDependencyVersions() { // Ignore the api-version of Network operations - UriRegexSanitizers.Add(new UriRegexSanitizer( - @"/providers\/Microsoft.Network\/(.*?)\?api-version=(?[a-z0-9-]+)", "**" - ) + UriRegexSanitizers.Add(new UriRegexSanitizer(@"/providers\/Microsoft.Network\/(.*?)\?api-version=(?[a-z0-9-]+)") { - GroupForReplace = "group" + GroupForReplace = "group", + Value = "**" }); } protected void IgnoreAuthorizationDependencyVersions() { // Ignore the api-version of Authorization operations - UriRegexSanitizers.Add(new UriRegexSanitizer( - @"/providers\/Microsoft.Authorization\/(.*?)\?api-version=(?[a-z0-9-]+)", "**" - ) + UriRegexSanitizers.Add(new UriRegexSanitizer(@"/providers\/Microsoft.Authorization\/(.*?)\?api-version=(?[a-z0-9-]+)") { - GroupForReplace = "group" + GroupForReplace = "group", + Value = "**" }); } protected void IgnoreKeyVaultDependencyVersions() { // Ignore the api-version of KeyVault operations - UriRegexSanitizers.Add(new UriRegexSanitizer( - @"/providers\/Microsoft.KeyVault\/(.*?)\?api-version=(?[a-z0-9-]+)", "**" - ) + UriRegexSanitizers.Add(new UriRegexSanitizer(@"/providers\/Microsoft.KeyVault\/(.*?)\?api-version=(?[a-z0-9-]+)") { - GroupForReplace = "group" + GroupForReplace = "group", + Value = "**" }); } protected void IgnoreManagedIdentityDependencyVersions() { // Ignore the api-version of ManagedIdentity operations - UriRegexSanitizers.Add(new UriRegexSanitizer( - @"/providers\/Microsoft.ManagedIdentity\/(.*?)\?api-version=(?[a-z0-9-]+)", "**" - ) + UriRegexSanitizers.Add(new UriRegexSanitizer(@"/providers\/Microsoft.ManagedIdentity\/(.*?)\?api-version=(?[a-z0-9-]+)") { - GroupForReplace = "group" + GroupForReplace = "group", + Value = "**" }); } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/tests/Scenario/LoggerTests.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/tests/Scenario/LoggerTests.cs index 3ac9a284a45d..764aae709b6e 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/tests/Scenario/LoggerTests.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/tests/Scenario/LoggerTests.cs @@ -52,10 +52,10 @@ private void IgnoreApiVersionInEventHubOperations() { // Ignore the api-version of EventHub operations UriRegexSanitizers.Add(new UriRegexSanitizer( - @"/providers/Microsoft.EventHub/namespaces/([\S]+)?pi-version=(?[a-z0-9-]+)", "**" - ) + @"/providers/Microsoft.EventHub/namespaces/([\S]+)?pi-version=(?[a-z0-9-]+)") { - GroupForReplace = "group" + GroupForReplace = "group", + Value = "**" }); } diff --git a/sdk/automanage/Azure.ResourceManager.Automanage/tests/AutomanageTestBase.cs b/sdk/automanage/Azure.ResourceManager.Automanage/tests/AutomanageTestBase.cs index 91793367162a..633f39d90dbe 100644 --- a/sdk/automanage/Azure.ResourceManager.Automanage/tests/AutomanageTestBase.cs +++ b/sdk/automanage/Azure.ResourceManager.Automanage/tests/AutomanageTestBase.cs @@ -151,10 +151,10 @@ private void IgnoreApiVersionInResourcesOperations() { // Ignore the api-version of deployment operations UriRegexSanitizers.Add(new UriRegexSanitizer( - @"/providers/Microsoft.Resources/deployments/[^/]+(/operationStatuses/[^/]+)?pi-version=(?[a-z0-9-]+)", "**" - ) + @"/providers/Microsoft.Resources/deployments/[^/]+(/operationStatuses/[^/]+)?pi-version=(?[a-z0-9-]+)") { - GroupForReplace = "group" + GroupForReplace = "group", + Value = "**" }); } } diff --git a/sdk/batch/Azure.ResourceManager.Batch/tests/TestCase/BatchApplicationPackageCollectionTests.cs b/sdk/batch/Azure.ResourceManager.Batch/tests/TestCase/BatchApplicationPackageCollectionTests.cs index 96af24a03ff4..82ed9166303a 100644 --- a/sdk/batch/Azure.ResourceManager.Batch/tests/TestCase/BatchApplicationPackageCollectionTests.cs +++ b/sdk/batch/Azure.ResourceManager.Batch/tests/TestCase/BatchApplicationPackageCollectionTests.cs @@ -17,7 +17,7 @@ public class BatchApplicationPackageCollectionTests : BatchManagementTestBase public BatchApplicationPackageCollectionTests(bool isAsync) : base(isAsync)//, RecordedTestMode.Record) { - BodyKeySanitizers.Add(new BodyKeySanitizer("https://fakeaccount.blob.core.windows.net") { JsonPath = "properties.storageUrl" }); + BodyKeySanitizers.Add(new BodyKeySanitizer("properties.storageUrl") { Value = "https://fakeaccount.blob.core.windows.net" }); } [SetUp] diff --git a/sdk/batch/Azure.ResourceManager.Batch/tests/TestCase/BatchApplicationPackageOperationTests.cs b/sdk/batch/Azure.ResourceManager.Batch/tests/TestCase/BatchApplicationPackageOperationTests.cs index 289e2c33b794..a0817a403da3 100644 --- a/sdk/batch/Azure.ResourceManager.Batch/tests/TestCase/BatchApplicationPackageOperationTests.cs +++ b/sdk/batch/Azure.ResourceManager.Batch/tests/TestCase/BatchApplicationPackageOperationTests.cs @@ -16,7 +16,7 @@ public class BatchApplicationPackageOperationTests : BatchManagementTestBase public BatchApplicationPackageOperationTests(bool isAsync) : base(isAsync)//, RecordedTestMode.Record) { - BodyKeySanitizers.Add(new BodyKeySanitizer("https://fakeaccount.blob.core.windows.net") { JsonPath = "properties.storageUrl" }); + BodyKeySanitizers.Add(new BodyKeySanitizer("properties.storageUrl") { Value = "https://fakeaccount.blob.core.windows.net" }); } [SetUp] diff --git a/sdk/communication/Azure.Communication.CallAutomation/tests/Infrastructure/CallAutomationClientAutomatedLiveTestsBase.cs b/sdk/communication/Azure.Communication.CallAutomation/tests/Infrastructure/CallAutomationClientAutomatedLiveTestsBase.cs index 7686da463215..96d3c5f7ddea 100644 --- a/sdk/communication/Azure.Communication.CallAutomation/tests/Infrastructure/CallAutomationClientAutomatedLiveTestsBase.cs +++ b/sdk/communication/Azure.Communication.CallAutomation/tests/Infrastructure/CallAutomationClientAutomatedLiveTestsBase.cs @@ -52,10 +52,10 @@ public CallAutomationClientAutomatedLiveTestsBase(bool isAsync, RecordedTestMode JsonPathSanitizers.Add("$..botAppId"); JsonPathSanitizers.Add("$..ivrContext"); JsonPathSanitizers.Add("$..dialog.botAppId"); - BodyKeySanitizers.Add(new BodyKeySanitizer(@"https://sanitized.skype.com/api/servicebuscallback/events?q=SanitizedSanitized") { JsonPath = "..callbackUri" }); - BodyRegexSanitizers.Add(new BodyRegexSanitizer(TestDispatcherRegEx, "https://sanitized.skype.com")); - UriRegexSanitizers.Add(new UriRegexSanitizer(URIDomainRegEx, "https://sanitized.skype.com")); - UriRegexSanitizers.Add(new UriRegexSanitizer(TestDispatcherQNameRegEx, SanitizeValue)); + BodyKeySanitizers.Add(new BodyKeySanitizer("..callbackUri") { Value = @"https://sanitized.skype.com/api/servicebuscallback/events?q=SanitizedSanitized"}); + BodyRegexSanitizers.Add(new BodyRegexSanitizer(TestDispatcherRegEx) { Value = "https://sanitized.skype.com" }); + UriRegexSanitizers.Add(new UriRegexSanitizer(URIDomainRegEx) { Value = "https://sanitized.skype.com" }); + UriRegexSanitizers.Add(new UriRegexSanitizer(TestDispatcherQNameRegEx)); } [SetUp] diff --git a/sdk/communication/Azure.Communication.CallAutomation/tests/Infrastructure/CallAutomationClientLiveTestsBase.cs b/sdk/communication/Azure.Communication.CallAutomation/tests/Infrastructure/CallAutomationClientLiveTestsBase.cs index df5f4eac2f50..483a7a8df157 100644 --- a/sdk/communication/Azure.Communication.CallAutomation/tests/Infrastructure/CallAutomationClientLiveTestsBase.cs +++ b/sdk/communication/Azure.Communication.CallAutomation/tests/Infrastructure/CallAutomationClientLiveTestsBase.cs @@ -22,8 +22,8 @@ public CallAutomationClientLiveTestsBase(bool isAsync) : base(isAsync) JsonPathSanitizers.Add("$..id"); JsonPathSanitizers.Add("$..rawId"); JsonPathSanitizers.Add("$..value"); - UriRegexSanitizers.Add(new UriRegexSanitizer(URIDomainRegEx, "https://sanitized.skype.com")); - } + UriRegexSanitizers.Add(new UriRegexSanitizer(URIDomainRegEx) { Value = "https://sanitized.skype.com" }); + } public bool SkipCallAutomationInteractionLiveTests => TestEnvironment.Mode != RecordedTestMode.Playback && Environment.GetEnvironmentVariable("SKIP_CALLAUTOMATION_INTERACTION_LIVE_TESTS")== "TRUE"; diff --git a/sdk/communication/Azure.Communication.CallingServer/tests/Infrastructure/CallAutomationClientLiveTestsBase.cs b/sdk/communication/Azure.Communication.CallingServer/tests/Infrastructure/CallAutomationClientLiveTestsBase.cs index 9c5bfaa8fe6d..466250eab7e7 100644 --- a/sdk/communication/Azure.Communication.CallingServer/tests/Infrastructure/CallAutomationClientLiveTestsBase.cs +++ b/sdk/communication/Azure.Communication.CallingServer/tests/Infrastructure/CallAutomationClientLiveTestsBase.cs @@ -20,7 +20,7 @@ public CallAutomationClientLiveTestsBase(bool isAsync) : base(isAsync) JsonPathSanitizers.Add("$..id"); JsonPathSanitizers.Add("$..rawId"); JsonPathSanitizers.Add("$..value"); - UriRegexSanitizers.Add(new UriRegexSanitizer(URIDomainRegEx, "https://sanitized.skype.com")); + UriRegexSanitizers.Add(new UriRegexSanitizer(URIDomainRegEx) {Value = "https://sanitized.skype.com" }); IgnoredHeaders.Add("Repeatability-Request-ID"); IgnoredHeaders.Add("Repeatability-First-Sent"); } diff --git a/sdk/communication/Azure.Communication.Chat/tests/Infrastructure/ChatLiveTestBase.cs b/sdk/communication/Azure.Communication.Chat/tests/Infrastructure/ChatLiveTestBase.cs index 237301630813..84eaa1feb2fe 100644 --- a/sdk/communication/Azure.Communication.Chat/tests/Infrastructure/ChatLiveTestBase.cs +++ b/sdk/communication/Azure.Communication.Chat/tests/Infrastructure/ChatLiveTestBase.cs @@ -17,8 +17,8 @@ public ChatLiveTestBase(bool isAsync) : base(isAsync) { JsonPathSanitizers.Add("$..token"); SanitizedHeaders.Add("x-ms-content-sha256"); - UriRegexSanitizers.Add(new UriRegexSanitizer(URIDomainNameReplacerRegEx, "https://sanitized.communication.azure.com")); - UriRegexSanitizers.Add(new UriRegexSanitizer(URIIdentityReplacerRegEx, "/identities/Sanitized")); + UriRegexSanitizers.Add(new UriRegexSanitizer(URIDomainNameReplacerRegEx) {Value = "https://sanitized.communication.azure.com" }); + UriRegexSanitizers.Add(new UriRegexSanitizer(URIIdentityReplacerRegEx) { Value = "/identities/Sanitized" }); } /// diff --git a/sdk/communication/Azure.Communication.Email/tests/EmailClientLiveTestBase.cs b/sdk/communication/Azure.Communication.Email/tests/EmailClientLiveTestBase.cs index a2a0e2efef86..ceb67ac889dd 100644 --- a/sdk/communication/Azure.Communication.Email/tests/EmailClientLiveTestBase.cs +++ b/sdk/communication/Azure.Communication.Email/tests/EmailClientLiveTestBase.cs @@ -18,9 +18,9 @@ public EmailClientLiveTestBase(bool isAsync) : base(isAsync) { SanitizedHeaders.Add("x-ms-content-sha256"); SanitizedHeaders.Add("Operation-Id"); - UriRegexSanitizers.Add(new UriRegexSanitizer(URIDomainNameReplacerRegEx, "https://sanitized.communication.azure.com")); - UriRegexSanitizers.Add(new UriRegexSanitizer(URIRoomsIdReplacerRegEx, "emails/operations/sanitizedId?api")); - HeaderRegexSanitizers.Add(new HeaderRegexSanitizer("Operation-Location", "https://sanitized.communication.azure.com/emails/operations/sanitizedId?api-version=2023-03-31")); + UriRegexSanitizers.Add(new UriRegexSanitizer(URIDomainNameReplacerRegEx) { Value = "https://sanitized.communication.azure.com" }); + UriRegexSanitizers.Add(new UriRegexSanitizer(URIRoomsIdReplacerRegEx) { Value = "emails/operations/sanitizedId?api" }); + HeaderRegexSanitizers.Add(new HeaderRegexSanitizer("Operation-Location") { Value = "https://sanitized.communication.azure.com/emails/operations/sanitizedId?api-version=2023-03-31" }); } protected EmailClient CreateEmailClient() diff --git a/sdk/communication/Azure.Communication.Identity/tests/Infrastructure/CommunicationIdentityClientLiveTestBase.cs b/sdk/communication/Azure.Communication.Identity/tests/Infrastructure/CommunicationIdentityClientLiveTestBase.cs index eff5bcdc1df8..c5c61e19f41f 100644 --- a/sdk/communication/Azure.Communication.Identity/tests/Infrastructure/CommunicationIdentityClientLiveTestBase.cs +++ b/sdk/communication/Azure.Communication.Identity/tests/Infrastructure/CommunicationIdentityClientLiveTestBase.cs @@ -27,8 +27,8 @@ public CommunicationIdentityClientLiveTestBase(bool isAsync) : base(isAsync) JsonPathSanitizers.Add("$..userId"); JsonPathSanitizers.Add("$..id"); SanitizedHeaders.Add("x-ms-content-sha256"); - UriRegexSanitizers.Add(new UriRegexSanitizer(URIIdentityReplacerRegEx, "/identities/Sanitized")); - UriRegexSanitizers.Add(new UriRegexSanitizer(URIDomainNameReplacerRegEx, "https://sanitized.communication.azure.com")); + UriRegexSanitizers.Add(new UriRegexSanitizer(URIIdentityReplacerRegEx) { Value = "/identities/Sanitized" }); + UriRegexSanitizers.Add(new UriRegexSanitizer(URIDomainNameReplacerRegEx) { Value = "https://sanitized.communication.azure.com" }); } /// diff --git a/sdk/communication/Azure.Communication.JobRouter/tests/Infrastructure/RouterLiveTestBase.cs b/sdk/communication/Azure.Communication.JobRouter/tests/Infrastructure/RouterLiveTestBase.cs index 28587e2c0e33..9c5d94949af5 100644 --- a/sdk/communication/Azure.Communication.JobRouter/tests/Infrastructure/RouterLiveTestBase.cs +++ b/sdk/communication/Azure.Communication.JobRouter/tests/Infrastructure/RouterLiveTestBase.cs @@ -28,7 +28,7 @@ public RouterLiveTestBase(bool isAsync, RecordedTestMode? mode = RecordedTestMod JsonPathSanitizers.Add("$..functionKey"); JsonPathSanitizers.Add("$..appKey"); SanitizedHeaders.Add("x-ms-content-sha256"); - UriRegexSanitizers.Add(new UriRegexSanitizer(URIDomainRegEx, "https://sanitized.comminication.azure.com")); + UriRegexSanitizers.Add(new UriRegexSanitizer(URIDomainRegEx) { Value = "https://sanitized.comminication.azure.com" }); } [SetUp] diff --git a/sdk/communication/Azure.Communication.Messages/tests/Infrastructure/MessagesLiveTestBase.cs b/sdk/communication/Azure.Communication.Messages/tests/Infrastructure/MessagesLiveTestBase.cs index f2abe6d155e8..2169246add97 100644 --- a/sdk/communication/Azure.Communication.Messages/tests/Infrastructure/MessagesLiveTestBase.cs +++ b/sdk/communication/Azure.Communication.Messages/tests/Infrastructure/MessagesLiveTestBase.cs @@ -18,7 +18,7 @@ public MessagesLiveTestBase(bool isAsync) : base(isAsync) SanitizedHeaders.Add("x-ms-content-sha256"); SanitizedHeaders.Add("Repeatability-Request-ID"); SanitizedHeaders.Add("Repeatability-First-Sent"); - UriRegexSanitizers.Add(new UriRegexSanitizer(URIDomainNameReplacerRegEx, "https://sanitized.communication.azure.com")); + UriRegexSanitizers.Add(new UriRegexSanitizer(URIDomainNameReplacerRegEx) { Value = "https://sanitized.communication.azure.com" }); } protected NotificationMessagesClient CreateInstrumentedNotificationMessagesClient() diff --git a/sdk/communication/Azure.Communication.PhoneNumbers/tests/Infrastructure/PhoneNumbersClientLiveTestBase.cs b/sdk/communication/Azure.Communication.PhoneNumbers/tests/Infrastructure/PhoneNumbersClientLiveTestBase.cs index b1df5451c7d8..c6fc10ee925e 100644 --- a/sdk/communication/Azure.Communication.PhoneNumbers/tests/Infrastructure/PhoneNumbersClientLiveTestBase.cs +++ b/sdk/communication/Azure.Communication.PhoneNumbers/tests/Infrastructure/PhoneNumbersClientLiveTestBase.cs @@ -20,13 +20,13 @@ public class PhoneNumbersClientLiveTestBase : RecordedTestBase diff --git a/sdk/communication/Azure.Communication.Sms/tests/SmsClientLiveTestBase.cs b/sdk/communication/Azure.Communication.Sms/tests/SmsClientLiveTestBase.cs index 476ae5ab4416..bac20471f87e 100644 --- a/sdk/communication/Azure.Communication.Sms/tests/SmsClientLiveTestBase.cs +++ b/sdk/communication/Azure.Communication.Sms/tests/SmsClientLiveTestBase.cs @@ -20,7 +20,7 @@ public SmsClientLiveTestBase(bool isAsync) : base(isAsync) JsonPathSanitizers.Add("$..repeatabilityRequestId"); JsonPathSanitizers.Add("$..repeatabilityFirstSent"); SanitizedHeaders.Add("x-ms-content-sha256"); - UriRegexSanitizers.Add(new UriRegexSanitizer(URIDomainNameReplacerRegEx, "https://sanitized.communication.azure.com")); + UriRegexSanitizers.Add(new UriRegexSanitizer(URIDomainNameReplacerRegEx) { Value = "https://sanitized.communication.azure.com" }); } [OneTimeSetUp] diff --git a/sdk/containerregistry/Azure.Containers.ContainerRegistry/tests/ContainerRegistryRecordedTestBase.cs b/sdk/containerregistry/Azure.Containers.ContainerRegistry/tests/ContainerRegistryRecordedTestBase.cs index 957b39e4ec30..89492b2692b4 100644 --- a/sdk/containerregistry/Azure.Containers.ContainerRegistry/tests/ContainerRegistryRecordedTestBase.cs +++ b/sdk/containerregistry/Azure.Containers.ContainerRegistry/tests/ContainerRegistryRecordedTestBase.cs @@ -111,17 +111,17 @@ private void InitializeRecordingSanitizers() string encodedBody = Base64Url.EncodeString($"{{\"exp\":{expiresOn.ToUnixTimeSeconds()}}}"); var jwtSanitizedValue = $"{SanitizeValue}.{encodedBody}.{SanitizeValue}"; - BodyKeySanitizers.Add(new BodyKeySanitizer(jwtSanitizedValue) + BodyKeySanitizers.Add(new BodyKeySanitizer("$..refresh_token") { - JsonPath = "$..refresh_token" + Value = jwtSanitizedValue }); - BodyRegexSanitizers.Add(new BodyRegexSanitizer(@"access_token=(?.*?)(?=&|$)", SanitizeValue) + BodyRegexSanitizers.Add(new BodyRegexSanitizer(@"access_token=(?.*?)(?=&|$)") { GroupForReplace = "group" }); - BodyRegexSanitizers.Add(new BodyRegexSanitizer(@"refresh_token=(?.*?)(?=&|$)", SanitizeValue) + BodyRegexSanitizers.Add(new BodyRegexSanitizer(@"refresh_token=(?.*?)(?=&|$)") { GroupForReplace = "group" }); diff --git a/sdk/core/Azure.Core.TestFramework/src/Generated/Models/BodyKeySanitizer.Serialization.cs b/sdk/core/Azure.Core.TestFramework/src/Generated/Models/BodyKeySanitizer.Serialization.cs index 703324ecefda..51dba567f57d 100644 --- a/sdk/core/Azure.Core.TestFramework/src/Generated/Models/BodyKeySanitizer.Serialization.cs +++ b/sdk/core/Azure.Core.TestFramework/src/Generated/Models/BodyKeySanitizer.Serialization.cs @@ -15,13 +15,13 @@ public partial class BodyKeySanitizer : IUtf8JsonSerializable void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) { writer.WriteStartObject(); - if (Optional.IsDefined(JsonPath)) + writer.WritePropertyName("jsonPath"u8); + writer.WriteStringValue(JsonPath); + if (Optional.IsDefined(Value)) { - writer.WritePropertyName("jsonPath"u8); - writer.WriteStringValue(JsonPath); + writer.WritePropertyName("value"u8); + writer.WriteStringValue(Value); } - writer.WritePropertyName("value"u8); - writer.WriteStringValue(Value); if (Optional.IsDefined(Regex)) { writer.WritePropertyName("regex"u8); diff --git a/sdk/core/Azure.Core.TestFramework/src/Generated/Models/BodyKeySanitizer.cs b/sdk/core/Azure.Core.TestFramework/src/Generated/Models/BodyKeySanitizer.cs index b5cd7d537f0a..73fce1764004 100644 --- a/sdk/core/Azure.Core.TestFramework/src/Generated/Models/BodyKeySanitizer.cs +++ b/sdk/core/Azure.Core.TestFramework/src/Generated/Models/BodyKeySanitizer.cs @@ -14,19 +14,19 @@ namespace Azure.Core.TestFramework.Models public partial class BodyKeySanitizer { /// Initializes a new instance of BodyKeySanitizer. - /// - /// is null. - public BodyKeySanitizer(string value) + /// + /// is null. + public BodyKeySanitizer(string jsonPath) { - Argument.AssertNotNull(value, nameof(value)); + Argument.AssertNotNull(jsonPath, nameof(jsonPath)); - Value = value; + JsonPath = jsonPath; } - /// Gets or sets the json path. - public string JsonPath { get; set; } - /// Gets the value. - public string Value { get; } + /// Gets the json path. + public string JsonPath { get; } + /// Gets or sets the value. + public string Value { get; set; } /// Gets or sets the regex. public string Regex { get; set; } /// Gets or sets the group for replace. diff --git a/sdk/core/Azure.Core.TestFramework/src/Generated/Models/BodyRegexSanitizer.Serialization.cs b/sdk/core/Azure.Core.TestFramework/src/Generated/Models/BodyRegexSanitizer.Serialization.cs index d2f8ad69dc79..56a2e6dac478 100644 --- a/sdk/core/Azure.Core.TestFramework/src/Generated/Models/BodyRegexSanitizer.Serialization.cs +++ b/sdk/core/Azure.Core.TestFramework/src/Generated/Models/BodyRegexSanitizer.Serialization.cs @@ -17,8 +17,11 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteStartObject(); writer.WritePropertyName("regex"u8); writer.WriteStringValue(Regex); - writer.WritePropertyName("value"u8); - writer.WriteStringValue(Value); + if (Optional.IsDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteStringValue(Value); + } if (Optional.IsDefined(GroupForReplace)) { writer.WritePropertyName("groupForReplace"u8); diff --git a/sdk/core/Azure.Core.TestFramework/src/Generated/Models/BodyRegexSanitizer.cs b/sdk/core/Azure.Core.TestFramework/src/Generated/Models/BodyRegexSanitizer.cs index dc40026ce935..e05f19ec524a 100644 --- a/sdk/core/Azure.Core.TestFramework/src/Generated/Models/BodyRegexSanitizer.cs +++ b/sdk/core/Azure.Core.TestFramework/src/Generated/Models/BodyRegexSanitizer.cs @@ -15,21 +15,18 @@ public partial class BodyRegexSanitizer { /// Initializes a new instance of BodyRegexSanitizer. /// - /// - /// or is null. - public BodyRegexSanitizer(string regex, string value) + /// is null. + public BodyRegexSanitizer(string regex) { Argument.AssertNotNull(regex, nameof(regex)); - Argument.AssertNotNull(value, nameof(value)); Regex = regex; - Value = value; } /// Gets the regex. public string Regex { get; } - /// Gets the value. - public string Value { get; } + /// Gets or sets the value. + public string Value { get; set; } /// Gets or sets the group for replace. public string GroupForReplace { get; set; } /// Condition to apply for the sanitization or transform. If the condition is not met, sanitization/transform is not performed. diff --git a/sdk/core/Azure.Core.TestFramework/src/Generated/Models/HeaderRegexSanitizer.Serialization.cs b/sdk/core/Azure.Core.TestFramework/src/Generated/Models/HeaderRegexSanitizer.Serialization.cs index 4be8f40c2461..3f7b845c7fed 100644 --- a/sdk/core/Azure.Core.TestFramework/src/Generated/Models/HeaderRegexSanitizer.Serialization.cs +++ b/sdk/core/Azure.Core.TestFramework/src/Generated/Models/HeaderRegexSanitizer.Serialization.cs @@ -17,8 +17,11 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteStartObject(); writer.WritePropertyName("key"u8); writer.WriteStringValue(Key); - writer.WritePropertyName("value"u8); - writer.WriteStringValue(Value); + if (Optional.IsDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteStringValue(Value); + } if (Optional.IsDefined(Regex)) { writer.WritePropertyName("regex"u8); diff --git a/sdk/core/Azure.Core.TestFramework/src/Generated/Models/HeaderRegexSanitizer.cs b/sdk/core/Azure.Core.TestFramework/src/Generated/Models/HeaderRegexSanitizer.cs index 292c844b8861..21328d5c5ece 100644 --- a/sdk/core/Azure.Core.TestFramework/src/Generated/Models/HeaderRegexSanitizer.cs +++ b/sdk/core/Azure.Core.TestFramework/src/Generated/Models/HeaderRegexSanitizer.cs @@ -15,21 +15,18 @@ public partial class HeaderRegexSanitizer { /// Initializes a new instance of HeaderRegexSanitizer. /// - /// - /// or is null. - public HeaderRegexSanitizer(string key, string value) + /// is null. + public HeaderRegexSanitizer(string key) { Argument.AssertNotNull(key, nameof(key)); - Argument.AssertNotNull(value, nameof(value)); Key = key; - Value = value; } /// Gets the key. public string Key { get; } - /// Gets the value. - public string Value { get; } + /// Gets or sets the value. + public string Value { get; set; } /// Gets or sets the regex. public string Regex { get; set; } /// Gets or sets the group for replace. diff --git a/sdk/core/Azure.Core.TestFramework/src/Generated/Models/HeaderTransform.Serialization.cs b/sdk/core/Azure.Core.TestFramework/src/Generated/Models/HeaderTransform.Serialization.cs index 104b78a727d9..477dc45f5101 100644 --- a/sdk/core/Azure.Core.TestFramework/src/Generated/Models/HeaderTransform.Serialization.cs +++ b/sdk/core/Azure.Core.TestFramework/src/Generated/Models/HeaderTransform.Serialization.cs @@ -17,8 +17,11 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteStartObject(); writer.WritePropertyName("key"u8); writer.WriteStringValue(Key); - writer.WritePropertyName("value"u8); - writer.WriteStringValue(Value); + if (Optional.IsDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteStringValue(Value); + } if (Optional.IsDefined(Condition)) { writer.WritePropertyName("condition"u8); diff --git a/sdk/core/Azure.Core.TestFramework/src/Generated/Models/HeaderTransform.cs b/sdk/core/Azure.Core.TestFramework/src/Generated/Models/HeaderTransform.cs index eccaa0526381..ab2a51d3de7e 100644 --- a/sdk/core/Azure.Core.TestFramework/src/Generated/Models/HeaderTransform.cs +++ b/sdk/core/Azure.Core.TestFramework/src/Generated/Models/HeaderTransform.cs @@ -15,21 +15,18 @@ public partial class HeaderTransform { /// Initializes a new instance of HeaderTransform. /// - /// - /// or is null. - public HeaderTransform(string key, string value) + /// is null. + public HeaderTransform(string key) { Argument.AssertNotNull(key, nameof(key)); - Argument.AssertNotNull(value, nameof(value)); Key = key; - Value = value; } /// Gets the key. public string Key { get; } - /// Gets the value. - public string Value { get; } + /// Gets or sets the value. + public string Value { get; set; } /// Condition to apply for the sanitization or transform. If the condition is not met, sanitization/transform is not performed. public Condition Condition { get; set; } } diff --git a/sdk/core/Azure.Core.TestFramework/src/Generated/Models/UriRegexSanitizer.Serialization.cs b/sdk/core/Azure.Core.TestFramework/src/Generated/Models/UriRegexSanitizer.Serialization.cs index 149f8fcfaff3..129fc51f66d3 100644 --- a/sdk/core/Azure.Core.TestFramework/src/Generated/Models/UriRegexSanitizer.Serialization.cs +++ b/sdk/core/Azure.Core.TestFramework/src/Generated/Models/UriRegexSanitizer.Serialization.cs @@ -17,8 +17,11 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteStartObject(); writer.WritePropertyName("regex"u8); writer.WriteStringValue(Regex); - writer.WritePropertyName("value"u8); - writer.WriteStringValue(Value); + if (Optional.IsDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteStringValue(Value); + } if (Optional.IsDefined(GroupForReplace)) { writer.WritePropertyName("groupForReplace"u8); diff --git a/sdk/core/Azure.Core.TestFramework/src/Generated/Models/UriRegexSanitizer.cs b/sdk/core/Azure.Core.TestFramework/src/Generated/Models/UriRegexSanitizer.cs index d66de6445e74..114444daa83d 100644 --- a/sdk/core/Azure.Core.TestFramework/src/Generated/Models/UriRegexSanitizer.cs +++ b/sdk/core/Azure.Core.TestFramework/src/Generated/Models/UriRegexSanitizer.cs @@ -15,21 +15,18 @@ public partial class UriRegexSanitizer { /// Initializes a new instance of UriRegexSanitizer. /// - /// - /// or is null. - public UriRegexSanitizer(string regex, string value) + /// is null. + public UriRegexSanitizer(string regex) { Argument.AssertNotNull(regex, nameof(regex)); - Argument.AssertNotNull(value, nameof(value)); Regex = regex; - Value = value; } /// Gets the regex. public string Regex { get; } - /// Gets the value. - public string Value { get; } + /// Gets or sets the value. + public string Value { get; set; } /// Gets or sets the group for replace. public string GroupForReplace { get; set; } } diff --git a/sdk/core/Azure.Core.TestFramework/src/HeaderRegexSanitizer.cs b/sdk/core/Azure.Core.TestFramework/src/HeaderRegexSanitizer.cs index f64ee849235f..8edac6ced22c 100644 --- a/sdk/core/Azure.Core.TestFramework/src/HeaderRegexSanitizer.cs +++ b/sdk/core/Azure.Core.TestFramework/src/HeaderRegexSanitizer.cs @@ -5,12 +5,13 @@ namespace Azure.Core.TestFramework.Models { public partial class HeaderRegexSanitizer { - public static HeaderRegexSanitizer CreateWithQueryParameter(string headerKey, string queryParameter, string value) => - new(headerKey, value) + public static HeaderRegexSanitizer CreateWithQueryParameter(string headerKey, string queryParameter, string sanitizedValue) => + new(headerKey) { // match the value of the query parameter up until the next ampersand or the end of the string Regex = $@"([\x0026|&|?]{queryParameter}=)(?[^&]+)", - GroupForReplace = "group" + GroupForReplace = "group", + Value = sanitizedValue }; } } diff --git a/sdk/core/Azure.Core.TestFramework/src/RecordedTestBase.cs b/sdk/core/Azure.Core.TestFramework/src/RecordedTestBase.cs index 6e34afa2e4ef..a4954ad99345 100644 --- a/sdk/core/Azure.Core.TestFramework/src/RecordedTestBase.cs +++ b/sdk/core/Azure.Core.TestFramework/src/RecordedTestBase.cs @@ -177,9 +177,10 @@ public string ReplacementHost { _replacementHost = value; UriRegexSanitizers.Add( - new UriRegexSanitizer(@"https://(?[^/]+)/", _replacementHost) + new UriRegexSanitizer(@"https://(?[^/]+)/") { - GroupForReplace = "host" + GroupForReplace = "host", + Value = _replacementHost }); } } diff --git a/sdk/core/Azure.Core.TestFramework/src/TestRecording.cs b/sdk/core/Azure.Core.TestFramework/src/TestRecording.cs index 44afcdc9d64a..434200d0a147 100644 --- a/sdk/core/Azure.Core.TestFramework/src/TestRecording.cs +++ b/sdk/core/Azure.Core.TestFramework/src/TestRecording.cs @@ -99,7 +99,7 @@ private async Task ApplySanitizersAsync() { foreach (string header in _recordedTestBase.SanitizedHeaders) { - await _proxy.Client.AddHeaderSanitizerAsync(new HeaderRegexSanitizer(header, Sanitized), RecordingId); + await _proxy.Client.AddHeaderSanitizerAsync(new HeaderRegexSanitizer(header), RecordingId); } foreach (var header in _recordedTestBase.HeaderRegexSanitizers) @@ -128,7 +128,7 @@ await _proxy.Client.AddUriSanitizerAsync( foreach (string path in _recordedTestBase.JsonPathSanitizers) { - await _proxy.Client.AddBodyKeySanitizerAsync(new BodyKeySanitizer(Sanitized) { JsonPath = path }, RecordingId); + await _proxy.Client.AddBodyKeySanitizerAsync(new BodyKeySanitizer(path), RecordingId); } foreach (BodyKeySanitizer sanitizer in _recordedTestBase.BodyKeySanitizers) diff --git a/sdk/core/Azure.Core.TestFramework/src/UriRegexSanitizer.cs b/sdk/core/Azure.Core.TestFramework/src/UriRegexSanitizer.cs index 2772118d8845..5f2840e1aaa2 100644 --- a/sdk/core/Azure.Core.TestFramework/src/UriRegexSanitizer.cs +++ b/sdk/core/Azure.Core.TestFramework/src/UriRegexSanitizer.cs @@ -5,10 +5,11 @@ namespace Azure.Core.TestFramework.Models { public partial class UriRegexSanitizer { - public static UriRegexSanitizer CreateWithQueryParameter(string queryParameter, string value) => - new($@"([\x0026|&|?]{queryParameter}=)(?[^&]+)", value) + public static UriRegexSanitizer CreateWithQueryParameter(string queryParameter, string sanitizedValue) => + new($@"([\x0026|&|?]{queryParameter}=)(?[^&]+)") { - GroupForReplace = "group" + GroupForReplace = "group", + Value = sanitizedValue }; } } diff --git a/sdk/core/Azure.Core.TestFramework/src/testproxy.json b/sdk/core/Azure.Core.TestFramework/src/testproxy.json index 84a01751ceac..5012901cfc8d 100644 --- a/sdk/core/Azure.Core.TestFramework/src/testproxy.json +++ b/sdk/core/Azure.Core.TestFramework/src/testproxy.json @@ -700,8 +700,7 @@ } }, "required": [ - "key", - "value" + "key" ] }, "BodyKeySanitizer": { @@ -722,7 +721,7 @@ } }, "required": [ - "value" + "jsonPath" ] }, "BodyRegexSanitizer": { @@ -743,8 +742,7 @@ } }, "required": [ - "regex", - "value" + "regex" ] }, "HeaderRegexSanitizer": { @@ -765,8 +763,7 @@ } }, "required": [ - "key", - "value" + "key" ] }, "UriRegexSanitizer": { @@ -784,8 +781,7 @@ } }, "required": [ - "regex", - "value" + "regex" ] }, "Condition": { diff --git a/sdk/documentintelligence/Azure.AI.DocumentIntelligence/tests/Infrastructure/DocumentIntelligenceLiveTestBase.cs b/sdk/documentintelligence/Azure.AI.DocumentIntelligence/tests/Infrastructure/DocumentIntelligenceLiveTestBase.cs index 751d9e56d5d4..4aaa1076cc8e 100644 --- a/sdk/documentintelligence/Azure.AI.DocumentIntelligence/tests/Infrastructure/DocumentIntelligenceLiveTestBase.cs +++ b/sdk/documentintelligence/Azure.AI.DocumentIntelligence/tests/Infrastructure/DocumentIntelligenceLiveTestBase.cs @@ -15,7 +15,7 @@ public DocumentIntelligenceLiveTestBase(bool isAsync, RecordedTestMode? mode = n : base(isAsync, mode) { JsonPathSanitizers.Add("$..accessToken"); - BodyKeySanitizers.Add(new BodyKeySanitizer("https://sanitized.blob.core.windows.net") { JsonPath = "$..containerUrl" }); + BodyKeySanitizers.Add(new BodyKeySanitizer("$..containerUrl") { Value = "https://sanitized.blob.core.windows.net" }); SanitizedHeaders.Add("Ocp-Apim-Subscription-Key"); } diff --git a/sdk/formrecognizer/Azure.AI.FormRecognizer/tests/Infrastructure/DocumentAnalysisLiveTestBase.cs b/sdk/formrecognizer/Azure.AI.FormRecognizer/tests/Infrastructure/DocumentAnalysisLiveTestBase.cs index e3de8620497b..7594aec2e501 100644 --- a/sdk/formrecognizer/Azure.AI.FormRecognizer/tests/Infrastructure/DocumentAnalysisLiveTestBase.cs +++ b/sdk/formrecognizer/Azure.AI.FormRecognizer/tests/Infrastructure/DocumentAnalysisLiveTestBase.cs @@ -34,7 +34,7 @@ public DocumentAnalysisLiveTestBase(bool isAsync, DocumentAnalysisClientOptions. }; JsonPathSanitizers.Add("$..accessToken"); - BodyKeySanitizers.Add(new BodyKeySanitizer("https://sanitized.blob.core.windows.net") { JsonPath = "$..containerUrl" }); + BodyKeySanitizers.Add(new BodyKeySanitizer("$..containerUrl") { Value = "https://sanitized.blob.core.windows.net" }); SanitizedHeaders.Add(Constants.AuthorizationHeader); } diff --git a/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/tests/HealthcareApisManagementTestBase.cs b/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/tests/HealthcareApisManagementTestBase.cs index 1e3c8461d384..cdc8f8dc9e3e 100644 --- a/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/tests/HealthcareApisManagementTestBase.cs +++ b/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/tests/HealthcareApisManagementTestBase.cs @@ -24,16 +24,32 @@ protected HealthcareApisManagementTestBase(bool isAsync, RecordedTestMode mode) : base(isAsync, mode) { JsonPathSanitizers.Add("$..authority"); - UriRegexSanitizers.Add(new UriRegexSanitizer(@"/Microsoft.EventHub/namespaces/[^/]+api-version=(?[a-z0-9-]+)", "**") { GroupForReplace = "group" }); - UriRegexSanitizers.Add(new UriRegexSanitizer(@"/Microsoft.EventHub/namespaces/[^/]+/eventhubs/[^/]+api-version=(?[a-z0-9-]+)", "**") { GroupForReplace = "group" }); + UriRegexSanitizers.Add(new UriRegexSanitizer(@"/Microsoft.EventHub/namespaces/[^/]+api-version=(?[a-z0-9-]+)") + { + GroupForReplace = "group", + Value = "**" + }); + UriRegexSanitizers.Add(new UriRegexSanitizer(@"/Microsoft.EventHub/namespaces/[^/]+/eventhubs/[^/]+api-version=(?[a-z0-9-]+)") + { + GroupForReplace = "group", + Value = "**" + }); } protected HealthcareApisManagementTestBase(bool isAsync) : base(isAsync) { JsonPathSanitizers.Add("$..authority"); - UriRegexSanitizers.Add(new UriRegexSanitizer(@"/Microsoft.EventHub/namespaces/[^/]+api-version=(?[a-z0-9-]+)", "**") { GroupForReplace = "group" }); - UriRegexSanitizers.Add(new UriRegexSanitizer(@"/Microsoft.EventHub/namespaces/[^/]+/eventhubs/[^/]+api-version=(?[a-z0-9-]+)", "**") { GroupForReplace = "group" }); + UriRegexSanitizers.Add(new UriRegexSanitizer(@"/Microsoft.EventHub/namespaces/[^/]+api-version=(?[a-z0-9-]+)") + { + GroupForReplace = "group", + Value = "**" + }); + UriRegexSanitizers.Add(new UriRegexSanitizer(@"/Microsoft.EventHub/namespaces/[^/]+/eventhubs/[^/]+api-version=(?[a-z0-9-]+)") + { + GroupForReplace = "group", + Value = "**" + }); } [SetUp] diff --git a/sdk/identity/Azure.Identity/tests/IdentityRecordedTestBase.cs b/sdk/identity/Azure.Identity/tests/IdentityRecordedTestBase.cs index a005f4500850..711800a04833 100644 --- a/sdk/identity/Azure.Identity/tests/IdentityRecordedTestBase.cs +++ b/sdk/identity/Azure.Identity/tests/IdentityRecordedTestBase.cs @@ -37,14 +37,14 @@ private void InitializeRecordingSettings() SanitizedHeaders.Add("secret"); JsonPathSanitizers.Add("$..refresh_token"); JsonPathSanitizers.Add("$..access_token"); - BodyRegexSanitizers.Add(new BodyRegexSanitizer(@"=[^&|}|""]+", "=" + SanitizeValue) + BodyRegexSanitizers.Add(new BodyRegexSanitizer(@"=[^&|}|""]+") { - Condition = new Condition { UriRegex = ".*/token([?].*)?$" } + Condition = new Condition { UriRegex = ".*/token([?].*)?$" }, + Value = "=" + SanitizeValue }); - HeaderTransforms.Add(new HeaderTransform( - "WWW-Authenticate", - $"Basic realm={Path.Combine(TestContext.CurrentContext.TestDirectory, "Data", "mock-arc-mi-key.key")}") + HeaderTransforms.Add(new HeaderTransform("WWW-Authenticate") { + Value = $"Basic realm={Path.Combine(TestContext.CurrentContext.TestDirectory, "Data", "mock-arc-mi-key.key")}", Condition = new Condition { ResponseHeader = new HeaderCondition diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/tests/LoadTestTestsBase.cs b/sdk/loadtestservice/Azure.Developer.LoadTesting/tests/LoadTestTestsBase.cs index e340544586b1..66d94e03b28e 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/tests/LoadTestTestsBase.cs +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/tests/LoadTestTestsBase.cs @@ -68,10 +68,9 @@ public LoadTestTestsBase(bool isAsync) : base(isAsync) _testRunId = "test-run-id-from-csharp-sdk"; _testHelper = new TestHelper(); - BodyKeySanitizers.Add(new BodyKeySanitizer(SanitizeValue) + BodyKeySanitizers.Add(new BodyKeySanitizer("$..url") { GroupForReplace = "group", - JsonPath = "$..url", Regex = @"sig=(?.*?)(?=$|&)" }); } diff --git a/sdk/metricsadvisor/Azure.AI.MetricsAdvisor/tests/MetricsAdvisorLiveTestBase.cs b/sdk/metricsadvisor/Azure.AI.MetricsAdvisor/tests/MetricsAdvisorLiveTestBase.cs index 441276c37c1c..1770a4328bad 100644 --- a/sdk/metricsadvisor/Azure.AI.MetricsAdvisor/tests/MetricsAdvisorLiveTestBase.cs +++ b/sdk/metricsadvisor/Azure.AI.MetricsAdvisor/tests/MetricsAdvisorLiveTestBase.cs @@ -31,7 +31,7 @@ public MetricsAdvisorLiveTestBase(bool isAsync, RecordedTestMode? mode = default JsonPathSanitizers.Add("$..accountKey"); JsonPathSanitizers.Add("$..authHeader"); JsonPathSanitizers.Add("$..httpHeader"); - BodyRegexSanitizers.Add(new BodyRegexSanitizer(@"\w+@microsoft.com", "foo@contoso.com")); + BodyRegexSanitizers.Add(new BodyRegexSanitizer(@"\w+@microsoft.com") { Value = "foo@contoso.com" }); } internal const string DetectionConfigurationId = "78f3a4e7-fe53-4a05-9f4d-d724ab6c23a7"; diff --git a/sdk/migrationdiscoverysap/Azure.ResourceManager.MigrationDiscoverySap/tests/Tests/MigrationSapDiscoveryTests.cs b/sdk/migrationdiscoverysap/Azure.ResourceManager.MigrationDiscoverySap/tests/Tests/MigrationSapDiscoveryTests.cs index 166d66ca11d7..d38d4fe00ac9 100644 --- a/sdk/migrationdiscoverysap/Azure.ResourceManager.MigrationDiscoverySap/tests/Tests/MigrationSapDiscoveryTests.cs +++ b/sdk/migrationdiscoverysap/Azure.ResourceManager.MigrationDiscoverySap/tests/Tests/MigrationSapDiscoveryTests.cs @@ -25,7 +25,7 @@ public class MigrationSapDiscoveryTests : MigrationDiscoverySapManagementTestBas { public MigrationSapDiscoveryTests(bool isAsync) : base(isAsync) { - BodyKeySanitizers.Add(new BodyKeySanitizer(SanitizeValue) { JsonPath = "properties.discoveryExcelSasUri" }); + BodyKeySanitizers.Add(new BodyKeySanitizer("properties.discoveryExcelSasUri")); } [TestCase] diff --git a/sdk/mysql/Azure.ResourceManager.MySql/tests/Scenario/MySqlFlexibleServerTests.cs b/sdk/mysql/Azure.ResourceManager.MySql/tests/Scenario/MySqlFlexibleServerTests.cs index 9d482f619836..6467f6158fb2 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/tests/Scenario/MySqlFlexibleServerTests.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/tests/Scenario/MySqlFlexibleServerTests.cs @@ -18,8 +18,8 @@ public class MySqlFlexibleServerTests: MySqlManagementTestBase public MySqlFlexibleServerTests(bool isAsync) : base(isAsync)//,RecordedTestMode.Record) { - BodyKeySanitizers.Add(new BodyKeySanitizer("https://fakeaccout.blob.windows.core.net/fakecontainer") { JsonPath = "properties.importSourceProperties.storageUrl" }); - BodyKeySanitizers.Add(new BodyKeySanitizer(SanitizeValue) { JsonPath = "properties.importSourceProperties.sasToken" }); + BodyKeySanitizers.Add(new BodyKeySanitizer("properties.importSourceProperties.storageUrl") { Value = "https://fakeaccout.blob.windows.core.net/fakecontainer" }); + BodyKeySanitizers.Add(new BodyKeySanitizer("properties.importSourceProperties.sasToken")); } [TestCase] diff --git a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/tests/NetworkCloudManagementTestBase.cs b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/tests/NetworkCloudManagementTestBase.cs index c81d6469fff4..381ed35cf20e 100644 --- a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/tests/NetworkCloudManagementTestBase.cs +++ b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/tests/NetworkCloudManagementTestBase.cs @@ -20,13 +20,13 @@ public class NetworkCloudManagementTestBase : ManagementRecordedTestBase\\n)", - "\r\n") + "[^\\r](?\\n)") { - GroupForReplace = "break" + GroupForReplace = "break", + Value = "\r\n" }); _serviceVersion = serviceVersion; } diff --git a/sdk/servicelinker/Azure.ResourceManager.ServiceLinker/tests/Tests/WebAppWebPubSubConnectionTests.cs b/sdk/servicelinker/Azure.ResourceManager.ServiceLinker/tests/Tests/WebAppWebPubSubConnectionTests.cs index 74de0290100b..039d919a6466 100644 --- a/sdk/servicelinker/Azure.ResourceManager.ServiceLinker/tests/Tests/WebAppWebPubSubConnectionTests.cs +++ b/sdk/servicelinker/Azure.ResourceManager.ServiceLinker/tests/Tests/WebAppWebPubSubConnectionTests.cs @@ -17,7 +17,7 @@ public class WebAppWebPubSubConnectionTests : ServiceLinkerTestBase { public WebAppWebPubSubConnectionTests() : base(true) { - BodyKeySanitizers.Add(new Core.TestFramework.Models.BodyKeySanitizer("Sanitized") { JsonPath = "$..value", Regex = "AccessKey=.*" }); + BodyKeySanitizers.Add(new Core.TestFramework.Models.BodyKeySanitizer("$..value") { Regex = "AccessKey=.*" }); } [SetUp] diff --git a/sdk/storage/Azure.Storage.Blobs.Batch/tests/BlobBatchClientTests.cs b/sdk/storage/Azure.Storage.Blobs.Batch/tests/BlobBatchClientTests.cs index ac5d9e0d3cc3..e846382d5ead 100644 --- a/sdk/storage/Azure.Storage.Blobs.Batch/tests/BlobBatchClientTests.cs +++ b/sdk/storage/Azure.Storage.Blobs.Batch/tests/BlobBatchClientTests.cs @@ -30,9 +30,10 @@ public BlobBatchClientTests(bool async, BlobClientOptions.ServiceVersion service { // Batch delimiters are random so disable body comparison CompareBodies = false; - BodyRegexSanitizers.Add(new BodyRegexSanitizer(@"sig=(?.*?)(?=\s+)", SanitizeValue) + BodyRegexSanitizers.Add(new BodyRegexSanitizer(@"sig=(?.*?)(?=\s+)") { - GroupForReplace = "group" + GroupForReplace = "group", + Value = SanitizeValue }); } diff --git a/sdk/storage/Azure.Storage.Common/tests/Shared/StorageTestBase.cs b/sdk/storage/Azure.Storage.Common/tests/Shared/StorageTestBase.cs index 15f71f1b63c0..a2050b43d996 100644 --- a/sdk/storage/Azure.Storage.Common/tests/Shared/StorageTestBase.cs +++ b/sdk/storage/Azure.Storage.Common/tests/Shared/StorageTestBase.cs @@ -49,26 +49,31 @@ public StorageTestBase(bool async, RecordedTestMode? mode = null) #if NETFRAMEWORK // Uri uses different escaping for some special characters between .NET Framework and Core. Because the Test Proxy runs on .NET // Core, we need to normalize to the .NET Core escaping when matching and storing the recordings when running tests on NetFramework. - UriRegexSanitizers.Add(new UriRegexSanitizer("\\(", "%28")); - UriRegexSanitizers.Add(new UriRegexSanitizer("\\)", "%29")); - UriRegexSanitizers.Add(new UriRegexSanitizer("\\!", "%21")); - UriRegexSanitizers.Add(new UriRegexSanitizer("\\'", "%27")); - UriRegexSanitizers.Add(new UriRegexSanitizer("\\*", "%2A")); + UriRegexSanitizers.Add(new UriRegexSanitizer("\\("){ Value = "%28" }); + UriRegexSanitizers.Add(new UriRegexSanitizer("\\)"){ Value = "%29" }); + UriRegexSanitizers.Add(new UriRegexSanitizer("\\!"){ Value = "%21" }); + UriRegexSanitizers.Add(new UriRegexSanitizer("\\'"){ Value = "%27" }); + UriRegexSanitizers.Add(new UriRegexSanitizer("\\*"){ Value = "%2A" }); // Encode any colons in the Uri except for the one in the scheme - UriRegexSanitizers.Add(new UriRegexSanitizer("(?:)[^//]", "%3A") {GroupForReplace = "group"}); + UriRegexSanitizers.Add(new UriRegexSanitizer("(?:)[^//]") + { + GroupForReplace = "group", + Value = "%3A" + }); #endif - HeaderRegexSanitizers.Add(new HeaderRegexSanitizer("x-ms-encryption-key", SanitizeValue)); - HeaderRegexSanitizers.Add(new HeaderRegexSanitizer(CopySourceAuthorization, SanitizeValue)); + HeaderRegexSanitizers.Add(new HeaderRegexSanitizer("x-ms-encryption-key")); + HeaderRegexSanitizers.Add(new HeaderRegexSanitizer(CopySourceAuthorization)); SanitizedQueryParametersInHeaders.Add((CopySourceName, SignatureQueryName)); SanitizedQueryParametersInHeaders.Add((RenameSource, SignatureQueryName)); SanitizedQueryParametersInHeaders.Add((PreviousSnapshotUrl, SignatureQueryName)); SanitizedQueryParametersInHeaders.Add((FileRenameSource, SignatureQueryName)); - BodyRegexSanitizers.Add(new BodyRegexSanitizer(@"client_secret=(?.*?)(?=&|$)", SanitizeValue) + BodyRegexSanitizers.Add(new BodyRegexSanitizer(@"client_secret=(?.*?)(?=&|$)") { - GroupForReplace = "group" + GroupForReplace = "group", + Value = SanitizeValue }); Tenants = new TenantConfigurationBuilder(this); diff --git a/sdk/subscription/Azure.ResourceManager.Subscription/tests/SubscriptionManagementTestBase.cs b/sdk/subscription/Azure.ResourceManager.Subscription/tests/SubscriptionManagementTestBase.cs index b7240ff41e08..44c0b5eee619 100644 --- a/sdk/subscription/Azure.ResourceManager.Subscription/tests/SubscriptionManagementTestBase.cs +++ b/sdk/subscription/Azure.ResourceManager.Subscription/tests/SubscriptionManagementTestBase.cs @@ -45,17 +45,17 @@ private void IgnoreApiVersionInTagOperations() { // Ignore the api-version of tagNames operations including list UriRegexSanitizers.Add(new UriRegexSanitizer( - @"/subscriptions/[^/]+/tagNames[/]?[^/]*api-version=(?[a-z0-9-]+)", "**" - ) + @"/subscriptions/[^/]+/tagNames[/]?[^/]*api-version=(?[a-z0-9-]+)") { - GroupForReplace = "group" + GroupForReplace = "group", + Value = "**" }); // Ignore the api-version of tagValues operations UriRegexSanitizers.Add(new UriRegexSanitizer( - @"/subscriptions/[^/]+/tagNames/[^/]+/tagValues/[^/]+api-version=(?[a-z0-9-]+)", "**" - ) + @"/subscriptions/[^/]+/tagNames/[^/]+/tagValues/[^/]+api-version=(?[a-z0-9-]+)") { - GroupForReplace = "group" + GroupForReplace = "group", + Value = "**" }); } } diff --git a/sdk/tables/Azure.Data.Tables/tests/TableServiceLiveTestsBase.cs b/sdk/tables/Azure.Data.Tables/tests/TableServiceLiveTestsBase.cs index f681204d7c9c..fa450ac6dd1b 100644 --- a/sdk/tables/Azure.Data.Tables/tests/TableServiceLiveTestsBase.cs +++ b/sdk/tables/Azure.Data.Tables/tests/TableServiceLiveTestsBase.cs @@ -31,7 +31,7 @@ public TableServiceLiveTestsBase(bool isAsync, TableEndpointType endpointType, R _enableTenantDiscovery = enableTenantDiscovery; SanitizedHeaders.Add("My-Custom-Auth-Header"); UriRegexSanitizers.Add( - new UriRegexSanitizer(@"([\x0026|&|?]sig=)(?[\w\d%]+)", SanitizeValue) + new UriRegexSanitizer(@"([\x0026|&|?]sig=)(?[\w\d%]+)") { GroupForReplace = "group" }); diff --git a/sdk/vision/Azure.AI.Vision.ImageAnalysis/tests/ImageAnalysisTestBase.cs b/sdk/vision/Azure.AI.Vision.ImageAnalysis/tests/ImageAnalysisTestBase.cs index bcc9873b0f0a..5c231dcabb94 100644 --- a/sdk/vision/Azure.AI.Vision.ImageAnalysis/tests/ImageAnalysisTestBase.cs +++ b/sdk/vision/Azure.AI.Vision.ImageAnalysis/tests/ImageAnalysisTestBase.cs @@ -20,8 +20,8 @@ public abstract class ImageAnalysisTestBase : RecordedTestBase