Skip to content

Commit

Permalink
Correct test proxy swagger (#44012)
Browse files Browse the repository at this point in the history
* Correct test proxy swagger

* Fix ManagementRecordedTestBase.cs

* Fix call sites

* Value

* more

* fix mgmt

* fix mgmt
  • Loading branch information
JoshLove-msft authored May 15, 2024
1 parent 2a0e020 commit f2d11b2
Show file tree
Hide file tree
Showing 58 changed files with 282 additions and 220 deletions.
28 changes: 12 additions & 16 deletions common/ManagementTestShared/Redesign/ManagementRecordedTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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=(?<group>[a-z0-9-]+)", "**"
)
UriRegexSanitizers.Add(new UriRegexSanitizer(@"/providers\/Microsoft.Network\/(.*?)\?api-version=(?<group>[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=(?<group>[a-z0-9-]+)", "**"
)
UriRegexSanitizers.Add(new UriRegexSanitizer(@"/providers\/Microsoft.Authorization\/(.*?)\?api-version=(?<group>[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=(?<group>[a-z0-9-]+)", "**"
)
UriRegexSanitizers.Add(new UriRegexSanitizer(@"/providers\/Microsoft.KeyVault\/(.*?)\?api-version=(?<group>[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=(?<group>[a-z0-9-]+)", "**"
)
UriRegexSanitizers.Add(new UriRegexSanitizer(@"/providers\/Microsoft.ManagedIdentity\/(.*?)\?api-version=(?<group>[a-z0-9-]+)")
{
GroupForReplace = "group"
GroupForReplace = "group",
Value = "**"
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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=(?<group>[a-z0-9-]+)", "**"
)
@"/providers/Microsoft.EventHub/namespaces/([\S]+)?pi-version=(?<group>[a-z0-9-]+)")
{
GroupForReplace = "group"
GroupForReplace = "group",
Value = "**"
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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=(?<group>[a-z0-9-]+)", "**"
)
@"/providers/Microsoft.Resources/deployments/[^/]+(/operationStatuses/[^/]+)?pi-version=(?<group>[a-z0-9-]+)")
{
GroupForReplace = "group"
GroupForReplace = "group",
Value = "**"
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" });
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" });
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ public class PhoneNumbersClientLiveTestBase : RecordedTestBase<PhoneNumbersClien

public PhoneNumbersClientLiveTestBase(bool isAsync) : base(isAsync)
{
HeaderRegexSanitizers.Add(new HeaderRegexSanitizer("location", SanitizeValue)
HeaderRegexSanitizers.Add(new HeaderRegexSanitizer("location")
{
Regex = PhoneNumberRegEx
});
BodyRegexSanitizers.Add(new BodyRegexSanitizer(PhoneNumberRegEx, SanitizeValue));
UriRegexSanitizers.Add(new UriRegexSanitizer(PhoneNumberRegEx, SanitizeValue));
UriRegexSanitizers.Add(new UriRegexSanitizer(URIDomainNameReplacerRegEx, "https://sanitized.communication.azure.com"));
BodyRegexSanitizers.Add(new BodyRegexSanitizer(PhoneNumberRegEx));
UriRegexSanitizers.Add(new UriRegexSanitizer(PhoneNumberRegEx));
UriRegexSanitizers.Add(new UriRegexSanitizer(URIDomainNameReplacerRegEx) { Value = "https://sanitized.communication.azure.com" });
SanitizedHeaders.Add("x-ms-content-sha256");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public SipRoutingClientLiveTestBase(bool isAsync) : base(isAsync)

JsonPathSanitizers.Add("$..credential");
SanitizedHeaders.Add("x-ms-content-sha256");
UriRegexSanitizers.Add(new UriRegexSanitizer(URIDomainNameReplacerRegEx, "https://sanitized.communication.azure.com"));
BodyRegexSanitizers.Add(new BodyRegexSanitizer(testDomain, DummyTestDomain));
UriRegexSanitizers.Add(new UriRegexSanitizer(URIDomainNameReplacerRegEx) { Value = "https://sanitized.communication.azure.com" });
BodyRegexSanitizers.Add(new BodyRegexSanitizer(testDomain) { Value = DummyTestDomain });
}

[SetUp]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ public class ProgrammableConnectivityClientTest : RecordedTestBase<ProgrammableC
public ProgrammableConnectivityClientTest(bool isAsync) : base(isAsync, RecordedTestMode.Playback)
{
HeaderRegexSanitizers.Add(
new HeaderRegexSanitizer("apc-gateway-id", "**********/resourceGroups")
{ Regex = @"[A-Za-z0-9-\-]+/resourceGroups" });
new HeaderRegexSanitizer("apc-gateway-id")
{
Regex = @"[A-Za-z0-9-\-]+/resourceGroups",
Value = "**********/resourceGroups"
});
credential = TestEnvironment.Credential;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ public RoomsClientLiveTestBase(bool isAsync) : base(isAsync)
JsonPathSanitizers.Add("$..token");
JsonPathSanitizers.Add("$..appId");
JsonPathSanitizers.Add("$..userId");
BodyRegexSanitizers.Add(new BodyRegexSanitizer(DateTimeStampRegEx, SanitizeValue));
UriRegexSanitizers.Add(new UriRegexSanitizer(URIIdentityReplacerRegEx, "/identities/Sanitized"));
UriRegexSanitizers.Add(new UriRegexSanitizer(URIDomainNameReplacerRegEx, "https://sanitized.communication.azure.com"));
UriRegexSanitizers.Add(new UriRegexSanitizer(URIRoomsIdReplacerRegEx, "/rooms/Sanitized"));
BodyRegexSanitizers.Add(new BodyRegexSanitizer(DateTimeStampRegEx));
UriRegexSanitizers.Add(new UriRegexSanitizer(URIIdentityReplacerRegEx) { Value = "/identities/Sanitized" });
UriRegexSanitizers.Add(new UriRegexSanitizer(URIDomainNameReplacerRegEx) { Value = "https://sanitized.communication.azure.com" });
UriRegexSanitizers.Add(new UriRegexSanitizer(URIRoomsIdReplacerRegEx) { Value = "/rooms/Sanitized" });
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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=(?<group>.*?)(?=&|$)", SanitizeValue)
BodyRegexSanitizers.Add(new BodyRegexSanitizer(@"access_token=(?<group>.*?)(?=&|$)")
{
GroupForReplace = "group"
});

BodyRegexSanitizers.Add(new BodyRegexSanitizer(@"refresh_token=(?<group>.*?)(?=&|$)", SanitizeValue)
BodyRegexSanitizers.Add(new BodyRegexSanitizer(@"refresh_token=(?<group>.*?)(?=&|$)")
{
GroupForReplace = "group"
});
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f2d11b2

Please sign in to comment.