From 2506ae4a113db6fb7bcbb2b8e1d140bd35a29dcd Mon Sep 17 00:00:00 2001 From: Ziyue Zheng Date: Tue, 17 May 2022 11:18:34 +0800 Subject: [PATCH 1/2] Add SecurityTestRunner to replace TestController --- .../AlertsSuppressionRuleTests.cs | 15 +-- .../ScenarioTests/AllowedConnectionTests.cs | 20 +-- .../DeviceSecurityGroupsTests.cs | 19 +-- .../IotSecuritySolutionAnalyticsTests.cs | 19 +-- .../IotSecuritySolutionsTests.cs | 35 ++--- ...SecurityAdaptiveApplicationControlTests.cs | 18 +-- .../SecurityAdaptiveNetworkHardeningTests.cs | 18 +-- .../SecurityAdvancedThreatProtectionTests.cs | 14 +- .../ScenarioTests/SecurityAlertTests.cs | 27 ++-- .../SecurityAssessmentMetadataTests.cs | 15 +-- .../ScenarioTests/SecurityAssessmentTests.cs | 15 +-- .../SecurityAutoProvisioningSettingTests.cs | 21 +-- .../ScenarioTests/SecurityAutomationTests.cs | 46 +++---- .../ScenarioTests/SecurityComplianceTests.cs | 17 +-- .../ScenarioTests/SecurityContactTests.cs | 23 ++-- ...SecurityDiscoveredSecuritySolutionTests.cs | 17 +-- .../SecurityExternalSecuritySolutionTests.cs | 17 +-- .../SecurityJitNetworkAccessPolicyTests.cs | 27 ++-- .../ScenarioTests/SecurityLocationTests.cs | 17 +-- .../ScenarioTests/SecurityPricingTests.cs | 19 +-- .../SecurityRegulatoryComplinceTests.cs | 30 ++--- ...curitySecureScoreControlDefinitionTests.cs | 13 +- .../SecuritySecureScoreControlTests.cs | 16 +-- .../ScenarioTests/SecuritySecureScoreTests.cs | 19 +-- .../ScenarioTests/SecuritySettingTests.cs | 17 +-- .../ScenarioTests/SecuritySolutionTests .cs | 13 +- .../SecuritySolutionsReferenceDataTests.cs | 13 +- .../SecuritySubAssessmentTests.cs | 15 +-- .../ScenarioTests/SecurityTaskTests.cs | 21 +-- .../ScenarioTests/SecurityTestRunner.cs | 51 ++++++++ .../ScenarioTests/SecurityTopologyTests.cs | 20 +-- .../SecurityWorkspaceSettingTests.cs | 21 +-- .../SqlInformationProtectionPolicyTests.cs | 29 ++--- .../SqlVulnerabilityAssessmentTests.cs | 13 +- .../ScenarioTests/TestController.cs | 122 ------------------ .../help/Get-AzRegulatoryComplianceControl.md | 4 +- ...itySqlVulnerabilityAssessmentScanResult.md | 38 +++--- 37 files changed, 280 insertions(+), 594 deletions(-) create mode 100644 src/Security/Security.Test/ScenarioTests/SecurityTestRunner.cs delete mode 100644 src/Security/Security.Test/ScenarioTests/TestController.cs diff --git a/src/Security/Security.Test/ScenarioTests/AlertsSuppressionRuleTests.cs b/src/Security/Security.Test/ScenarioTests/AlertsSuppressionRuleTests.cs index 520ea40ecbc6..1568d26b0fb0 100644 --- a/src/Security/Security.Test/ScenarioTests/AlertsSuppressionRuleTests.cs +++ b/src/Security/Security.Test/ScenarioTests/AlertsSuppressionRuleTests.cs @@ -12,36 +12,29 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using Microsoft.Azure.Commands.ScenarioTest; -using Microsoft.Azure.ServiceManagement.Common.Models; using Microsoft.WindowsAzure.Commands.ScenarioTest; using Xunit; namespace Microsoft.Azure.Commands.Security.Test.ScenarioTests { - public class AlertsSuppressionRuleTests + public class AlertsSuppressionRuleTests : SecurityTestRunner { - private readonly XunitTracingInterceptor _logger; - - public AlertsSuppressionRuleTests(Xunit.Abstractions.ITestOutputHelper output) + public AlertsSuppressionRuleTests(Xunit.Abstractions.ITestOutputHelper output) : base(output) { - _logger = new XunitTracingInterceptor(output); - XunitTracingInterceptor.AddToContext(_logger); - TestExecutionHelpers.SetUpSessionAndProfile(); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetSubscriptionScope() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzAlertsSuppressionRule-SubscriptionScope"); + TestRunner.RunTestScript("Get-AzAlertsSuppressionRule-SubscriptionScope"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void CreateAndDeleteAlertsSuppressionRule() { - TestController.NewInstance.RunPowerShellTest(_logger, "CreateAndDelete-AzAlertsSuppressionRule"); + TestRunner.RunTestScript("CreateAndDelete-AzAlertsSuppressionRule"); } } } \ No newline at end of file diff --git a/src/Security/Security.Test/ScenarioTests/AllowedConnectionTests.cs b/src/Security/Security.Test/ScenarioTests/AllowedConnectionTests.cs index 663102f2bb3a..7ca24d378d20 100644 --- a/src/Security/Security.Test/ScenarioTests/AllowedConnectionTests.cs +++ b/src/Security/Security.Test/ScenarioTests/AllowedConnectionTests.cs @@ -1,41 +1,33 @@ -using Microsoft.Azure.Commands.ScenarioTest; -using Microsoft.Azure.ServiceManagement.Common.Models; -using Microsoft.WindowsAzure.Commands.ScenarioTest; +using Microsoft.WindowsAzure.Commands.ScenarioTest; using Xunit; namespace Microsoft.Azure.Commands.Security.Test.ScenarioTests { - public class AllowedConnectionTests + public class AllowedConnectionTests : SecurityTestRunner { - private readonly XunitTracingInterceptor _logger; - - public AllowedConnectionTests (Xunit.Abstractions.ITestOutputHelper output) + public AllowedConnectionTests (Xunit.Abstractions.ITestOutputHelper output) : base(output) { - _logger = new XunitTracingInterceptor(output); - XunitTracingInterceptor.AddToContext(_logger); - TestExecutionHelpers.SetUpSessionAndProfile(); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetSubscriptionScope() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmAllowedConnection-SubscriptionScope"); + TestRunner.RunTestScript("Get-AzureRmAllowedConnection-SubscriptionScope"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetResourceGroupLevelResource() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmAllowedConnection-ResourceGroupLevelResource"); + TestRunner.RunTestScript("Get-AzureRmAllowedConnection-ResourceGroupLevelResource"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetResourceId() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmAllowedConnection-ResourceId"); + TestRunner.RunTestScript("Get-AzureRmAllowedConnection-ResourceId"); } } } - diff --git a/src/Security/Security.Test/ScenarioTests/DeviceSecurityGroupsTests.cs b/src/Security/Security.Test/ScenarioTests/DeviceSecurityGroupsTests.cs index 925d5c5c8513..335b64169acb 100644 --- a/src/Security/Security.Test/ScenarioTests/DeviceSecurityGroupsTests.cs +++ b/src/Security/Security.Test/ScenarioTests/DeviceSecurityGroupsTests.cs @@ -12,50 +12,43 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using Microsoft.Azure.Commands.ScenarioTest; -using Microsoft.Azure.ServiceManagement.Common.Models; using Microsoft.WindowsAzure.Commands.ScenarioTest; using Xunit; namespace Microsoft.Azure.Commands.Security.Test.ScenarioTests { - public class DeviceSecurityGroupsTests + public class DeviceSecurityGroupsTests : SecurityTestRunner { - private readonly XunitTracingInterceptor _logger; - - public DeviceSecurityGroupsTests(Xunit.Abstractions.ITestOutputHelper output) + public DeviceSecurityGroupsTests(Xunit.Abstractions.ITestOutputHelper output) : base(output) { - _logger = new XunitTracingInterceptor(output); - XunitTracingInterceptor.AddToContext(_logger); - TestExecutionHelpers.SetUpSessionAndProfile(); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetResourceIdScope() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmDeviceSecurityGroup-ResourceIdScope"); + TestRunner.RunTestScript("Get-AzureRmDeviceSecurityGroup-ResourceIdScope"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetResourceIdLevelResource() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmDeviceSecurityGroup-ResourceIdLevelResource"); + TestRunner.RunTestScript("Get-AzureRmDeviceSecurityGroup-ResourceIdLevelResource"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void SetResourceIdLevelResource() { - TestController.NewInstance.RunPowerShellTest(_logger, "Set-AzureRmDeviceSecurityGroup-ResourceIdLevelResource"); + TestRunner.RunTestScript("Set-AzureRmDeviceSecurityGroup-ResourceIdLevelResource"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void RemoveDeviceSecurityGroups() { - TestController.NewInstance.RunPowerShellTest(_logger, "Remove-AzureRmDeviceSecurityGroup-ResourceIdLevelResource"); + TestRunner.RunTestScript("Remove-AzureRmDeviceSecurityGroup-ResourceIdLevelResource"); } } } diff --git a/src/Security/Security.Test/ScenarioTests/IotSecuritySolutionAnalyticsTests.cs b/src/Security/Security.Test/ScenarioTests/IotSecuritySolutionAnalyticsTests.cs index 8fcd896f7097..43c3567ba0dc 100644 --- a/src/Security/Security.Test/ScenarioTests/IotSecuritySolutionAnalyticsTests.cs +++ b/src/Security/Security.Test/ScenarioTests/IotSecuritySolutionAnalyticsTests.cs @@ -12,50 +12,43 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using Microsoft.Azure.Commands.ScenarioTest; -using Microsoft.Azure.ServiceManagement.Common.Models; using Microsoft.WindowsAzure.Commands.ScenarioTest; using Xunit; namespace Microsoft.Azure.Commands.Security.Test.ScenarioTests { - public class IotSecuritySolutionAnalyticsTests + public class IotSecuritySolutionAnalyticsTests : SecurityTestRunner { - private readonly XunitTracingInterceptor _logger; - - public IotSecuritySolutionAnalyticsTests(Xunit.Abstractions.ITestOutputHelper output) + public IotSecuritySolutionAnalyticsTests(Xunit.Abstractions.ITestOutputHelper output) : base(output) { - _logger = new XunitTracingInterceptor(output); - XunitTracingInterceptor.AddToContext(_logger); - TestExecutionHelpers.SetUpSessionAndProfile(); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetSolutionScopeSingle() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmIotSecurityAnalytics-SolutionScope-Single"); + TestRunner.RunTestScript("Get-AzureRmIotSecurityAnalytics-SolutionScope-Single"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetSolutionScopeList() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmIotSecurityAnalytics-SolutionScope-List"); + TestRunner.RunTestScript("Get-AzureRmIotSecurityAnalytics-SolutionScope-List"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetAggregatedAlertSolutionScope() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmIotSecurityAnalyticsAggregatedAlert-SolutionScope"); + TestRunner.RunTestScript("Get-AzureRmIotSecurityAnalyticsAggregatedAlert-SolutionScope"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetAggregatedRecommendationSolutionScope() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmIotSecurityAnalyticsAggregatedRecommendation-SolutionScope"); + TestRunner.RunTestScript("Get-AzureRmIotSecurityAnalyticsAggregatedRecommendation-SolutionScope"); } } } diff --git a/src/Security/Security.Test/ScenarioTests/IotSecuritySolutionsTests.cs b/src/Security/Security.Test/ScenarioTests/IotSecuritySolutionsTests.cs index 7b9bdcf57d7c..27a854dfbe07 100644 --- a/src/Security/Security.Test/ScenarioTests/IotSecuritySolutionsTests.cs +++ b/src/Security/Security.Test/ScenarioTests/IotSecuritySolutionsTests.cs @@ -12,106 +12,99 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using Microsoft.Azure.Commands.ScenarioTest; -using Microsoft.Azure.ServiceManagement.Common.Models; using Microsoft.WindowsAzure.Commands.ScenarioTest; using Xunit; namespace Microsoft.Azure.Commands.Security.Test.ScenarioTests { - public class IotSecuritySolutionsTests + public class IotSecuritySolutionsTests : SecurityTestRunner { - private readonly XunitTracingInterceptor _logger; - - public IotSecuritySolutionsTests(Xunit.Abstractions.ITestOutputHelper output) + public IotSecuritySolutionsTests(Xunit.Abstractions.ITestOutputHelper output) : base(output) { - _logger = new XunitTracingInterceptor(output); - XunitTracingInterceptor.AddToContext(_logger); - TestExecutionHelpers.SetUpSessionAndProfile(); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetSubscriptionScope() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmIotSecuritySolution-SubscriptionScope"); + TestRunner.RunTestScript("Get-AzureRmIotSecuritySolution-SubscriptionScope"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetResourceGroupScope() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmIotSecuritySolution-ResourceGroupScope"); + TestRunner.RunTestScript("Get-AzureRmIotSecuritySolution-ResourceGroupScope"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetResourceGroupLevelResource() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmIotSecuritySolution-ResourceGroupLevelResource"); + TestRunner.RunTestScript("Get-AzureRmIotSecuritySolution-ResourceGroupLevelResource"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetResourceId() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmIotSecuritySolution-ResourceId"); + TestRunner.RunTestScript("Get-AzureRmIotSecuritySolution-ResourceId"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void SetResourceGroupLevelResource() { - TestController.NewInstance.RunPowerShellTest(_logger, "Set-AzureRmIotSecuritySolution-ResourceGroupLevelResource"); + TestRunner.RunTestScript("Set-AzureRmIotSecuritySolution-ResourceGroupLevelResource"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void SetResourceId() { - TestController.NewInstance.RunPowerShellTest(_logger, "Set-AzureRmIotSecuritySolution-ResourceId"); + TestRunner.RunTestScript("Set-AzureRmIotSecuritySolution-ResourceId"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void SetInputObject() { - TestController.NewInstance.RunPowerShellTest(_logger, "Set-AzureRmIotSecuritySolution-InputObject"); + TestRunner.RunTestScript("Set-AzureRmIotSecuritySolution-InputObject"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void RemoveResourceGroupLevelResource() { - TestController.NewInstance.RunPowerShellTest(_logger, "Remove-AzureRmIotSecuritySolution-ResourceGroupLevelResource"); + TestRunner.RunTestScript("Remove-AzureRmIotSecuritySolution-ResourceGroupLevelResource"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void RemoveResourceId() { - TestController.NewInstance.RunPowerShellTest(_logger, "Remove-AzureRmIotSecuritySolution-ResourceId"); + TestRunner.RunTestScript("Remove-AzureRmIotSecuritySolution-ResourceId"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void UpdateResourceGroupLevelResource() { - TestController.NewInstance.RunPowerShellTest(_logger, "Update-AzureRmIotSecuritySolution-ResourceGroupLevelResource"); + TestRunner.RunTestScript("Update-AzureRmIotSecuritySolution-ResourceGroupLevelResource"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void UpdateResourceId() { - TestController.NewInstance.RunPowerShellTest(_logger, "Update-AzureRmIotSecuritySolution-ResourceId"); + TestRunner.RunTestScript("Update-AzureRmIotSecuritySolution-ResourceId"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void UpdateInputObject() { - TestController.NewInstance.RunPowerShellTest(_logger, "Update-AzureRmIotSecuritySolution-InputObject"); + TestRunner.RunTestScript("Update-AzureRmIotSecuritySolution-InputObject"); } } } diff --git a/src/Security/Security.Test/ScenarioTests/SecurityAdaptiveApplicationControlTests.cs b/src/Security/Security.Test/ScenarioTests/SecurityAdaptiveApplicationControlTests.cs index 390a0f1b4d2a..72f6bc95ad7c 100644 --- a/src/Security/Security.Test/ScenarioTests/SecurityAdaptiveApplicationControlTests.cs +++ b/src/Security/Security.Test/ScenarioTests/SecurityAdaptiveApplicationControlTests.cs @@ -1,34 +1,26 @@ -using Microsoft.Azure.Commands.ScenarioTest; -using Microsoft.Azure.ServiceManagement.Common.Models; -using Microsoft.WindowsAzure.Commands.ScenarioTest; +using Microsoft.WindowsAzure.Commands.ScenarioTest; using Xunit; namespace Microsoft.Azure.Commands.Security.Test.ScenarioTests { - public class SecurityAdaptiveApplicationControlTests + public class SecurityAdaptiveApplicationControlTests : SecurityTestRunner { - private readonly XunitTracingInterceptor _logger; - - public SecurityAdaptiveApplicationControlTests(Xunit.Abstractions.ITestOutputHelper output) + public SecurityAdaptiveApplicationControlTests(Xunit.Abstractions.ITestOutputHelper output) : base(output) { - _logger = new XunitTracingInterceptor(output); - XunitTracingInterceptor.AddToContext(_logger); - TestExecutionHelpers.SetUpSessionAndProfile(); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetAdaptiveApplicationControlGroup() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzSecurityAdaptiveApplicationControlGroup-ResourceGroupScope"); + TestRunner.RunTestScript("Get-AzSecurityAdaptiveApplicationControlGroup-ResourceGroupScope"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetAdaptiveApplicationControlList() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzSecurityAdaptiveApplicationControl-SubscriptionScope"); + TestRunner.RunTestScript("Get-AzSecurityAdaptiveApplicationControl-SubscriptionScope"); } } } - diff --git a/src/Security/Security.Test/ScenarioTests/SecurityAdaptiveNetworkHardeningTests.cs b/src/Security/Security.Test/ScenarioTests/SecurityAdaptiveNetworkHardeningTests.cs index 729da1102bdb..9937cabfbb19 100644 --- a/src/Security/Security.Test/ScenarioTests/SecurityAdaptiveNetworkHardeningTests.cs +++ b/src/Security/Security.Test/ScenarioTests/SecurityAdaptiveNetworkHardeningTests.cs @@ -1,34 +1,26 @@ -using Microsoft.Azure.Commands.ScenarioTest; -using Microsoft.Azure.ServiceManagement.Common.Models; -using Microsoft.WindowsAzure.Commands.ScenarioTest; +using Microsoft.WindowsAzure.Commands.ScenarioTest; using Xunit; namespace Microsoft.Azure.Commands.Security.Test.ScenarioTests { - public class SecurityAdaptiveNetworkHardeningTests + public class SecurityAdaptiveNetworkHardeningTests : SecurityTestRunner { - private readonly XunitTracingInterceptor _logger; - - public SecurityAdaptiveNetworkHardeningTests(Xunit.Abstractions.ITestOutputHelper output) + public SecurityAdaptiveNetworkHardeningTests(Xunit.Abstractions.ITestOutputHelper output) : base(output) { - _logger = new XunitTracingInterceptor(output); - XunitTracingInterceptor.AddToContext(_logger); - TestExecutionHelpers.SetUpSessionAndProfile(); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void ListByExtendedResource() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzSecurityAdaptiveNetworkHardening-ResourceGroupLevelResource"); + TestRunner.RunTestScript("Get-AzSecurityAdaptiveNetworkHardening-ResourceGroupLevelResource"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetSingleAdaptiveNetworkHardeningResource() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzSecurityAdaptiveNetworkHardening-ResourceGroupLevelResource"); + TestRunner.RunTestScript("Get-AzSecurityAdaptiveNetworkHardening-ResourceGroupLevelResource"); } } } - diff --git a/src/Security/Security.Test/ScenarioTests/SecurityAdvancedThreatProtectionTests.cs b/src/Security/Security.Test/ScenarioTests/SecurityAdvancedThreatProtectionTests.cs index 8ee612663719..a46b7d7a7297 100644 --- a/src/Security/Security.Test/ScenarioTests/SecurityAdvancedThreatProtectionTests.cs +++ b/src/Security/Security.Test/ScenarioTests/SecurityAdvancedThreatProtectionTests.cs @@ -12,30 +12,22 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using Microsoft.Azure.Commands.ScenarioTest; -using Microsoft.Azure.ServiceManagement.Common.Models; using Microsoft.WindowsAzure.Commands.ScenarioTest; using Xunit; namespace Microsoft.Azure.Commands.Security.Test.ScenarioTests { - public class SecurityAdvancedThreatProtectionTests + public class SecurityAdvancedThreatProtectionTests : SecurityTestRunner { - private readonly XunitTracingInterceptor _logger; - - public SecurityAdvancedThreatProtectionTests(Xunit.Abstractions.ITestOutputHelper output) + public SecurityAdvancedThreatProtectionTests(Xunit.Abstractions.ITestOutputHelper output) : base(output) { - _logger = new XunitTracingInterceptor(output); - XunitTracingInterceptor.AddToContext(_logger); - TestExecutionHelpers.SetUpSessionAndProfile(); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void TestResourceId() { - TestController.NewInstance.RunPowerShellTest(_logger, "Test-AzSecurityAdvancedThreatProtection-ResourceId"); + TestRunner.RunTestScript("Test-AzSecurityAdvancedThreatProtection-ResourceId"); } - } } diff --git a/src/Security/Security.Test/ScenarioTests/SecurityAlertTests.cs b/src/Security/Security.Test/ScenarioTests/SecurityAlertTests.cs index b0b34ea4ec93..50fd6f659ca0 100644 --- a/src/Security/Security.Test/ScenarioTests/SecurityAlertTests.cs +++ b/src/Security/Security.Test/ScenarioTests/SecurityAlertTests.cs @@ -12,78 +12,71 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using Microsoft.Azure.Commands.ScenarioTest; -using Microsoft.Azure.ServiceManagement.Common.Models; using Microsoft.WindowsAzure.Commands.ScenarioTest; using Xunit; namespace Microsoft.Azure.Commands.Security.Test.ScenarioTests { - public class SecurityAlertTests + public class SecurityAlertTests : SecurityTestRunner { - private readonly XunitTracingInterceptor _logger; - - public SecurityAlertTests(Xunit.Abstractions.ITestOutputHelper output) + public SecurityAlertTests(Xunit.Abstractions.ITestOutputHelper output) : base(output) { - _logger = new XunitTracingInterceptor(output); - XunitTracingInterceptor.AddToContext(_logger); - TestExecutionHelpers.SetUpSessionAndProfile(); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetSubscriptionScope() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmSecurityAlert-SubscriptionScope"); + TestRunner.RunTestScript("Get-AzureRmSecurityAlert-SubscriptionScope"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetResourceGroupScope() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmSecurityAlert-ResourceGroupScope"); + TestRunner.RunTestScript("Get-AzureRmSecurityAlert-ResourceGroupScope"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetResourceGroupLevelResource() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmSecurityAlert-ResourceGroupLevelResource"); + TestRunner.RunTestScript("Get-AzureRmSecurityAlert-ResourceGroupLevelResource"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetSubscriptionLevelResource() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmSecurityAlert-SubscriptionLevelResource"); + TestRunner.RunTestScript("Get-AzureRmSecurityAlert-SubscriptionLevelResource"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetResourceId() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmSecurityAlert-ResourceId"); + TestRunner.RunTestScript("Get-AzureRmSecurityAlert-ResourceId"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void SetResourceGroupLevelResource() { - TestController.NewInstance.RunPowerShellTest(_logger, "Set-AzureRmSecurityAlert-ResourceGroupLevelResource"); + TestRunner.RunTestScript("Set-AzureRmSecurityAlert-ResourceGroupLevelResource"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void SetSubscriptionLevelResource() { - TestController.NewInstance.RunPowerShellTest(_logger, "Set-AzureRmSecurityAlert-SubscriptionLevelResource"); + TestRunner.RunTestScript("Set-AzureRmSecurityAlert-SubscriptionLevelResource"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void SetResourceId() { - TestController.NewInstance.RunPowerShellTest(_logger, "Set-AzureRmSecurityAlert-ResourceId"); + TestRunner.RunTestScript("Set-AzureRmSecurityAlert-ResourceId"); } } } diff --git a/src/Security/Security.Test/ScenarioTests/SecurityAssessmentMetadataTests.cs b/src/Security/Security.Test/ScenarioTests/SecurityAssessmentMetadataTests.cs index c4f2cb2dec33..100b386f3df2 100644 --- a/src/Security/Security.Test/ScenarioTests/SecurityAssessmentMetadataTests.cs +++ b/src/Security/Security.Test/ScenarioTests/SecurityAssessmentMetadataTests.cs @@ -12,36 +12,29 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using Microsoft.Azure.Commands.ScenarioTest; -using Microsoft.Azure.ServiceManagement.Common.Models; using Microsoft.WindowsAzure.Commands.ScenarioTest; using Xunit; namespace Microsoft.Azure.Commands.Security.Test.ScenarioTests { - public class SecurityAssessmentMetadataTests + public class SecurityAssessmentMetadataTests : SecurityTestRunner { - private readonly XunitTracingInterceptor _logger; - - public SecurityAssessmentMetadataTests(Xunit.Abstractions.ITestOutputHelper output) + public SecurityAssessmentMetadataTests(Xunit.Abstractions.ITestOutputHelper output) : base(output) { - _logger = new XunitTracingInterceptor(output); - XunitTracingInterceptor.AddToContext(_logger); - TestExecutionHelpers.SetUpSessionAndProfile(); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetAllAssessmentMetadata() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AllSecurityAssessmentMetadata"); + TestRunner.RunTestScript("Get-AllSecurityAssessmentMetadata"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void CreateAndDeleteAssessmentMetadata() { - TestController.NewInstance.RunPowerShellTest(_logger, "CreateAndDelete-AzSecurityAssessmentMetadata"); + TestRunner.RunTestScript("CreateAndDelete-AzSecurityAssessmentMetadata"); } } } diff --git a/src/Security/Security.Test/ScenarioTests/SecurityAssessmentTests.cs b/src/Security/Security.Test/ScenarioTests/SecurityAssessmentTests.cs index 69c0c83ddee8..4575c887157a 100644 --- a/src/Security/Security.Test/ScenarioTests/SecurityAssessmentTests.cs +++ b/src/Security/Security.Test/ScenarioTests/SecurityAssessmentTests.cs @@ -12,36 +12,29 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using Microsoft.Azure.Commands.ScenarioTest; -using Microsoft.Azure.ServiceManagement.Common.Models; using Microsoft.WindowsAzure.Commands.ScenarioTest; using Xunit; namespace Microsoft.Azure.Commands.Security.Test.ScenarioTests { - public class SecurityAssessmentTests + public class SecurityAssessmentTests : SecurityTestRunner { - private readonly XunitTracingInterceptor _logger; - - public SecurityAssessmentTests(Xunit.Abstractions.ITestOutputHelper output) + public SecurityAssessmentTests(Xunit.Abstractions.ITestOutputHelper output) : base(output) { - _logger = new XunitTracingInterceptor(output); - XunitTracingInterceptor.AddToContext(_logger); - TestExecutionHelpers.SetUpSessionAndProfile(); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetAllAssessments() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AllSecurityAssessments"); + TestRunner.RunTestScript("Get-AllSecurityAssessments"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void CreateAndDeleteAssessment() { - TestController.NewInstance.RunPowerShellTest(_logger, "CreateAndDelete-AzSecurityAssessment"); + TestRunner.RunTestScript("CreateAndDelete-AzSecurityAssessment"); } } } diff --git a/src/Security/Security.Test/ScenarioTests/SecurityAutoProvisioningSettingTests.cs b/src/Security/Security.Test/ScenarioTests/SecurityAutoProvisioningSettingTests.cs index d159431f16d9..4b4ef817a6a9 100644 --- a/src/Security/Security.Test/ScenarioTests/SecurityAutoProvisioningSettingTests.cs +++ b/src/Security/Security.Test/ScenarioTests/SecurityAutoProvisioningSettingTests.cs @@ -12,57 +12,50 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using Microsoft.Azure.Commands.ScenarioTest; -using Microsoft.Azure.ServiceManagement.Common.Models; using Microsoft.WindowsAzure.Commands.ScenarioTest; using Xunit; namespace Microsoft.Azure.Commands.Security.Test.ScenarioTests { - public class SecurityAutoProvisioningSettingTests + public class SecurityAutoProvisioningSettingTests : SecurityTestRunner { - private readonly XunitTracingInterceptor _logger; - - public SecurityAutoProvisioningSettingTests(Xunit.Abstractions.ITestOutputHelper output) + public SecurityAutoProvisioningSettingTests(Xunit.Abstractions.ITestOutputHelper output) : base(output) { - _logger = new XunitTracingInterceptor(output); - XunitTracingInterceptor.AddToContext(_logger); - TestExecutionHelpers.SetUpSessionAndProfile(); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetSubscriptionScope() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmSecurityAutoProvisioningSetting-SubscriptionScope"); + TestRunner.RunTestScript("Get-AzureRmSecurityAutoProvisioningSetting-SubscriptionScope"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetResourceGroupScope() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmSecurityAutoProvisioningSetting-SubscriptionLevelResource"); + TestRunner.RunTestScript("Get-AzureRmSecurityAutoProvisioningSetting-SubscriptionLevelResource"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetResourceId() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmSecurityAutoProvisioningSetting-ResourceId"); + TestRunner.RunTestScript("Get-AzureRmSecurityAutoProvisioningSetting-ResourceId"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void SetSubscriptionLevelResource() { - TestController.NewInstance.RunPowerShellTest(_logger, "Set-AzureRmSecurityAutoProvisioningSetting-SubscriptionLevelResource"); + TestRunner.RunTestScript("Set-AzureRmSecurityAutoProvisioningSetting-SubscriptionLevelResource"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void SetResourceId() { - TestController.NewInstance.RunPowerShellTest(_logger, "Set-AzureRmSecurityAutoProvisioningSetting-ResourceId"); + TestRunner.RunTestScript("Set-AzureRmSecurityAutoProvisioningSetting-ResourceId"); } } } diff --git a/src/Security/Security.Test/ScenarioTests/SecurityAutomationTests.cs b/src/Security/Security.Test/ScenarioTests/SecurityAutomationTests.cs index 415810cbb3e3..58dce816438d 100644 --- a/src/Security/Security.Test/ScenarioTests/SecurityAutomationTests.cs +++ b/src/Security/Security.Test/ScenarioTests/SecurityAutomationTests.cs @@ -12,142 +12,134 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using Microsoft.Azure.Commands.ScenarioTest; -using Microsoft.Azure.ServiceManagement.Common.Models; using Microsoft.WindowsAzure.Commands.ScenarioTest; using Xunit; namespace Microsoft.Azure.Commands.Security.Test.ScenarioTests { - public class SecurityAutomationTests + public class SecurityAutomationTests : SecurityTestRunner { - private readonly XunitTracingInterceptor _logger; - - public SecurityAutomationTests(Xunit.Abstractions.ITestOutputHelper output) + public SecurityAutomationTests(Xunit.Abstractions.ITestOutputHelper output) : base(output) { - _logger = new XunitTracingInterceptor(output); - XunitTracingInterceptor.AddToContext(_logger); - TestExecutionHelpers.SetUpSessionAndProfile(); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetSecurityAutomationSubscriptionScope() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzSecurityAutomation-SubscriptionScope"); + TestRunner.RunTestScript("Get-AzSecurityAutomation-SubscriptionScope"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetSecurityAutomationResourceScope() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzSecurityAutomation-ResourceGroupScope"); + TestRunner.RunTestScript("Get-AzSecurityAutomation-ResourceGroupScope"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetSecurityAutomationResourceGroupLevelResource() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzSecurityAutomation-ResourceGroupLevelResource"); + TestRunner.RunTestScript("Get-AzSecurityAutomation-ResourceGroupLevelResource"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetSecurityAutomationResourceId() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzSecurityAutomation-ResourceId"); + TestRunner.RunTestScript("Get-AzSecurityAutomation-ResourceId"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void NewSecurityAutomationResourceGroupLevelResource() { - TestController.NewInstance.RunPowerShellTest(_logger, "New-AzSecurityAutomation-ResourceGroupLevelResource"); + TestRunner.RunTestScript("New-AzSecurityAutomation-ResourceGroupLevelResource"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void SetSecurityAutomationResourceGroupLevelResource() { - TestController.NewInstance.RunPowerShellTest(_logger, "Set-AzSecurityAutomation-ResourceGroupLevelResource"); + TestRunner.RunTestScript("Set-AzSecurityAutomation-ResourceGroupLevelResource"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void SetSecurityAutomationResourceId() { - TestController.NewInstance.RunPowerShellTest(_logger, "Set-AzSecurityAutomation-ResourceId"); + TestRunner.RunTestScript("Set-AzSecurityAutomation-ResourceId"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void SetSecurityAutomationInputObject() { - TestController.NewInstance.RunPowerShellTest(_logger, "Set-AzSecurityAutomation-InputObject"); + TestRunner.RunTestScript("Set-AzSecurityAutomation-InputObject"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void ConfirmSecurityAutomationResourceGroupLevelResource() { - TestController.NewInstance.RunPowerShellTest(_logger, "Confirm-AzSecurityAutomation-ResourceGroupLevelResource"); + TestRunner.RunTestScript("Confirm-AzSecurityAutomation-ResourceGroupLevelResource"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void ConfirmSecurityAutomationResourceId() { - TestController.NewInstance.RunPowerShellTest(_logger, "Confirm-AzSecurityAutomation-ResourceId"); + TestRunner.RunTestScript("Confirm-AzSecurityAutomation-ResourceId"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void ConfirmSecurityAutomationInputObject() { - TestController.NewInstance.RunPowerShellTest(_logger, "Confirm-AzSecurityAutomation-InputObject"); + TestRunner.RunTestScript("Confirm-AzSecurityAutomation-InputObject"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void RemoveSecurityAutomationResourceGroupLevelResource() { - TestController.NewInstance.RunPowerShellTest(_logger, "Remove-AzSecurityAutomation-ResourceGroupLevelResource"); + TestRunner.RunTestScript("Remove-AzSecurityAutomation-ResourceGroupLevelResource"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void RemoveSecurityAutomationResourceId() { - TestController.NewInstance.RunPowerShellTest(_logger, "Remove-AzSecurityAutomation-ResourceId"); + TestRunner.RunTestScript("Remove-AzSecurityAutomation-ResourceId"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void RemoveSecurityAutomationInputObject() { - TestController.NewInstance.RunPowerShellTest(_logger, "Remove-AzSecurityAutomation-InputObject"); + TestRunner.RunTestScript("Remove-AzSecurityAutomation-InputObject"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void NewSecurityAutomationScopeObject() { - TestController.NewInstance.RunPowerShellTest(_logger, "New-AzSecurityAutomationScopeObject-Test"); + TestRunner.RunTestScript("New-AzSecurityAutomationScopeObject-Test"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void NewSecurityAutomationSourceObject() { - TestController.NewInstance.RunPowerShellTest(_logger, "New-AzSecurityAutomationSourceObject-Test"); + TestRunner.RunTestScript("New-AzSecurityAutomationSourceObject-Test"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void NewSecurityAutomationActionObject() { - TestController.NewInstance.RunPowerShellTest(_logger, "New-AzSecurityAutomationActionObject-Test"); + TestRunner.RunTestScript("New-AzSecurityAutomationActionObject-Test"); } - } } diff --git a/src/Security/Security.Test/ScenarioTests/SecurityComplianceTests.cs b/src/Security/Security.Test/ScenarioTests/SecurityComplianceTests.cs index 32d32d6cea80..c4ac70c21682 100644 --- a/src/Security/Security.Test/ScenarioTests/SecurityComplianceTests.cs +++ b/src/Security/Security.Test/ScenarioTests/SecurityComplianceTests.cs @@ -12,43 +12,36 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using Microsoft.Azure.Commands.ScenarioTest; -using Microsoft.Azure.ServiceManagement.Common.Models; using Microsoft.WindowsAzure.Commands.ScenarioTest; using Xunit; namespace Microsoft.Azure.Commands.Security.Test.ScenarioTests { - public class SecurityComplianceTests + public class SecurityComplianceTests : SecurityTestRunner { - private readonly XunitTracingInterceptor _logger; - - public SecurityComplianceTests(Xunit.Abstractions.ITestOutputHelper output) + public SecurityComplianceTests(Xunit.Abstractions.ITestOutputHelper output) : base(output) { - _logger = new XunitTracingInterceptor(output); - XunitTracingInterceptor.AddToContext(_logger); - TestExecutionHelpers.SetUpSessionAndProfile(); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetSubscriptionScope() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmSecurityCompliance-SubscriptionScope"); + TestRunner.RunTestScript("Get-AzureRmSecurityCompliance-SubscriptionScope"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetSubscriptionLevelResource() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmSecurityCompliance-SubscriptionLevelResource"); + TestRunner.RunTestScript("Get-AzureRmSecurityCompliance-SubscriptionLevelResource"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetResourceId() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmSecurityCompliance-ResourceId"); + TestRunner.RunTestScript("Get-AzureRmSecurityCompliance-ResourceId"); } } } diff --git a/src/Security/Security.Test/ScenarioTests/SecurityContactTests.cs b/src/Security/Security.Test/ScenarioTests/SecurityContactTests.cs index c61ed83727d1..d35e1ea2700f 100644 --- a/src/Security/Security.Test/ScenarioTests/SecurityContactTests.cs +++ b/src/Security/Security.Test/ScenarioTests/SecurityContactTests.cs @@ -12,64 +12,57 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using Microsoft.Azure.Commands.ScenarioTest; -using Microsoft.Azure.ServiceManagement.Common.Models; using Microsoft.WindowsAzure.Commands.ScenarioTest; using Xunit; namespace Microsoft.Azure.Commands.Security.Test.ScenarioTests { - public class SecurityContactTests + public class SecurityContactTests : SecurityTestRunner { - private readonly XunitTracingInterceptor _logger; - - public SecurityContactTests(Xunit.Abstractions.ITestOutputHelper output) + public SecurityContactTests(Xunit.Abstractions.ITestOutputHelper output) : base(output) { - _logger = new XunitTracingInterceptor(output); - XunitTracingInterceptor.AddToContext(_logger); - TestExecutionHelpers.SetUpSessionAndProfile(); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetSubscriptionScope() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmSecurityContact-SubscriptionScope"); + TestRunner.RunTestScript("Get-AzureRmSecurityContact-SubscriptionScope"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetSubscriptionLevelResource() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmSecurityContact-SubscriptionLevelResource"); + TestRunner.RunTestScript("Get-AzureRmSecurityContact-SubscriptionLevelResource"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetResourceId() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmSecurityContact-ResourceId"); + TestRunner.RunTestScript("Get-AzureRmSecurityContact-ResourceId"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void SetSubscriptionLevelResource() { - TestController.NewInstance.RunPowerShellTest(_logger, "Set-AzureRmSecurityContact-SubscriptionLevelResource"); + TestRunner.RunTestScript("Set-AzureRmSecurityContact-SubscriptionLevelResource"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void SetSubscriptionLevelResourceSecondary() { - TestController.NewInstance.RunPowerShellTest(_logger, "Set-AzureRmSecurityContact-SubscriptionLevelResource-Secondary"); + TestRunner.RunTestScript("Set-AzureRmSecurityContact-SubscriptionLevelResource-Secondary"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void RemoveSubscriptionLevelResource() { - TestController.NewInstance.RunPowerShellTest(_logger, "Remove-AzureRmSecurityContact-SubscriptionLevelResource"); + TestRunner.RunTestScript("Remove-AzureRmSecurityContact-SubscriptionLevelResource"); } } } diff --git a/src/Security/Security.Test/ScenarioTests/SecurityDiscoveredSecuritySolutionTests.cs b/src/Security/Security.Test/ScenarioTests/SecurityDiscoveredSecuritySolutionTests.cs index a66ae39a2467..b208b3000c3c 100644 --- a/src/Security/Security.Test/ScenarioTests/SecurityDiscoveredSecuritySolutionTests.cs +++ b/src/Security/Security.Test/ScenarioTests/SecurityDiscoveredSecuritySolutionTests.cs @@ -12,43 +12,36 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using Microsoft.Azure.Commands.ScenarioTest; -using Microsoft.Azure.ServiceManagement.Common.Models; using Microsoft.WindowsAzure.Commands.ScenarioTest; using Xunit; namespace Microsoft.Azure.Commands.Security.Test.ScenarioTests { - public class SecurityDiscoveredSecuritySolutionTests + public class SecurityDiscoveredSecuritySolutionTests : SecurityTestRunner { - private readonly XunitTracingInterceptor _logger; - - public SecurityDiscoveredSecuritySolutionTests(Xunit.Abstractions.ITestOutputHelper output) + public SecurityDiscoveredSecuritySolutionTests(Xunit.Abstractions.ITestOutputHelper output) : base(output) { - _logger = new XunitTracingInterceptor(output); - XunitTracingInterceptor.AddToContext(_logger); - TestExecutionHelpers.SetUpSessionAndProfile(); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetSubscriptionScope() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmDiscoveredSecuritySolution-SubscriptionScope"); + TestRunner.RunTestScript("Get-AzureRmDiscoveredSecuritySolution-SubscriptionScope"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetResourceGroupLevelResource() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmDiscoveredSecuritySolution-ResourceGroupLevelResource"); + TestRunner.RunTestScript("Get-AzureRmDiscoveredSecuritySolution-ResourceGroupLevelResource"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetResourceId() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmDiscoveredSecuritySolution-ResourceId"); + TestRunner.RunTestScript("Get-AzureRmDiscoveredSecuritySolution-ResourceId"); } } } diff --git a/src/Security/Security.Test/ScenarioTests/SecurityExternalSecuritySolutionTests.cs b/src/Security/Security.Test/ScenarioTests/SecurityExternalSecuritySolutionTests.cs index c6bc20b51b4e..4f984812bb10 100644 --- a/src/Security/Security.Test/ScenarioTests/SecurityExternalSecuritySolutionTests.cs +++ b/src/Security/Security.Test/ScenarioTests/SecurityExternalSecuritySolutionTests.cs @@ -12,43 +12,36 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using Microsoft.Azure.Commands.ScenarioTest; -using Microsoft.Azure.ServiceManagement.Common.Models; using Microsoft.WindowsAzure.Commands.ScenarioTest; using Xunit; namespace Microsoft.Azure.Commands.Security.Test.ScenarioTests { - public class SecurityExternalSecuritySolutionTests + public class SecurityExternalSecuritySolutionTests : SecurityTestRunner { - private readonly XunitTracingInterceptor _logger; - - public SecurityExternalSecuritySolutionTests(Xunit.Abstractions.ITestOutputHelper output) + public SecurityExternalSecuritySolutionTests(Xunit.Abstractions.ITestOutputHelper output) : base(output) { - _logger = new XunitTracingInterceptor(output); - XunitTracingInterceptor.AddToContext(_logger); - TestExecutionHelpers.SetUpSessionAndProfile(); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetSubscriptionScope() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmExternalSecuritySolution-SubscriptionScope"); + TestRunner.RunTestScript("Get-AzureRmExternalSecuritySolution-SubscriptionScope"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetResourceGroupLevelResource() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmExternalSecuritySolution-ResourceGroupLevelResource"); + TestRunner.RunTestScript("Get-AzureRmExternalSecuritySolution-ResourceGroupLevelResource"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetResourceId() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmExternalSecuritySolution-ResourceId"); + TestRunner.RunTestScript("Get-AzureRmExternalSecuritySolution-ResourceId"); } } } diff --git a/src/Security/Security.Test/ScenarioTests/SecurityJitNetworkAccessPolicyTests.cs b/src/Security/Security.Test/ScenarioTests/SecurityJitNetworkAccessPolicyTests.cs index 95125db8821c..8ace9252dc96 100644 --- a/src/Security/Security.Test/ScenarioTests/SecurityJitNetworkAccessPolicyTests.cs +++ b/src/Security/Security.Test/ScenarioTests/SecurityJitNetworkAccessPolicyTests.cs @@ -12,78 +12,71 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using Microsoft.Azure.Commands.ScenarioTest; -using Microsoft.Azure.ServiceManagement.Common.Models; using Microsoft.WindowsAzure.Commands.ScenarioTest; using Xunit; namespace Microsoft.Azure.Commands.Security.Test.ScenarioTests { - public class SecurityJitNetworkAccessPolicyTests + public class SecurityJitNetworkAccessPolicyTests : SecurityTestRunner { - private readonly XunitTracingInterceptor _logger; - - public SecurityJitNetworkAccessPolicyTests(Xunit.Abstractions.ITestOutputHelper output) + public SecurityJitNetworkAccessPolicyTests(Xunit.Abstractions.ITestOutputHelper output) : base(output) { - _logger = new XunitTracingInterceptor(output); - XunitTracingInterceptor.AddToContext(_logger); - TestExecutionHelpers.SetUpSessionAndProfile(); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetSubscriptionScope() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmJitNetworkAccessPolicy-SubscriptionScope"); + TestRunner.RunTestScript("Get-AzureRmJitNetworkAccessPolicy-SubscriptionScope"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetResourceGroupScope() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmJitNetworkAccessPolicy-ResourceGroupScope"); + TestRunner.RunTestScript("Get-AzureRmJitNetworkAccessPolicy-ResourceGroupScope"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetResourceGroupLevelResource() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmJitNetworkAccessPolicy-ResourceGroupLevelResource"); + TestRunner.RunTestScript("Get-AzureRmJitNetworkAccessPolicy-ResourceGroupLevelResource"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetResourceId() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmJitNetworkAccessPolicy-ResourceId"); + TestRunner.RunTestScript("Get-AzureRmJitNetworkAccessPolicy-ResourceId"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void SetResourceGroupLevelResource() { - TestController.NewInstance.RunPowerShellTest(_logger, "Set-AzureRmJitNetworkAccessPolicy-ResourceGroupLevelResource"); + TestRunner.RunTestScript("Set-AzureRmJitNetworkAccessPolicy-ResourceGroupLevelResource"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void RemoveResourceId() { - TestController.NewInstance.RunPowerShellTest(_logger, "Remove-AzureRmJitNetworkAccessPolicy-ResourceId"); + TestRunner.RunTestScript("Remove-AzureRmJitNetworkAccessPolicy-ResourceId"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void RemoveResourceGroupLevelResource() { - TestController.NewInstance.RunPowerShellTest(_logger, "Remove-AzureRmJitNetworkAccessPolicy-ResourceGroupLevelResource"); + TestRunner.RunTestScript("Remove-AzureRmJitNetworkAccessPolicy-ResourceGroupLevelResource"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void StartResourceGroupLevelResource() { - TestController.NewInstance.RunPowerShellTest(_logger, "Start-AzureRmJitNetworkAccessPolicy-ResourceGroupLevelResource"); + TestRunner.RunTestScript("Start-AzureRmJitNetworkAccessPolicy-ResourceGroupLevelResource"); } } } diff --git a/src/Security/Security.Test/ScenarioTests/SecurityLocationTests.cs b/src/Security/Security.Test/ScenarioTests/SecurityLocationTests.cs index 5ef9d283ec35..a582a74d482f 100644 --- a/src/Security/Security.Test/ScenarioTests/SecurityLocationTests.cs +++ b/src/Security/Security.Test/ScenarioTests/SecurityLocationTests.cs @@ -12,43 +12,36 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using Microsoft.Azure.Commands.ScenarioTest; -using Microsoft.Azure.ServiceManagement.Common.Models; using Microsoft.WindowsAzure.Commands.ScenarioTest; using Xunit; namespace Microsoft.Azure.Commands.Security.Test.ScenarioTests { - public class SecurityLocationTests + public class SecurityLocationTests : SecurityTestRunner { - private readonly XunitTracingInterceptor _logger; - - public SecurityLocationTests(Xunit.Abstractions.ITestOutputHelper output) + public SecurityLocationTests(Xunit.Abstractions.ITestOutputHelper output) : base(output) { - _logger = new XunitTracingInterceptor(output); - XunitTracingInterceptor.AddToContext(_logger); - TestExecutionHelpers.SetUpSessionAndProfile(); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetSubscriptionScope() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmSecurityLocation-SubscriptionScope"); + TestRunner.RunTestScript("Get-AzureRmSecurityLocation-SubscriptionScope"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetSubscriptionLevelResource() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmSecurityLocation-SubscriptionLevelResource"); + TestRunner.RunTestScript("Get-AzureRmSecurityLocation-SubscriptionLevelResource"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetResourceId() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmSecurityLocation-ResourceId"); + TestRunner.RunTestScript("Get-AzureRmSecurityLocation-ResourceId"); } } } diff --git a/src/Security/Security.Test/ScenarioTests/SecurityPricingTests.cs b/src/Security/Security.Test/ScenarioTests/SecurityPricingTests.cs index c560a3e90161..890bdf9fbedc 100644 --- a/src/Security/Security.Test/ScenarioTests/SecurityPricingTests.cs +++ b/src/Security/Security.Test/ScenarioTests/SecurityPricingTests.cs @@ -12,50 +12,43 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using Microsoft.Azure.Commands.ScenarioTest; -using Microsoft.Azure.ServiceManagement.Common.Models; using Microsoft.WindowsAzure.Commands.ScenarioTest; using Xunit; namespace Microsoft.Azure.Commands.Security.Test.ScenarioTests { - public class SecurityPricingTests + public class SecurityPricingTests : SecurityTestRunner { - private readonly XunitTracingInterceptor _logger; - - public SecurityPricingTests(Xunit.Abstractions.ITestOutputHelper output) + public SecurityPricingTests(Xunit.Abstractions.ITestOutputHelper output) : base(output) { - _logger = new XunitTracingInterceptor(output); - XunitTracingInterceptor.AddToContext(_logger); - TestExecutionHelpers.SetUpSessionAndProfile(); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetSubscriptionScope() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmSecurityPricing-SubscriptionScope"); + TestRunner.RunTestScript("Get-AzureRmSecurityPricing-SubscriptionScope"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetSubscriptionLevelResource() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmSecurityPricing-SubscriptionLevelResource"); + TestRunner.RunTestScript("Get-AzureRmSecurityPricing-SubscriptionLevelResource"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetResourceId() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmSecurityPricing-ResourceId"); + TestRunner.RunTestScript("Get-AzureRmSecurityPricing-ResourceId"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void SetSubscriptionLevelResource() { - TestController.NewInstance.RunPowerShellTest(_logger, "Set-AzureRmSecurityPricing-SubscriptionLevelResource"); + TestRunner.RunTestScript("Set-AzureRmSecurityPricing-SubscriptionLevelResource"); } } } diff --git a/src/Security/Security.Test/ScenarioTests/SecurityRegulatoryComplinceTests.cs b/src/Security/Security.Test/ScenarioTests/SecurityRegulatoryComplinceTests.cs index 36e9fdafc6e6..ebacb9385ea2 100644 --- a/src/Security/Security.Test/ScenarioTests/SecurityRegulatoryComplinceTests.cs +++ b/src/Security/Security.Test/ScenarioTests/SecurityRegulatoryComplinceTests.cs @@ -12,86 +12,78 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using Microsoft.Azure.Commands.ScenarioTest; -using Microsoft.Azure.ServiceManagement.Common.Models; using Microsoft.WindowsAzure.Commands.ScenarioTest; using Xunit; namespace Microsoft.Azure.Commands.Security.Test.ScenarioTests { - public class SecurityRegulatoryComplinceTests + public class SecurityRegulatoryComplinceTests : SecurityTestRunner { - private readonly XunitTracingInterceptor _logger; - - public SecurityRegulatoryComplinceTests(Xunit.Abstractions.ITestOutputHelper output) + public SecurityRegulatoryComplinceTests(Xunit.Abstractions.ITestOutputHelper output) : base(output) { - _logger = new XunitTracingInterceptor(output); - XunitTracingInterceptor.AddToContext(_logger); - TestExecutionHelpers.SetUpSessionAndProfile(); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetStandardSubscriptionScope() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmRegulatoryComplianceStandard-SubscriptionScope"); + TestRunner.RunTestScript("Get-AzureRmRegulatoryComplianceStandard-SubscriptionScope"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetStandardSubscriptionLevelResource() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmRegulatoryComplianceStandard-SubscriptionLevelResource"); + TestRunner.RunTestScript("Get-AzureRmRegulatoryComplianceStandard-SubscriptionLevelResource"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetStandardResourceId() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmRegulatoryComplianceStandard-ResourceId"); + TestRunner.RunTestScript("Get-AzureRmRegulatoryComplianceStandard-ResourceId"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetControlSubscriptionScope() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmRegulatoryComplianceControl-SubscriptionScope"); + TestRunner.RunTestScript("Get-AzureRmRegulatoryComplianceControl-SubscriptionScope"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetControlSubscriptionLevelResource() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmRegulatoryComplianceControl-SubscriptionLevelResource"); + TestRunner.RunTestScript("Get-AzureRmRegulatoryComplianceControl-SubscriptionLevelResource"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetControlResourceId() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmRegulatoryComplianceControl-ResourceId"); + TestRunner.RunTestScript("Get-AzureRmRegulatoryComplianceControl-ResourceId"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetAssessmentSubscriptionScope() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmRegulatoryComplianceAssessment-SubscriptionScope"); + TestRunner.RunTestScript("Get-AzureRmRegulatoryComplianceAssessment-SubscriptionScope"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetAssessmentSubscriptionLevelResource() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmRegulatoryComplianceAssessment-SubscriptionLevelResource"); + TestRunner.RunTestScript("Get-AzureRmRegulatoryComplianceAssessment-SubscriptionLevelResource"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetAssessmentResourceId() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmRegulatoryComplianceAssessment-ResourceId"); + TestRunner.RunTestScript("Get-AzureRmRegulatoryComplianceAssessment-ResourceId"); } - } } diff --git a/src/Security/Security.Test/ScenarioTests/SecuritySecureScoreControlDefinitionTests.cs b/src/Security/Security.Test/ScenarioTests/SecuritySecureScoreControlDefinitionTests.cs index cbbb61b26b29..ea42f9d174ed 100644 --- a/src/Security/Security.Test/ScenarioTests/SecuritySecureScoreControlDefinitionTests.cs +++ b/src/Security/Security.Test/ScenarioTests/SecuritySecureScoreControlDefinitionTests.cs @@ -12,29 +12,22 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using Microsoft.Azure.Commands.ScenarioTest; -using Microsoft.Azure.ServiceManagement.Common.Models; using Microsoft.WindowsAzure.Commands.ScenarioTest; using Xunit; namespace Microsoft.Azure.Commands.Security.Test.ScenarioTests { - public class SecuritySecureScoreControlDefinitionTests + public class SecuritySecureScoreControlDefinitionTests : SecurityTestRunner { - private readonly XunitTracingInterceptor _logger; - - public SecuritySecureScoreControlDefinitionTests(Xunit.Abstractions.ITestOutputHelper output) + public SecuritySecureScoreControlDefinitionTests(Xunit.Abstractions.ITestOutputHelper output) : base(output) { - _logger = new XunitTracingInterceptor(output); - XunitTracingInterceptor.AddToContext(_logger); - TestExecutionHelpers.SetUpSessionAndProfile(); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetAllSecureScoreControlDefinitions() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AllSecuritySecureScoreControlDefinitions"); + TestRunner.RunTestScript("Get-AllSecuritySecureScoreControlDefinitions"); } } } diff --git a/src/Security/Security.Test/ScenarioTests/SecuritySecureScoreControlTests.cs b/src/Security/Security.Test/ScenarioTests/SecuritySecureScoreControlTests.cs index 46350dbc3c16..7b8487f2a8c0 100644 --- a/src/Security/Security.Test/ScenarioTests/SecuritySecureScoreControlTests.cs +++ b/src/Security/Security.Test/ScenarioTests/SecuritySecureScoreControlTests.cs @@ -12,37 +12,29 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using Microsoft.Azure.Commands.ScenarioTest; -using Microsoft.Azure.ServiceManagement.Common.Models; using Microsoft.WindowsAzure.Commands.ScenarioTest; using Xunit; namespace Microsoft.Azure.Commands.Security.Test.ScenarioTests { - public class SecuritySecureScoreControlTests + public class SecuritySecureScoreControlTests : SecurityTestRunner { - private readonly XunitTracingInterceptor _logger; - - public SecuritySecureScoreControlTests(Xunit.Abstractions.ITestOutputHelper output) + public SecuritySecureScoreControlTests(Xunit.Abstractions.ITestOutputHelper output) : base(output) { - _logger = new XunitTracingInterceptor(output); - XunitTracingInterceptor.AddToContext(_logger); - TestExecutionHelpers.SetUpSessionAndProfile(); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetAllSecureScoreControls() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AllSecuritySecureScoreControls"); + TestRunner.RunTestScript("Get-AllSecuritySecureScoreControls"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetAscSecureScoreControls() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AscSecuritySecureScoreControls"); + TestRunner.RunTestScript("Get-AscSecuritySecureScoreControls"); } - } } diff --git a/src/Security/Security.Test/ScenarioTests/SecuritySecureScoreTests.cs b/src/Security/Security.Test/ScenarioTests/SecuritySecureScoreTests.cs index 7816bf261ca3..b6d8844b700f 100644 --- a/src/Security/Security.Test/ScenarioTests/SecuritySecureScoreTests.cs +++ b/src/Security/Security.Test/ScenarioTests/SecuritySecureScoreTests.cs @@ -12,40 +12,29 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using Microsoft.Azure.Commands.ScenarioTest; -using Microsoft.Azure.ServiceManagement.Common.Models; -using Microsoft.Azure.Test.HttpRecorder; using Microsoft.WindowsAzure.Commands.ScenarioTest; -using System.Diagnostics; -using System.IO; -using System.Text; using Xunit; namespace Microsoft.Azure.Commands.Security.Test.ScenarioTests { - public class SecuritySecureScoreTests + public class SecuritySecureScoreTests : SecurityTestRunner { - private readonly XunitTracingInterceptor _logger; - - public SecuritySecureScoreTests(Xunit.Abstractions.ITestOutputHelper output) + public SecuritySecureScoreTests(Xunit.Abstractions.ITestOutputHelper output) : base(output) { - _logger = new XunitTracingInterceptor(output); - XunitTracingInterceptor.AddToContext(_logger); - TestExecutionHelpers.SetUpSessionAndProfile(); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetAllSecureScores() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AllSecuritySecureScores"); + TestRunner.RunTestScript("Get-AllSecuritySecureScores"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetAscSecureScore() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-SecuritySecureScore"); + TestRunner.RunTestScript("Get-SecuritySecureScore"); } } } diff --git a/src/Security/Security.Test/ScenarioTests/SecuritySettingTests.cs b/src/Security/Security.Test/ScenarioTests/SecuritySettingTests.cs index a4109005ec8b..aabe07f6075f 100644 --- a/src/Security/Security.Test/ScenarioTests/SecuritySettingTests.cs +++ b/src/Security/Security.Test/ScenarioTests/SecuritySettingTests.cs @@ -12,43 +12,36 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using Microsoft.Azure.Commands.ScenarioTest; -using Microsoft.Azure.ServiceManagement.Common.Models; using Microsoft.WindowsAzure.Commands.ScenarioTest; using Xunit; namespace Microsoft.Azure.Commands.Security.Test.ScenarioTests { - public class SecuritySettingTests + public class SecuritySettingTests : SecurityTestRunner { - private readonly XunitTracingInterceptor _logger; - - public SecuritySettingTests(Xunit.Abstractions.ITestOutputHelper output) + public SecuritySettingTests(Xunit.Abstractions.ITestOutputHelper output) : base(output) { - _logger = new XunitTracingInterceptor(output); - XunitTracingInterceptor.AddToContext(_logger); - TestExecutionHelpers.SetUpSessionAndProfile(); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetSubscriptionScope() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmSecuritySetting-SubscriptionScope"); + TestRunner.RunTestScript("Get-AzureRmSecuritySetting-SubscriptionScope"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetSubscriptionLevelResource() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmSecuritySetting-SubscriptionLevelResource"); + TestRunner.RunTestScript("Get-AzureRmSecuritySetting-SubscriptionLevelResource"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void SetSettingsScope() { - TestController.NewInstance.RunPowerShellTest(_logger, "Set-AzureRmSecuritySetting-SettingsScope"); + TestRunner.RunTestScript("Set-AzureRmSecuritySetting-SettingsScope"); } } } \ No newline at end of file diff --git a/src/Security/Security.Test/ScenarioTests/SecuritySolutionTests .cs b/src/Security/Security.Test/ScenarioTests/SecuritySolutionTests .cs index 2d6dfc052060..cbfda38ff408 100644 --- a/src/Security/Security.Test/ScenarioTests/SecuritySolutionTests .cs +++ b/src/Security/Security.Test/ScenarioTests/SecuritySolutionTests .cs @@ -12,29 +12,22 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using Microsoft.Azure.Commands.ScenarioTest; -using Microsoft.Azure.ServiceManagement.Common.Models; using Microsoft.WindowsAzure.Commands.ScenarioTest; using Xunit; namespace Microsoft.Azure.Commands.Security.Test.ScenarioTests { - public class SecuritySolutionTests + public class SecuritySolutionTests : SecurityTestRunner { - private readonly XunitTracingInterceptor _logger; - - public SecuritySolutionTests(Xunit.Abstractions.ITestOutputHelper output) + public SecuritySolutionTests(Xunit.Abstractions.ITestOutputHelper output) : base(output) { - _logger = new XunitTracingInterceptor(output); - XunitTracingInterceptor.AddToContext(_logger); - TestExecutionHelpers.SetUpSessionAndProfile(); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetSubscriptionScope() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzSecuritySolution-SubscriptionScope"); + TestRunner.RunTestScript("Get-AzSecuritySolution-SubscriptionScope"); } } } \ No newline at end of file diff --git a/src/Security/Security.Test/ScenarioTests/SecuritySolutionsReferenceDataTests.cs b/src/Security/Security.Test/ScenarioTests/SecuritySolutionsReferenceDataTests.cs index e42e10436656..fbdafd2b10bf 100644 --- a/src/Security/Security.Test/ScenarioTests/SecuritySolutionsReferenceDataTests.cs +++ b/src/Security/Security.Test/ScenarioTests/SecuritySolutionsReferenceDataTests.cs @@ -12,29 +12,22 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using Microsoft.Azure.Commands.ScenarioTest; -using Microsoft.Azure.ServiceManagement.Common.Models; using Microsoft.WindowsAzure.Commands.ScenarioTest; using Xunit; namespace Microsoft.Azure.Commands.Security.Test.ScenarioTests { - public class SecuritySolutionsReferenceDataTests + public class SecuritySolutionsReferenceDataTests : SecurityTestRunner { - private readonly XunitTracingInterceptor _logger; - - public SecuritySolutionsReferenceDataTests(Xunit.Abstractions.ITestOutputHelper output) + public SecuritySolutionsReferenceDataTests(Xunit.Abstractions.ITestOutputHelper output) : base(output) { - _logger = new XunitTracingInterceptor(output); - XunitTracingInterceptor.AddToContext(_logger); - TestExecutionHelpers.SetUpSessionAndProfile(); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetSubscriptionScope() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzSecuritySolutionsReferenceData-SubscriptionScope"); + TestRunner.RunTestScript("Get-AzSecuritySolutionsReferenceData-SubscriptionScope"); } } } diff --git a/src/Security/Security.Test/ScenarioTests/SecuritySubAssessmentTests.cs b/src/Security/Security.Test/ScenarioTests/SecuritySubAssessmentTests.cs index bbbd6793af59..acca9a8d946e 100644 --- a/src/Security/Security.Test/ScenarioTests/SecuritySubAssessmentTests.cs +++ b/src/Security/Security.Test/ScenarioTests/SecuritySubAssessmentTests.cs @@ -12,36 +12,29 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using Microsoft.Azure.Commands.ScenarioTest; -using Microsoft.Azure.ServiceManagement.Common.Models; using Microsoft.WindowsAzure.Commands.ScenarioTest; using Xunit; namespace Microsoft.Azure.Commands.Security.Test.ScenarioTests { - public class SecuritySubAssessmentTests + public class SecuritySubAssessmentTests : SecurityTestRunner { - private readonly XunitTracingInterceptor _logger; - - public SecuritySubAssessmentTests(Xunit.Abstractions.ITestOutputHelper output) + public SecuritySubAssessmentTests(Xunit.Abstractions.ITestOutputHelper output) : base(output) { - _logger = new XunitTracingInterceptor(output); - XunitTracingInterceptor.AddToContext(_logger); - TestExecutionHelpers.SetUpSessionAndProfile(); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetAllSubAssessments() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AllSecuritySubAssessments"); + TestRunner.RunTestScript("Get-AllSecuritySubAssessments"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetSingleSubAssessments() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-SingleSecuritySubAssessment"); + TestRunner.RunTestScript("Get-SingleSecuritySubAssessment"); } } } diff --git a/src/Security/Security.Test/ScenarioTests/SecurityTaskTests.cs b/src/Security/Security.Test/ScenarioTests/SecurityTaskTests.cs index 296a23805882..67f7574b97e3 100644 --- a/src/Security/Security.Test/ScenarioTests/SecurityTaskTests.cs +++ b/src/Security/Security.Test/ScenarioTests/SecurityTaskTests.cs @@ -12,57 +12,50 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using Microsoft.Azure.Commands.ScenarioTest; -using Microsoft.Azure.ServiceManagement.Common.Models; using Microsoft.WindowsAzure.Commands.ScenarioTest; using Xunit; namespace Microsoft.Azure.Commands.Security.Test.ScenarioTests { - public class SecurityTaskTests + public class SecurityTaskTests : SecurityTestRunner { - private readonly XunitTracingInterceptor _logger; - - public SecurityTaskTests(Xunit.Abstractions.ITestOutputHelper output) + public SecurityTaskTests(Xunit.Abstractions.ITestOutputHelper output) : base(output) { - _logger = new XunitTracingInterceptor(output); - XunitTracingInterceptor.AddToContext(_logger); - TestExecutionHelpers.SetUpSessionAndProfile(); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetSubscriptionScope() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmSecurityTask-SubscriptionScope"); + TestRunner.RunTestScript("Get-AzureRmSecurityTask-SubscriptionScope"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetResourceGroupScope() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmSecurityTask-ResourceGroupScope"); + TestRunner.RunTestScript("Get-AzureRmSecurityTask-ResourceGroupScope"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetResourceId() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmSecurityTask-ResourceId"); + TestRunner.RunTestScript("Get-AzureRmSecurityTask-ResourceId"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetSubscriptionLevelResource() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmSecurityTask-SubscriptionLevelResource"); + TestRunner.RunTestScript("Get-AzureRmSecurityTask-SubscriptionLevelResource"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetResourceGroupLevelResource() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmSecurityTask-ResourceGroupLevelResource"); + TestRunner.RunTestScript("Get-AzureRmSecurityTask-ResourceGroupLevelResource"); } } } diff --git a/src/Security/Security.Test/ScenarioTests/SecurityTestRunner.cs b/src/Security/Security.Test/ScenarioTests/SecurityTestRunner.cs new file mode 100644 index 000000000000..fe961e39feb7 --- /dev/null +++ b/src/Security/Security.Test/ScenarioTests/SecurityTestRunner.cs @@ -0,0 +1,51 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using System.Collections.Generic; +using Microsoft.Azure.Commands.TestFx; +using Xunit.Abstractions; + +namespace Microsoft.Azure.Commands.Security.Test.ScenarioTests +{ + public class SecurityTestRunner + { + protected readonly ITestRunner TestRunner; + + protected SecurityTestRunner(ITestOutputHelper output) + { + TestRunner = TestManager.CreateInstance(output) + .WithNewPsScriptFilename($"{GetType().Name}.ps1") + .WithProjectSubfolderForTests("ScenarioTests") + .WithCommonPsScripts(new[] + { + @"Common.ps1", + @"../AzureRM.Storage.ps1", + @"../AzureRM.Resources.ps1" + }) + .WithNewRmModules(helper => new[] + { + helper.RMProfileModule, + helper.GetRMModulePath("Az.Security.psd1"), + helper.GetRMModulePath("Az.Compute.psd1"), + helper.GetRMModulePath("Az.Network.psd1"), + helper.GetRMModulePath("Az.OperationalInsights.psd1"), + }) + .WithNewRecordMatcherArguments( + userAgentsToIgnore: new Dictionary(), + resourceProviders: new Dictionary() + ) + .Build(); + } + } +} diff --git a/src/Security/Security.Test/ScenarioTests/SecurityTopologyTests.cs b/src/Security/Security.Test/ScenarioTests/SecurityTopologyTests.cs index 55da88c63999..eb17ae12f56b 100644 --- a/src/Security/Security.Test/ScenarioTests/SecurityTopologyTests.cs +++ b/src/Security/Security.Test/ScenarioTests/SecurityTopologyTests.cs @@ -1,41 +1,33 @@ -using Microsoft.Azure.Commands.ScenarioTest; -using Microsoft.Azure.ServiceManagement.Common.Models; -using Microsoft.WindowsAzure.Commands.ScenarioTest; +using Microsoft.WindowsAzure.Commands.ScenarioTest; using Xunit; namespace Microsoft.Azure.Commands.Security.Test.ScenarioTests { - public class SecurityTopologyTests + public class SecurityTopologyTests : SecurityTestRunner { - private readonly XunitTracingInterceptor _logger; - - public SecurityTopologyTests(Xunit.Abstractions.ITestOutputHelper output) + public SecurityTopologyTests(Xunit.Abstractions.ITestOutputHelper output) : base(output) { - _logger = new XunitTracingInterceptor(output); - XunitTracingInterceptor.AddToContext(_logger); - TestExecutionHelpers.SetUpSessionAndProfile(); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetSubscriptionScope() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmSecurityTopology-SubscriptionScope"); + TestRunner.RunTestScript("Get-AzureRmSecurityTopology-SubscriptionScope"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetResourceGroupLevelResource() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmSecurityTopology-ResourceGroupLevelResource"); + TestRunner.RunTestScript("Get-AzureRmSecurityTopology-ResourceGroupLevelResource"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetResourceId() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmSecurityTopology-ResourceId"); + TestRunner.RunTestScript("Get-AzureRmSecurityTopology-ResourceId"); } } } - diff --git a/src/Security/Security.Test/ScenarioTests/SecurityWorkspaceSettingTests.cs b/src/Security/Security.Test/ScenarioTests/SecurityWorkspaceSettingTests.cs index bee7c1184e61..4c3e0efb4fb3 100644 --- a/src/Security/Security.Test/ScenarioTests/SecurityWorkspaceSettingTests.cs +++ b/src/Security/Security.Test/ScenarioTests/SecurityWorkspaceSettingTests.cs @@ -12,57 +12,50 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using Microsoft.Azure.Commands.ScenarioTest; -using Microsoft.Azure.ServiceManagement.Common.Models; using Microsoft.WindowsAzure.Commands.ScenarioTest; using Xunit; namespace Microsoft.Azure.Commands.Security.Test.ScenarioTests { - public class SecurityWorkspaceSettingTests + public class SecurityWorkspaceSettingTests : SecurityTestRunner { - private readonly XunitTracingInterceptor _logger; - - public SecurityWorkspaceSettingTests(Xunit.Abstractions.ITestOutputHelper output) + public SecurityWorkspaceSettingTests(Xunit.Abstractions.ITestOutputHelper output) : base(output) { - _logger = new XunitTracingInterceptor(output); - XunitTracingInterceptor.AddToContext(_logger); - TestExecutionHelpers.SetUpSessionAndProfile(); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetSubscriptionScope() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmSecurityWorkspaceSetting-SubscriptionScope"); + TestRunner.RunTestScript("Get-AzureRmSecurityWorkspaceSetting-SubscriptionScope"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetSubscriptionLevelResource() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmSecurityWorkspaceSetting-SubscriptionLevelResource"); + TestRunner.RunTestScript("Get-AzureRmSecurityWorkspaceSetting-SubscriptionLevelResource"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void GetResourceId() { - TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmSecurityWorkspaceSetting-ResourceId"); + TestRunner.RunTestScript("Get-AzureRmSecurityWorkspaceSetting-ResourceId"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void SetSubscriptionLevelResource() { - TestController.NewInstance.RunPowerShellTest(_logger, "Set-AzureRmSecurityWorkspaceSetting-SubscriptionLevelResource"); + TestRunner.RunTestScript("Set-AzureRmSecurityWorkspaceSetting-SubscriptionLevelResource"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void RemoveSubscriptionLevelResource() { - TestController.NewInstance.RunPowerShellTest(_logger, "Remove-AzureRmSecurityWorkspaceSetting-SubscriptionLevelResource"); + TestRunner.RunTestScript("Remove-AzureRmSecurityWorkspaceSetting-SubscriptionLevelResource"); } } } diff --git a/src/Security/Security.Test/ScenarioTests/SqlInformationProtectionPolicyTests.cs b/src/Security/Security.Test/ScenarioTests/SqlInformationProtectionPolicyTests.cs index fad93bc6a128..6073363e0fb3 100644 --- a/src/Security/Security.Test/ScenarioTests/SqlInformationProtectionPolicyTests.cs +++ b/src/Security/Security.Test/ScenarioTests/SqlInformationProtectionPolicyTests.cs @@ -12,34 +12,29 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using Microsoft.Azure.Commands.ScenarioTest; -using Microsoft.Azure.ServiceManagement.Common.Models; using Microsoft.WindowsAzure.Commands.ScenarioTest; using Xunit; namespace Microsoft.Azure.Commands.Security.Test.ScenarioTests { - public class SqlInformationProtectionPolicyTests + public class SqlInformationProtectionPolicyTests : SecurityTestRunner { - public SqlInformationProtectionPolicyTests(Xunit.Abstractions.ITestOutputHelper output) + public SqlInformationProtectionPolicyTests(Xunit.Abstractions.ITestOutputHelper output) : base(output) { - _logger = new XunitTracingInterceptor(output); - XunitTracingInterceptor.AddToContext(_logger); - TestExecutionHelpers.SetUpSessionAndProfile(); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void TestErrorWhenInformationTypeAndSensitivityLabelShareSameId() { - TestController.NewInstance.RunPowerShellTest(_logger, "Test-ErrorWhenInformationTypeAndSensitivityLabelShareSameId"); + TestRunner.RunTestScript("Test-ErrorWhenInformationTypeAndSensitivityLabelShareSameId"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void TestErrorWhenInformationTypeAndSensitivityLabelShareSameDisplayName() { - TestController.NewInstance.RunPowerShellTest(_logger, "Test-ErrorWhenInformationTypeAndSensitivityLabelShareSameDisplayName"); + TestRunner.RunTestScript("Test-ErrorWhenInformationTypeAndSensitivityLabelShareSameDisplayName"); } @@ -47,51 +42,49 @@ public void TestErrorWhenInformationTypeAndSensitivityLabelShareSameDisplayName( [Trait(Category.AcceptanceType, Category.CheckIn)] public void TestErrorWhenInformationTypesShareSameDisplayName() { - TestController.NewInstance.RunPowerShellTest(_logger, "Test-ErrorWhenInformationTypesShareSameDisplayName"); + TestRunner.RunTestScript("Test-ErrorWhenInformationTypesShareSameDisplayName"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void TestErrorWhenInformationTypesShareSameId() { - TestController.NewInstance.RunPowerShellTest(_logger, "Test-ErrorWhenInformationTypesShareSameId"); + TestRunner.RunTestScript("Test-ErrorWhenInformationTypesShareSameId"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void TestErrorWhenSensitivityLabelsShareSameDisplayName() { - TestController.NewInstance.RunPowerShellTest(_logger, "Test-ErrorWhenSensitivityLabelsShareSameDisplayName"); + TestRunner.RunTestScript("Test-ErrorWhenSensitivityLabelsShareSameDisplayName"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void TestErrorWhenSensitivityLabelsShareSameId() { - TestController.NewInstance.RunPowerShellTest(_logger, "Test-ErrorWhenSensitivityLabelsShareSameId"); + TestRunner.RunTestScript("Test-ErrorWhenSensitivityLabelsShareSameId"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void TestErrorWhenRankIsInvalid() { - TestController.NewInstance.RunPowerShellTest(_logger, "Test-ErrorWhenRankIsInvalid"); + TestRunner.RunTestScript("Test-ErrorWhenRankIsInvalid"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void TestErrorWhenRankIsMissing() { - TestController.NewInstance.RunPowerShellTest(_logger, "Test-ErrorWhenRankIsMissing"); + TestRunner.RunTestScript("Test-ErrorWhenRankIsMissing"); } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void TestErrorWhenSettingAnEmptyPolicy() { - TestController.NewInstance.RunPowerShellTest(_logger, "Test-ErrorWhenSettingAnEmptyPolicy"); + TestRunner.RunTestScript("Test-ErrorWhenSettingAnEmptyPolicy"); } - - private readonly XunitTracingInterceptor _logger; } } diff --git a/src/Security/Security.Test/ScenarioTests/SqlVulnerabilityAssessmentTests.cs b/src/Security/Security.Test/ScenarioTests/SqlVulnerabilityAssessmentTests.cs index c427232a61bb..9d67d73eaa99 100644 --- a/src/Security/Security.Test/ScenarioTests/SqlVulnerabilityAssessmentTests.cs +++ b/src/Security/Security.Test/ScenarioTests/SqlVulnerabilityAssessmentTests.cs @@ -12,22 +12,15 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using Microsoft.Azure.Commands.ScenarioTest; -using Microsoft.Azure.ServiceManagement.Common.Models; using Microsoft.WindowsAzure.Commands.ScenarioTest; using Xunit; namespace Microsoft.Azure.Commands.Security.Test.ScenarioTests { - public class SqlVulnerabilityAssessmentTests + public class SqlVulnerabilityAssessmentTests : SecurityTestRunner { - private readonly XunitTracingInterceptor _logger; - - public SqlVulnerabilityAssessmentTests(Xunit.Abstractions.ITestOutputHelper output) + public SqlVulnerabilityAssessmentTests(Xunit.Abstractions.ITestOutputHelper output) : base(output) { - _logger = new XunitTracingInterceptor(output); - XunitTracingInterceptor.AddToContext(_logger); - TestExecutionHelpers.SetUpSessionAndProfile(); } /* @@ -39,7 +32,7 @@ public SqlVulnerabilityAssessmentTests(Xunit.Abstractions.ITestOutputHelper outp [Trait(Category.AcceptanceType, Category.LiveOnly)] public void TestAzSecuritySqlVulnerabilityAssessment() { - TestController.NewInstance.RunPowerShellTest(_logger, "Test-AzSecuritySqlVulnerabilityAssessment"); + TestRunner.RunTestScript("Test-AzSecuritySqlVulnerabilityAssessment"); } } } diff --git a/src/Security/Security.Test/ScenarioTests/TestController.cs b/src/Security/Security.Test/ScenarioTests/TestController.cs deleted file mode 100644 index e88fcdf87941..000000000000 --- a/src/Security/Security.Test/ScenarioTests/TestController.cs +++ /dev/null @@ -1,122 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// Copyright Microsoft Corporation -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ---------------------------------------------------------------------------------- - -using Microsoft.Azure.Commands.Common.Authentication; -using Microsoft.Azure.Management.Compute; -using Microsoft.Azure.Management.OperationalInsights; -using Microsoft.Azure.Management.Internal.Network.Version2017_10_01; -using Microsoft.Azure.Management.Internal.Resources; -using Microsoft.Azure.Management.Security; -using Microsoft.Azure.Management.Storage.Version2017_10_01; -using Microsoft.Azure.Test.HttpRecorder; -using Microsoft.Rest.ClientRuntime.Azure.TestFramework; -using Microsoft.WindowsAzure.Commands.ScenarioTest; -using Microsoft.WindowsAzure.Commands.Test.Utilities.Common; -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Linq; - -namespace Microsoft.Azure.Commands.Security.Test.ScenarioTests -{ - public class TestController : RMTestBase - { - private readonly EnvironmentSetupHelper _helper; - - public static TestController NewInstance => new TestController(); - - protected TestController() - { - _helper = new EnvironmentSetupHelper(); - } - - public void RunPowerShellTest(ServiceManagement.Common.Models.XunitTracingInterceptor logger, params string[] scripts) - { - var sf = new StackTrace().GetFrame(1); - var callingClassType = sf.GetMethod().ReflectedType?.ToString(); - var mockName = sf.GetMethod().Name; - - _helper.TracingInterceptor = logger; - var providers = new Dictionary(); - var providersToIgnore = new Dictionary(); - HttpMockServer.Matcher = new PermissiveRecordMatcherWithApiExclusion(true, providers, providersToIgnore); - HttpMockServer.RecordsDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SessionRecords"); - - using (var context = MockContext.Start(callingClassType, mockName)) - { - SetupManagementClients(context); - - _helper.SetupEnvironment(AzureModule.AzureResourceManager); - var computePath = _helper.GetRMModulePath(@"AzureRM.Compute.psd1"); - var networkPath = _helper.GetRMModulePath(@"AzureRM.Network.psd1"); - var operationalInsightsPath = _helper.GetRMModulePath(@"AzureRM.OperationalInsights.psd1"); - - var callingClassName = callingClassType?.Split(new[] { "." }, StringSplitOptions.RemoveEmptyEntries).Last(); - _helper.SetupModules( - AzureModule.AzureResourceManager, - _helper.RMProfileModule, - _helper.GetRMModulePath(@"AzureRM.Security.psd1"), - computePath, - networkPath, - operationalInsightsPath, - "ScenarioTests\\Common.ps1", - "ScenarioTests\\" + callingClassName + ".ps1", - "AzureRM.Storage.ps1", - "AzureRM.Resources.ps1"); - - _helper.RunPowerShellTest(scripts); - } - } - - protected void SetupManagementClients(MockContext context) - { - var resourcesClient = GetResourcesClient(context); - var securityCenterClient = GetSecurityCenterClient(context); - var storageClient = GetStorageManagementClient(context); - var computeClient = GetComputeManagementClient(context); - var networkClient = GetNetworkManagementClient(context); - var operationalInsightsClient = GetOperationalInsightsManagementClient(context); - _helper.SetupManagementClients(securityCenterClient, resourcesClient, storageClient, computeClient, networkClient, operationalInsightsClient); - } - - private static SecurityCenterClient GetSecurityCenterClient(MockContext context) - { - return context.GetServiceClient(TestEnvironmentFactory.GetTestEnvironment()); - } - private static ResourceManagementClient GetResourcesClient(MockContext context) - { - return context.GetServiceClient(TestEnvironmentFactory.GetTestEnvironment()); - } - private static StorageManagementClient GetStorageManagementClient(MockContext context) - { - return context.GetServiceClient(TestEnvironmentFactory.GetTestEnvironment()); - } - - private static ComputeManagementClient GetComputeManagementClient(MockContext context) - { - return context.GetServiceClient(TestEnvironmentFactory.GetTestEnvironment()); - } - - private static NetworkManagementClient GetNetworkManagementClient(MockContext context) - { - return context.GetServiceClient(TestEnvironmentFactory.GetTestEnvironment()); - } - - private static OperationalInsightsManagementClient GetOperationalInsightsManagementClient(MockContext context) - { - return context.GetServiceClient(TestEnvironmentFactory.GetTestEnvironment()); - } - } -} diff --git a/src/Security/Security/help/Get-AzRegulatoryComplianceControl.md b/src/Security/Security/help/Get-AzRegulatoryComplianceControl.md index feab0d31a387..edc9b6b46955 100644 --- a/src/Security/Security/help/Get-AzRegulatoryComplianceControl.md +++ b/src/Security/Security/help/Get-AzRegulatoryComplianceControl.md @@ -40,7 +40,7 @@ Id : /subscriptions/487bb485-b5b0-471e-9c0d-10717612f869/provide Name : A1.1 Type : Microsoft.Security/regulatoryComplianceStandards/regulatoryComplianceControls Description : Current processing capacity and usage are maintained, monitored, and evaluated to manage capacity - demand and to enable the implementation of additional capacity to help meet the entity�s + demand and to enable the implementation of additional capacity to help meet the entity's availability commitments and system requirements. State : Unsupported PassedAssessments : 0 @@ -63,7 +63,7 @@ Id : /subscriptions/487bb485-b5b0-471e-9c0d-10717612f869/provide nceStandards/SOC-TSP/regulatoryComplianceControls/A1.3 Name : A1.3 Type : Microsoft.Security/regulatoryComplianceStandards/regulatoryComplianceControls -Description : Recovery plan procedures supporting system recovery are tested to help meet the entity�s +Description : Recovery plan procedures supporting system recovery are tested to help meet the entity's availability commitments and system requirements. State : Unsupported PassedAssessments : 0 diff --git a/src/Security/Security/help/Get-AzSecuritySqlVulnerabilityAssessmentScanResult.md b/src/Security/Security/help/Get-AzSecuritySqlVulnerabilityAssessmentScanResult.md index 424b495c6b82..3adf4fc19298 100644 --- a/src/Security/Security/help/Get-AzSecuritySqlVulnerabilityAssessmentScanResult.md +++ b/src/Security/Security/help/Get-AzSecuritySqlVulnerabilityAssessmentScanResult.md @@ -54,12 +54,12 @@ RuleMetadata : { Severity: High Category: AuthenticationAndAuthorization Rule type: NegativeList - Title: Execute permissions on xp_cmdshell from all users (except dbo) should be revoked. - Description: The xp_cmdshell extended stored procedure spawns a Windows command shell, passing in a string for execution. This rule checks that no users (except users with the CONTROL SERVER permission like members of the sysadmin server role) have permission to execute the xp_cmdshell ext - ended stored procedure. - Rationale: The xp_cmdshell extended stored procedure is a very powerful tool, but because of that, it is crucial that access to xp_cmdshell be tightly controlled. By default, only users with the CONTROL SERVER permission like members of the sysadmin server role can execute this extended - stored procedure. When first enabled, xp_cmdshell has the same security context as the SQL Server service account. The SQL Server service account is often more privileged than necessary for the work being performed by the process created by xp_cmdshell. As such, malicious users can attempt  - to elevate their privileges by using xp_cmdshell. See https://docs.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/xp-cmdshell-transact-sql for more information on xp_cmdshell. + Title: Execute permissions on xp_cmdshell from all users (except dbo) should be revoked. + Description: The xp_cmdshell extended stored procedure spawns a Windows command shell, passing in a string for execution. This rule checks that no users (except users with the CONTROL SERVER permission like members of the sysadmin server role) have permission to execute the xp_cmdshell ext + ended stored procedure. + Rationale: The xp_cmdshell extended stored procedure is a very powerful tool, but because of that, it is crucial that access to xp_cmdshell be tightly controlled. By default, only users with the CONTROL SERVER permission like members of the sysadmin server role can execute this extended + stored procedure. When first enabled, xp_cmdshell has the same security context as the SQL Server service account. The SQL Server service account is often more privileged than necessary for the work being performed by the process created by xp_cmdshell. As such, malicious users can attempt + to elevate their privileges by using xp_cmdshell. See https://docs.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/xp-cmdshell-transact-sql for more information on xp_cmdshell. Query check: { Query: @@ -146,20 +146,20 @@ RuleMetadata : { Category: AuthenticationAndAuthorization Rule type: NegativeList Title: - Execute permissions on xp_cmdshell from all users (except dbo) should be revoked. - Description: The xp_cmdshell extended stored procedure spawns a Windows command shell, passin - g in a string for execution. This rule checks that no users (except users with the CONTROL SER - VER permission like members of the sysadmin server role) have permission to execute the xp_cmd - shell extended stored procedure. - Rationale: The xp_cmdshell extended stored procedure is a very powerful tool, but because o - f that, it is crucial that access to xp_cmdshell be tightly controlled. By default, only + Execute permissions on xp_cmdshell from all users (except dbo) should be revoked. + Description: The xp_cmdshell extended stored procedure spawns a Windows command shell, passin + g in a string for execution. This rule checks that no users (except users with the CONTROL SER + VER permission like members of the sysadmin server role) have permission to execute the xp_cmd + shell extended stored procedure. + Rationale: The xp_cmdshell extended stored procedure is a very powerful tool, but because o + f that, it is crucial that access to xp_cmdshell be tightly controlled. By default, only users with the CONTROL SERVER permission like members of the sysadmin server role can execute - this extended stored procedure. When first enabled, xp_cmdshell has the same security context  - as the SQL Server service account. The SQL Server service account is often more privileged tha - n necessary for the work being performed by the process created by xp_cmdshell. As such, malic - ious users can attempt to elevate their privileges by using xp_cmdshell. See https://docs.micr - osoft.com/en-us/sql/relational-databases/system-stored-procedures/xp-cmdshell-transact-sql for -  more information on xp_cmdshell. + this extended stored procedure. When first enabled, xp_cmdshell has the same security context + as the SQL Server service account. The SQL Server service account is often more privileged tha + n necessary for the work being performed by the process created by xp_cmdshell. As such, malic + ious users can attempt to elevate their privileges by using xp_cmdshell. See https://docs.micr + osoft.com/en-us/sql/relational-databases/system-stored-procedures/xp-cmdshell-transact-sql for + more information on xp_cmdshell. Query check: { Query: From 88070f7d5d339415bd94924ce16bbaebb6ac9f95 Mon Sep 17 00:00:00 2001 From: Ziyue Zheng Date: Thu, 19 May 2022 11:13:16 +0800 Subject: [PATCH 2/2] Revert Az.Security document changes --- .../help/Get-AzRegulatoryComplianceControl.md | 4 +- ...itySqlVulnerabilityAssessmentScanResult.md | 38 +++++++++---------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/Security/Security/help/Get-AzRegulatoryComplianceControl.md b/src/Security/Security/help/Get-AzRegulatoryComplianceControl.md index edc9b6b46955..feab0d31a387 100644 --- a/src/Security/Security/help/Get-AzRegulatoryComplianceControl.md +++ b/src/Security/Security/help/Get-AzRegulatoryComplianceControl.md @@ -40,7 +40,7 @@ Id : /subscriptions/487bb485-b5b0-471e-9c0d-10717612f869/provide Name : A1.1 Type : Microsoft.Security/regulatoryComplianceStandards/regulatoryComplianceControls Description : Current processing capacity and usage are maintained, monitored, and evaluated to manage capacity - demand and to enable the implementation of additional capacity to help meet the entity's + demand and to enable the implementation of additional capacity to help meet the entity�s availability commitments and system requirements. State : Unsupported PassedAssessments : 0 @@ -63,7 +63,7 @@ Id : /subscriptions/487bb485-b5b0-471e-9c0d-10717612f869/provide nceStandards/SOC-TSP/regulatoryComplianceControls/A1.3 Name : A1.3 Type : Microsoft.Security/regulatoryComplianceStandards/regulatoryComplianceControls -Description : Recovery plan procedures supporting system recovery are tested to help meet the entity's +Description : Recovery plan procedures supporting system recovery are tested to help meet the entity�s availability commitments and system requirements. State : Unsupported PassedAssessments : 0 diff --git a/src/Security/Security/help/Get-AzSecuritySqlVulnerabilityAssessmentScanResult.md b/src/Security/Security/help/Get-AzSecuritySqlVulnerabilityAssessmentScanResult.md index 3adf4fc19298..424b495c6b82 100644 --- a/src/Security/Security/help/Get-AzSecuritySqlVulnerabilityAssessmentScanResult.md +++ b/src/Security/Security/help/Get-AzSecuritySqlVulnerabilityAssessmentScanResult.md @@ -54,12 +54,12 @@ RuleMetadata : { Severity: High Category: AuthenticationAndAuthorization Rule type: NegativeList - Title: Execute permissions on xp_cmdshell from all users (except dbo) should be revoked. - Description: The xp_cmdshell extended stored procedure spawns a Windows command shell, passing in a string for execution. This rule checks that no users (except users with the CONTROL SERVER permission like members of the sysadmin server role) have permission to execute the xp_cmdshell ext - ended stored procedure. - Rationale: The xp_cmdshell extended stored procedure is a very powerful tool, but because of that, it is crucial that access to xp_cmdshell be tightly controlled. By default, only users with the CONTROL SERVER permission like members of the sysadmin server role can execute this extended - stored procedure. When first enabled, xp_cmdshell has the same security context as the SQL Server service account. The SQL Server service account is often more privileged than necessary for the work being performed by the process created by xp_cmdshell. As such, malicious users can attempt - to elevate their privileges by using xp_cmdshell. See https://docs.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/xp-cmdshell-transact-sql for more information on xp_cmdshell. + Title: Execute permissions on xp_cmdshell from all users (except dbo) should be revoked. + Description: The xp_cmdshell extended stored procedure spawns a Windows command shell, passing in a string for execution. This rule checks that no users (except users with the CONTROL SERVER permission like members of the sysadmin server role) have permission to execute the xp_cmdshell ext + ended stored procedure. + Rationale: The xp_cmdshell extended stored procedure is a very powerful tool, but because of that, it is crucial that access to xp_cmdshell be tightly controlled. By default, only users with the CONTROL SERVER permission like members of the sysadmin server role can execute this extended + stored procedure. When first enabled, xp_cmdshell has the same security context as the SQL Server service account. The SQL Server service account is often more privileged than necessary for the work being performed by the process created by xp_cmdshell. As such, malicious users can attempt  + to elevate their privileges by using xp_cmdshell. See https://docs.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/xp-cmdshell-transact-sql for more information on xp_cmdshell. Query check: { Query: @@ -146,20 +146,20 @@ RuleMetadata : { Category: AuthenticationAndAuthorization Rule type: NegativeList Title: - Execute permissions on xp_cmdshell from all users (except dbo) should be revoked. - Description: The xp_cmdshell extended stored procedure spawns a Windows command shell, passin - g in a string for execution. This rule checks that no users (except users with the CONTROL SER - VER permission like members of the sysadmin server role) have permission to execute the xp_cmd - shell extended stored procedure. - Rationale: The xp_cmdshell extended stored procedure is a very powerful tool, but because o - f that, it is crucial that access to xp_cmdshell be tightly controlled. By default, only + Execute permissions on xp_cmdshell from all users (except dbo) should be revoked. + Description: The xp_cmdshell extended stored procedure spawns a Windows command shell, passin + g in a string for execution. This rule checks that no users (except users with the CONTROL SER + VER permission like members of the sysadmin server role) have permission to execute the xp_cmd + shell extended stored procedure. + Rationale: The xp_cmdshell extended stored procedure is a very powerful tool, but because o + f that, it is crucial that access to xp_cmdshell be tightly controlled. By default, only users with the CONTROL SERVER permission like members of the sysadmin server role can execute - this extended stored procedure. When first enabled, xp_cmdshell has the same security context - as the SQL Server service account. The SQL Server service account is often more privileged tha - n necessary for the work being performed by the process created by xp_cmdshell. As such, malic - ious users can attempt to elevate their privileges by using xp_cmdshell. See https://docs.micr - osoft.com/en-us/sql/relational-databases/system-stored-procedures/xp-cmdshell-transact-sql for - more information on xp_cmdshell. + this extended stored procedure. When first enabled, xp_cmdshell has the same security context  + as the SQL Server service account. The SQL Server service account is often more privileged tha + n necessary for the work being performed by the process created by xp_cmdshell. As such, malic + ious users can attempt to elevate their privileges by using xp_cmdshell. See https://docs.micr + osoft.com/en-us/sql/relational-databases/system-stored-procedures/xp-cmdshell-transact-sql for +  more information on xp_cmdshell. Query check: { Query: