Skip to content
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)
Comment thread
live1206 marked this conversation as 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