Skip to content

Commit 92b7f74

Browse files
author
dicolanl
committed
v1 tests
1 parent b02b40d commit 92b7f74

File tree

56 files changed

+196
-4038
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+196
-4038
lines changed

src/SecurityInsights/SecurityInsights.Test/Properties/AssemblyInfo.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
// General Information about an assembly is controlled through the following
2121
// set of attributes. Change these attribute values to modify the information
2222
// associated with an assembly.
23-
[assembly: AssemblyTitle("Commands.Security.Test")]
23+
[assembly: AssemblyTitle("Commands.SecurityInsights.Test")]
2424
[assembly: AssemblyDescription("")]
2525
[assembly: AssemblyConfiguration("")]
2626
[assembly: AssemblyCompany("")]
27-
[assembly: AssemblyProduct("Commands.Security.Test")]
27+
[assembly: AssemblyProduct("Commands.SecurityInsights.Test")]
2828
[assembly: AssemblyCopyright("Copyright © 2018")]
2929
[assembly: AssemblyTrademark("")]
3030
[assembly: AssemblyCulture("")]
@@ -35,7 +35,7 @@
3535
[assembly: ComVisible(false)]
3636

3737
// The following GUID is for the ID of the typelib if this project is exposed to COM
38-
[assembly: Guid("9f866d20-059a-4dab-af42-18e37f503e30")]
38+
[assembly: Guid("CA24A45A-9D2D-4BBD-9F71-EF5599ADAD96")]
3939

4040
// Version information for an assembly consists of the following four values:
4141
//

src/SecurityInsights/SecurityInsights.Test/ScenarioTests/SecurityTaskTests.cs renamed to src/SecurityInsights/SecurityInsights.Test/ScenarioTests/Actions/ActionsTests.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
using Microsoft.WindowsAzure.Commands.ScenarioTest;
1818
using Xunit;
1919

20-
namespace Microsoft.Azure.Commands.Security.Test.ScenarioTests
20+
namespace Microsoft.Azure.Commands.SecurityInsights.Test.ScenarioTests
2121
{
22-
public class SecurityTaskTests
22+
public class ActionsTests
2323
{
2424
private readonly XunitTracingInterceptor _logger;
2525

26-
public SecurityTaskTests(Xunit.Abstractions.ITestOutputHelper output)
26+
public ActionsTests(Xunit.Abstractions.ITestOutputHelper output)
2727
{
2828
_logger = new XunitTracingInterceptor(output);
2929
XunitTracingInterceptor.AddToContext(_logger);
@@ -32,37 +32,37 @@ public SecurityTaskTests(Xunit.Abstractions.ITestOutputHelper output)
3232

3333
[Fact]
3434
[Trait(Category.AcceptanceType, Category.CheckIn)]
35-
public void GetSubscriptionScope()
35+
public void ListByAlertRule()
3636
{
37-
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmSecurityTask-SubscriptionScope");
37+
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzSentinelAlertRuleAction-ListByAlertRule");
3838
}
3939

4040
[Fact]
4141
[Trait(Category.AcceptanceType, Category.CheckIn)]
42-
public void GetResourceGroupScope()
42+
public void GetAction()
4343
{
44-
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmSecurityTask-ResourceGroupScope");
44+
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzSentinelAlertRuleAction-GetAction");
4545
}
4646

4747
[Fact]
4848
[Trait(Category.AcceptanceType, Category.CheckIn)]
49-
public void GetResourceId()
49+
public void CreateAction()
5050
{
51-
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmSecurityTask-ResourceId");
51+
TestController.NewInstance.RunPowerShellTest(_logger, "New-AzSentinelAlertRuleAction-Create");
5252
}
5353

5454
[Fact]
5555
[Trait(Category.AcceptanceType, Category.CheckIn)]
56-
public void GetSubscriptionLevelResource()
56+
public void UpdateAction()
5757
{
58-
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmSecurityTask-SubscriptionLevelResource");
58+
TestController.NewInstance.RunPowerShellTest(_logger, "Set-AzSentinelAlertRuleAction-Update");
5959
}
6060

6161
[Fact]
6262
[Trait(Category.AcceptanceType, Category.CheckIn)]
63-
public void GetResourceGroupLevelResource()
63+
public void RemoveAction()
6464
{
65-
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmSecurityTask-ResourceGroupLevelResource");
65+
TestController.NewInstance.RunPowerShellTest(_logger, "Remove-AzSentinelAlertRuleAction-Delete");
6666
}
6767
}
6868
}
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
# ----------------------------------------------------------------------------------
2+
#
3+
# Copyright Microsoft Corporation
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
# ----------------------------------------------------------------------------------
14+
15+
<#
16+
.SYNOPSIS
17+
List Actions by Alert Rule
18+
#>
19+
function Get-AzSentineAlertRulelAction-ListByAlertRule
20+
{
21+
22+
$LogicAppResourceId = "/subscriptions/1c61ccbf-70b3-45a3-a1fb-848ce46d70a6/resourceGroups/ndicola-azsposh/providers/Microsoft.Logic/workflows/Block-AADUser"
23+
$LogicAppResourceId2 = "/subscriptions/1c61ccbf-70b3-45a3-a1fb-848ce46d70a6/resourceGroups/ndicola-azsposh/providers/Microsoft.Logic/workflows/Get-MDATPInvestigationPackage"
24+
25+
#Create Alert Rule
26+
$alertRule = New-AzSentinelAlertRule -ResourceGroupName (Get-TestResourceGroupName) -WorkspaceName (Get-TestWorkspaceName) -Type Scheduled -Enabled $true -DisplayName "PoshModuleTest" -SuprressionDuration "PT5H" -SuprressionEnabled $false
27+
#Create Alert Rule Action
28+
$action = New-AzSentinelAlertRuleAction -ResourceGroupName (Get-TestResourceGroupName) -WorkspaceName (Get-TestWorkspaceName) -LogicAppResourceId $LogicAppResourceId
29+
#Create Alert Rule Action
30+
$action2 = New-AzSentinelAlertRuleAction -ResourceGroupName (Get-TestResourceGroupName) -WorkspaceName (Get-TestWorkspaceName) -LogicAppResourceId $LogicAppResourceId2
31+
32+
#Get Alert Rule Actions
33+
$actions = Get-AzSentinelAlertRuleAction -ResourceGroupName (Get-TestResourceGroupName) -WorkspaceName (Get-TestWorkspaceName) -AlertRuleId ($alertRule.Name)
34+
# Validate
35+
Validate-Actions $actions
36+
37+
#Cleanup
38+
Remove-AzSentinelAlertRule -ResourceGroupName (Get-TestResourceGroupName) -WorkspaceName (Get-TestWorkspaceName) -AlertRuleId ($alertRule.Name)
39+
}
40+
41+
<#
42+
.SYNOPSIS
43+
Get Action
44+
#>
45+
function Get-AzSentinelAlertRuleAction-GetAction
46+
{
47+
48+
$LogicAppResourceId = "/subscriptions/1c61ccbf-70b3-45a3-a1fb-848ce46d70a6/resourceGroups/ndicola-azsposh/providers/Microsoft.Logic/workflows/Block-AADUser"
49+
50+
#Create Alert Rule
51+
$alertRule = New-AzSentinelAlertRule -ResourceGroupName (Get-TestResourceGroupName) -WorkspaceName (Get-TestWorkspaceName) -Type Scheduled -Enabled $true -DisplayName "PoshModuleTest" -SuprressionDuration "PT5H" -SuprressionEnabled $false
52+
#Create Alert Rule Action
53+
$action = New-AzSentinelAlertRuleAction -ResourceGroupName (Get-TestResourceGroupName) -WorkspaceName (Get-TestWorkspaceName) -LogicAppResourceId $LogicAppResourceId
54+
55+
#Get Alert Rule Action
56+
$action = Get-AzSentinelAlertRuleAction -ResourceGroupName (Get-TestResourceGroupName) -WorkspaceName (Get-TestWorkspaceName) -AlertRuleId ($alertRule.Name) -ActionId ($action.Name)
57+
# Validate
58+
Validate-Action $action
59+
60+
#Cleanup
61+
Remove-AzSentinelAlertRule -ResourceGroupName (Get-TestResourceGroupName) -WorkspaceName (Get-TestWorkspaceName) -AlertRuleId ($alertRule.Name)
62+
}
63+
64+
<#
65+
.SYNOPSIS
66+
Create Action
67+
#>
68+
function New-AzSentinelAlertRuleAction-Create
69+
{
70+
$LogicAppResourceId = "/subscriptions/1c61ccbf-70b3-45a3-a1fb-848ce46d70a6/resourceGroups/ndicola-azsposh/providers/Microsoft.Logic/workflows/Block-AADUser"
71+
72+
#Create Alert Rule
73+
$alertRule = New-AzSentinelAlertRule -ResourceGroupName (Get-TestResourceGroupName) -WorkspaceName (Get-TestWorkspaceName) -Type Scheduled -Enabled $true -DisplayName "PoshModuleTest" -SuprressionDuration "PT5H" -SuprressionEnabled $false
74+
#Create Alert Rule Action
75+
$action = New-AzSentinelAlertRuleAction -ResourceGroupName (Get-TestResourceGroupName) -WorkspaceName (Get-TestWorkspaceName) -LogicAppResourceId $LogicAppResourceId
76+
77+
#Validate
78+
Validate-Action $action
79+
80+
#Cleanup
81+
Remove-AzSentinelAlertRule -ResourceGroupName (Get-TestResourceGroupName) -WorkspaceName (Get-TestWorkspaceName) -AlertRuleId ($alertRule.Name)
82+
}
83+
84+
<#
85+
.SYNOPSIS
86+
Update Action
87+
#>
88+
function Set-AzSentinelAlertRuleAction-Update
89+
{
90+
$LogicAppResourceId = "/subscriptions/1c61ccbf-70b3-45a3-a1fb-848ce46d70a6/resourceGroups/ndicola-azsposh/providers/Microsoft.Logic/workflows/Block-AADUser"
91+
$LogicAppResourceId2 = "/subscriptions/1c61ccbf-70b3-45a3-a1fb-848ce46d70a6/resourceGroups/ndicola-azsposh/providers/Microsoft.Logic/workflows/Get-MDATPInvestigationPackage"
92+
93+
#Create Alert Rule
94+
$alertRule = New-AzSentinelAlertRule -ResourceGroupName (Get-TestResourceGroupName) -WorkspaceName (Get-TestWorkspaceName) -Type Scheduled -Enabled $true -DisplayName "PoshModuleTest" -SuprressionDuration "PT5H" -SuprressionEnabled $false
95+
#Create Alert Rule Action
96+
$action = New-AzSentinelAlertRuleAction -ResourceGroupName (Get-TestResourceGroupName) -WorkspaceName (Get-TestWorkspaceName) -LogicAppResourceId $LogicAppResourceId
97+
98+
#update action
99+
$action = Set=AzSentinelAlertRuleAction -ResourceGroupName (Get-TestResourceGroupName) -WorkspaceName (Get-TestWorkspaceName) -LogicAppResourceId $LogicAppResourceId2
100+
101+
# Validate
102+
Validate-Action $action
103+
104+
#Cleanup
105+
Remove-AzSentinelAlertRule -ResourceGroupName (Get-TestResourceGroupName) -WorkspaceName (Get-TestWorkspaceName) -AlertRuleId ($alertRule.Name)
106+
}
107+
108+
<#
109+
.SYNOPSIS
110+
Delete Action
111+
#>
112+
function Remove-AzSentinelAlertRuleAction-Delete
113+
{
114+
$LogicAppResourceId = "/subscriptions/1c61ccbf-70b3-45a3-a1fb-848ce46d70a6/resourceGroups/ndicola-azsposh/providers/Microsoft.Logic/workflows/Block-AADUser"
115+
116+
#Create Alert Rule
117+
$alertRule = New-AzSentinelAlertRule -ResourceGroupName (Get-TestResourceGroupName) -WorkspaceName (Get-TestWorkspaceName) -Type Scheduled -Enabled $true -DisplayName "PoshModuleTest" -SuprressionDuration "PT5H" -SuprressionEnabled $false
118+
#Create Alert Rule Action
119+
$action = New-AzSentinelAlertRuleAction -ResourceGroupName (Get-TestResourceGroupName) -WorkspaceName (Get-TestWorkspaceName) -LogicAppResourceId $LogicAppResourceId
120+
Remove-AzSentinelAlertRuleAction -ResourceGroupName (Get-TestResourceGroupName) -WorkspaceName (Get-TestWorkspaceName) -ActionId ($action.Name)
121+
# Validate
122+
Validate-Action $action
123+
124+
#Cleanup
125+
Remove-AzSentinelAlertRule -ResourceGroupName (Get-TestResourceGroupName) -WorkspaceName (Get-TestWorkspaceName) -AlertRuleId ($alertRule.Name)
126+
}
127+
128+
<#
129+
.SYNOPSIS
130+
Validates a list of actions
131+
#>
132+
function Validate-Actions
133+
{
134+
param($actions)
135+
136+
Assert-True { $actions.Count -gt 0 }
137+
138+
Foreach($action in $actions)
139+
{
140+
Validate-Action $action
141+
}
142+
}
143+
144+
<#
145+
.SYNOPSIS
146+
Validates a single action
147+
#>
148+
function Validate-Action
149+
{
150+
param($action)
151+
152+
Assert-NotNull $action
153+
}

src/SecurityInsights/SecurityInsights.Test/ScenarioTests/AllowedConnectionTests.cs

Lines changed: 0 additions & 41 deletions
This file was deleted.

src/SecurityInsights/SecurityInsights.Test/ScenarioTests/AllowedConnectionTests.ps1

Lines changed: 0 additions & 76 deletions
This file was deleted.

src/SecurityInsights/SecurityInsights.Test/ScenarioTests/Common.ps1

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@ Gets test resource group name
1818
#>
1919
function Get-TestResourceGroupName
2020
{
21-
"myService1"
21+
"ndicola-azsposh"
22+
}
23+
24+
function Get-TestWorkspaceName
25+
{
26+
"azsposh"
2227
}
2328

2429
<#

0 commit comments

Comments
 (0)