-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathRunTest-CICD.ps1
More file actions
50 lines (45 loc) · 1.83 KB
/
RunTest-CICD.ps1
File metadata and controls
50 lines (45 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#region Install required modules
if ( -not ( Get-Module -ListAvailable Az.Accounts ) ) {
Install-Module Az.Accounts -Force
}
#endregion
#region Switch to correct subscription
Set-AzContext -SubscriptionId $Env:subscriptionId | Out-Null
#endregion
<#
When connecting a GitHub or Azure DevOps repository to Microsoft Sentinel, the artifacts are organized in folders named
\AnalyticsRule
\AutomationRule
\HuntingQuery
\Parser
\Playbook
\Workbook
Use, where available, the tests with the tag suffix "-CICD" instead of the normal tests.
Those tests will automatically parse the ARM template files in your configuration root and Pester uses this information
to dynamically create the tests. This way you can easily add new configuration without having to modify the tests.
#>
$configRunContainer = @(
# Add the CI/CD configuration path as parameter to all CI/CD tests
New-PesterContainer -Path "*.Tests.ps1" -Data @{
workspaceName = $Env:workspaceName
resourceGroup = $Env:resourceGroupName
subscriptionId = $Env:subscriptionId
# This is the path to the root of your Sentinel configuration files
CICDPathRoot = $PWD
}
)
$config = New-PesterConfiguration -Hashtable @{
Filter = @{
# Use the filter configuration to only specify the tests
# This way you can easily remove e.g. specific dataconnectors from the test without mofiying the test itself
# You will always have to modify the tests.ps1 file if you would like to remove specific tables it change the target configuration
Tag = "AutomationRules-CICD", "AnalyticsRules-CICD", "Configuration"
}
TestResult = @{ Enabled = $true }
Run = @{
Exit = $false
Container = $configRunContainer
}
Output = @{ Verbosity = 'Detailed' }
}
Invoke-Pester -Configuration $config