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

Ignore api-version for mgmt tests #37582

Merged
merged 1 commit into from
Jul 17, 2023
Merged
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 @@ -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)
live1206 marked this conversation as resolved.
Show resolved Hide resolved
: 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