@@ -27,7 +27,7 @@ Gets test resource group group name
27
27
#>
28
28
function Get-TestResourceGroupName
29
29
{
30
- " jilimpolicytest2 "
30
+ " cleanupservice "
31
31
}
32
32
33
33
<#
@@ -36,7 +36,7 @@ Gets test resource id
36
36
#>
37
37
function Get-TestResourceId
38
38
{
39
- " /subscriptions/d0610b27-9663-4c05-89f8-5b4be01e86a5 /resourcegroups/govintpolicyrp /providers/microsoft.network/trafficmanagerprofiles/gov-int-policy-rp "
39
+ " /subscriptions/0b40be06-04e8-4f70-abde-a502b2646fe8 /resourcegroups/cleanupservice /providers/Microsoft.KeyVault/vaults/kv12-cleanupservice "
40
40
}
41
41
42
42
<#
@@ -45,7 +45,7 @@ Gets test policy set definition name
45
45
#>
46
46
function Get-TestPolicySetDefinitionName
47
47
{
48
- " 875cf75e-49c3-47f8-ab8d-89ba3d2311a0 "
48
+ " 716ef2c9-4404-4673-8609-f984d58c417d "
49
49
}
50
50
51
51
<#
@@ -54,7 +54,7 @@ Gets test policy definition name
54
54
#>
55
55
function Get-TestPolicyDefinitionName
56
56
{
57
- " 24813039-7534-408a-9842-eb99f45721b1 "
57
+ " policy2 "
58
58
}
59
59
60
60
<#
@@ -63,7 +63,7 @@ Gets test policy assignment name
63
63
#>
64
64
function Get-TestPolicyAssignmentName
65
65
{
66
- " f54e881207924ca8b2e39f6a "
66
+ " SecurityCenterBuiltIn "
67
67
}
68
68
69
69
<#
@@ -72,7 +72,7 @@ Gets test resource group group name for resource group level policy assignment (
72
72
#>
73
73
function Get-TestResourceGroupNameForPolicyAssignmentEvents
74
74
{
75
- " jilimpolicytest2 "
75
+ " cleanupservice "
76
76
}
77
77
78
78
<#
@@ -81,7 +81,16 @@ Gets test policy assignment name (resource group level) (for event tests)
81
81
#>
82
82
function Get-TestPolicyAssignmentNameResourceGroupLevelEvents
83
83
{
84
- " e9860612d8ec4a469f59af06"
84
+ " 568e500984414fbe8a4f10d0"
85
+ }
86
+
87
+ <#
88
+ . SYNOPSIS
89
+ Gets test policy definition name for events
90
+ #>
91
+ function Get-TestPolicyDefinitionNameForEvents
92
+ {
93
+ " d994a92a-7669-4735-9950-bdcc326f32e4"
85
94
}
86
95
87
96
<#
@@ -90,7 +99,7 @@ Gets test resource group group name for resource group level policy assignment (
90
99
#>
91
100
function Get-TestResourceGroupNameForPolicyAssignmentStates
92
101
{
93
- " jilimpolicytest2 "
102
+ " cleanupservice "
94
103
}
95
104
96
105
<#
@@ -99,7 +108,7 @@ Gets test policy assignment name (resource group level) (for state tests)
99
108
#>
100
109
function Get-TestPolicyAssignmentNameResourceGroupLevelStates
101
110
{
102
- " e9860612d8ec4a469f59af06 "
111
+ " 147b065f2a0f409ca31325c7 "
103
112
}
104
113
105
114
<#
@@ -108,7 +117,7 @@ Gets test query interval start
108
117
#>
109
118
function Get-TestQueryIntervalStart
110
119
{
111
- " 2019-01-20 00:00:00Z"
120
+ " 2019-12-01 00:00:00Z"
112
121
}
113
122
114
123
<#
@@ -117,7 +126,7 @@ Gets test query interval end
117
126
#>
118
127
function Get-TestQueryIntervalEnd
119
128
{
120
- " 2019-04-15 00:00:00Z"
129
+ " 2019-12-06 00:00:00Z"
121
130
}
122
131
123
132
<#
@@ -126,7 +135,7 @@ Gets the policy assignment used in remediation tests at subscription level and b
126
135
#>
127
136
function Get-TestRemediationSubscriptionPolicyAssignmentId
128
137
{
129
- " /subscriptions/d0610b27-9663-4c05-89f8-5b4be01e86a5 /providers/Microsoft.Authorization/policyAssignments/2deae24764b447c29af7c309 "
138
+ " /subscriptions/f67cc918-f64f-4c3f-aa24-a855465f9d41 /providers/Microsoft.Authorization/policyAssignments/fcddeb6113ec43798567dce2 "
130
139
}
131
140
132
141
<#
@@ -135,7 +144,7 @@ Gets the policy assignment used in remediation tests at management group scope
135
144
#>
136
145
function Get-TestRemediationMgPolicyAssignmentId
137
146
{
138
- " /providers/Microsoft.Management/managementGroups/PolicyUIMG /providers/Microsoft.Authorization/policyAssignments/326b090398a649e3858e3f23 "
147
+ " /providers/Microsoft.Management/managementGroups/AzGovPerfTest /providers/Microsoft.Authorization/policyAssignments/d80d743b97874fd3bfd1d539 "
139
148
}
140
149
141
150
<#
@@ -249,8 +258,10 @@ function Validate-PolicyStateSummary
249
258
Assert-NotNullOrEmpty $policyAssignmentSummary.PolicyAssignmentId
250
259
251
260
Assert-NotNull $policyAssignmentSummary.Results
252
- Assert-NotNull $policyAssignmentSummary.Results.NonCompliantResources
253
- Assert-NotNull $policyAssignmentSummary.Results.NonCompliantPolicies
261
+ Validate- SummaryResults - results:$policyAssignmentSummary.Results - nonCompliantPoliciesAssertNull:$false
262
+ Assert-NotNull $policyAssignmentSummary.PolicyDefinitions
263
+ Assert-NotNull $policyAssignmentSummary.PolicyGroups
264
+ Assert-True { $policyAssignmentSummary.PolicyGroups.Count -gt 0 }
254
265
255
266
Assert-NotNull $policyAssignmentSummary.PolicyDefinitions
256
267
if ($policyAssignmentSummary.PolicyDefinitions.Count -gt 0 )
@@ -260,18 +271,42 @@ function Validate-PolicyStateSummary
260
271
Foreach ($policyDefinitionSummary in $policyAssignmentSummary.PolicyDefinitions )
261
272
{
262
273
Assert-NotNull $policyDefinitionSummary
263
-
264
274
Assert-NotNullOrEmpty $policyDefinitionSummary.PolicyDefinitionId
265
275
Assert-NotNullOrEmpty $policyDefinitionSummary.Effect
266
276
277
+ Assert-NotNull $policyDefinitionSummary.PolicyDefinitionGroupNames
267
278
Assert-NotNull $policyDefinitionSummary.Results
268
- Assert-NotNull $policyDefinitionSummary.Results.NonCompliantResources
269
- Assert-Null $policyDefinitionSummary.Results.NonCompliantPolicies
279
+ Validate- SummaryResults - results:$policyDefinitionSummary.Results
270
280
}
271
281
}
272
282
}
273
283
}
274
284
285
+ <#
286
+ . SYNOPSIS
287
+ Validates a summary results
288
+ #>
289
+ function Validate-SummaryResults
290
+ {
291
+ param ([Microsoft.Azure.Commands.PolicyInsights.Models.SummaryResults ] $results ,
292
+ [switch ]$nonCompliantPoliciesAssertNull = $true
293
+ )
294
+
295
+ Assert-NotNull $results.NonCompliantResources
296
+ if ($nonCompliantPoliciesAssertNull )
297
+ {
298
+ Assert-Null $results.NonCompliantPolicies
299
+ }
300
+ else
301
+ {
302
+ Assert-NotNull $results.NonCompliantPolicies
303
+ }
304
+ Assert-NotNull $results.ResourceDetails
305
+ Assert-NotNull $results.PolicyDetails
306
+ Assert-True { $results.PolicyDetails.Count -gt 0 }
307
+ Assert-NotNull $results.PolicyGroupDetails
308
+ }
309
+
275
310
<#
276
311
. SYNOPSIS
277
312
Validates a remediation
@@ -309,6 +344,32 @@ function Validate-RemediationDeployment
309
344
Assert-NotNullOrEmpty $deployment.ResourceLocation
310
345
}
311
346
347
+ <#
348
+ . SYNOPSIS
349
+ Validates a policy metadata resource
350
+ #>
351
+ function Validate-PolicyMetadata
352
+ {
353
+ param ([Microsoft.Azure.Commands.PolicyInsights.Models.PSPolicyMetadata ]$policyMetadata ,
354
+ [switch ]$validateExtendedProperties = $false )
355
+
356
+ Assert-NotNull $policyMetadata
357
+
358
+ Assert-NotNull $policyMetadata.Name
359
+ Assert-AreEqual " Microsoft.PolicyInsights/policyMetadata" $policyMetadata.Type
360
+ Assert-True { $policyMetadata.Id -like " /providers/Microsoft.PolicyInsights/policyMetadata/" + $policyMetadata.Name }
361
+
362
+ Assert-NotNull $policyMetadata.Owner
363
+ Assert-NotNull $policyMetadata.Title
364
+ Assert-NotNull $policyMetadata.Category
365
+ Assert-NotNull $policyMetadata.MetadataId
366
+ if ($validateExtendedProperties )
367
+ {
368
+ Assert-NotNull $policyMetadata.Requirements
369
+ Assert-NotNull $policyMetadata.Description
370
+ }
371
+ }
372
+
312
373
<#
313
374
. SYNOPSIS
314
375
Validates a string is not null or empty
0 commit comments