Skip to content

Commit

Permalink
Ignore api-version for mgmt tests (#37582)
Browse files Browse the repository at this point in the history
  • Loading branch information
live1206 authored Jul 17, 2023
1 parent 44ed0dc commit 8b19208
Showing 1 changed file with 4 additions and 80 deletions.
84 changes: 4 additions & 80 deletions common/ManagementTestShared/Redesign/ManagementRecordedTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,19 @@ public abstract class ManagementRecordedTestBase<TEnvironment> : RecordedTestBas
private ResourceType _resourceType;
protected string ApiVersion { get; }

protected ManagementRecordedTestBase(bool isAsync, RecordedTestMode? mode = default, bool ignoreArmCoreDependencyVersions = true)
protected ManagementRecordedTestBase(bool isAsync, RecordedTestMode? mode = default)
: base(isAsync, mode)
{
AdditionalInterceptors = new[] { new ManagementInterceptor(this) };

SessionEnvironment = new TEnvironment();
SessionEnvironment.Mode = Mode;
Initialize();
if (ignoreArmCoreDependencyVersions)
{
IgnoreArmCoreDependencyVersions();
}
IgnoredQueryParameters.Add("api-version");
}

protected ManagementRecordedTestBase(bool isAsync, ResourceType resourceType, string apiVersion, RecordedTestMode? mode = default, bool ignoreArmCoreDependencyVersions = true)
: this(isAsync, mode, ignoreArmCoreDependencyVersions)
protected ManagementRecordedTestBase(bool isAsync, ResourceType resourceType, string apiVersion, RecordedTestMode? mode = default)
: this(isAsync, mode)
{
_resourceType = resourceType;
ApiVersion = apiVersion;
Expand All @@ -71,79 +68,6 @@ private void Initialize()
_waitForCleanup = Mode == RecordedTestMode.Live ? WaitUntil.Completed : WaitUntil.Started;
}

private void IgnoreArmCoreDependencyVersions()
{
// Ignore the api-version of tenant operations
UriRegexSanitizers.Add(new UriRegexSanitizer(
@"/tenants\?api-version=(?<group>[a-z0-9-]+)", "**"
)
{
GroupForReplace = "group"
});
// Ignore the api-version of subscription operations
UriRegexSanitizers.Add(new UriRegexSanitizer(
@"/subscriptions/[^/]+api-version=(?<group>[a-z0-9-]+)", "**"
)
{
GroupForReplace = "group"
});
UriRegexSanitizers.Add(new UriRegexSanitizer(
@"/subscriptions/([^/]+)/locations\?api-version=(?<group>[a-z0-9-]+)", "**"
)
{
GroupForReplace = "group"
});
// Ignore the api-version of resource group operations
UriRegexSanitizers.Add(new UriRegexSanitizer(
@"/resourcegroups/[^/]+api-version=(?<group>[a-z0-9-]+)", "**"
)
{
GroupForReplace = "group"
});
// Ignore the api-version of LRO query status operation for resource group deletion
UriRegexSanitizers.Add(new UriRegexSanitizer(
@"/subscriptions/[^/]+/operationresults/[^/]+api-version=(?<group>[a-z0-9-]+)", "**"
)
{
GroupForReplace = "group"
});
// Ignore the api-version of TagResource operations
UriRegexSanitizers.Add(new UriRegexSanitizer(
@"/providers/Microsoft.Resources/tags/default\?api-version=(?<group>[a-z0-9-]+)", "**"
)
{
GroupForReplace = "group"
});
// Ignore the api-version of the operation to query resource providers
UriRegexSanitizers.Add(new UriRegexSanitizer(
@"/providers/([^/]+)api-version=(?<group>[a-z0-9-]+)", "**"
)
{
GroupForReplace = "group"
});
// Ignore the api-version of PolicyAssignments operations
UriRegexSanitizers.Add(new UriRegexSanitizer(
@"/providers\/Microsoft.Authorization\/policyAssignments(.*?)\?api-version=(?<group>[a-z0-9-]+)", "**"
)
{
GroupForReplace = "group"
});
// Ignore the api-version of PolicyDefinitions operations
UriRegexSanitizers.Add(new UriRegexSanitizer(
@"/providers\/Microsoft.Authorization\/policyDefinitions(.*?)\?api-version=(?<group>[a-z0-9-]+)", "**"
)
{
GroupForReplace = "group"
});
// Ignore the api-version of PolicySetDefinitions operations
UriRegexSanitizers.Add(new UriRegexSanitizer(
@"/providers\/Microsoft.Authorization\/policySetDefinitions(.*?)\?api-version=(?<group>[a-z0-9-]+)", "**"
)
{
GroupForReplace = "group"
});
}

protected void IgnoreNetworkDependencyVersions()
{
// Ignore the api-version of Network operations
Expand Down

0 comments on commit 8b19208

Please sign in to comment.