Skip to content

Commit 1ce9108

Browse files
authored
Merge pull request #8574 from aashish1987/master
Add support for Custom Policies for Guest Configuration cmdlets
2 parents cc37f26 + e28fdb5 commit 1ce9108

26 files changed

+52570
-1272
lines changed

src/GuestConfiguration/GuestConfiguration.Test/GuestConfiguration.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</PropertyGroup>
1212

1313
<ItemGroup>
14-
<PackageReference Include="Microsoft.Azure.Management.GuestConfiguration" Version="1.0.0" />
14+
<PackageReference Include="Microsoft.Azure.Management.GuestConfiguration" Version="1.1.0" />
1515
</ItemGroup>
1616

1717
</Project>

src/GuestConfiguration/GuestConfiguration.Test/ScenarioTests/GetVmGuestPolicyStatusHistoryTests.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,33 @@ public void ShowOnlyChangeSwitchVmNameScope()
5959
{
6060
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatusHistory-ShowOnlyChangeSwitch-VmNameScope");
6161
}
62+
63+
[Fact]
64+
[Trait(Category.AcceptanceType, Category.CheckIn)]
65+
public void VmNameScope_Custom()
66+
{
67+
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatusHistory-VmNameScope_Custom");
68+
}
69+
70+
[Fact]
71+
[Trait(Category.AcceptanceType, Category.CheckIn)]
72+
public void InitiativeIdScope_Custom()
73+
{
74+
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatusHistory-InitiativeIdScope_Custom");
75+
}
76+
77+
[Fact]
78+
[Trait(Category.AcceptanceType, Category.CheckIn)]
79+
public void InitiativeNameScope_Custom()
80+
{
81+
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatusHistory-InitiativeNameScope_Custom");
82+
}
83+
84+
[Fact]
85+
[Trait(Category.AcceptanceType, Category.CheckIn)]
86+
public void ShowOnlyChangeSwitchVmNameScope_Custom()
87+
{
88+
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatusHistory-ShowOnlyChangeSwitch-VmNameScope_Custom");
89+
}
6290
}
6391
}

src/GuestConfiguration/GuestConfiguration.Test/ScenarioTests/GetVmGuestPolicyStatusHistoryTests.ps1

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,20 @@ function Get-AzVMGuestPolicyStatusHistory-VmNameScope
2626
Assert-True { $historicalStatuses.Count -gt 0 }
2727
}
2828

29+
<#
30+
.SYNOPSIS
31+
Get guest configuration policy status history by Vm name scope
32+
#>
33+
function Get-AzVMGuestPolicyStatusHistory-VmNameScope_Custom
34+
{
35+
$rgName = "amits-test"
36+
$vmName = "amits-winser6"
37+
38+
$historicalStatuses = Get-AzVMGuestPolicyStatusHistory -ResourceGroupName $rgName -VMName $vmName
39+
Assert-NotNull $historicalStatuses
40+
Assert-True { $historicalStatuses.Count -gt 0 }
41+
}
42+
2943
<#
3044
.SYNOPSIS
3145
Get guest configuration policy status history by Initiative id scope
@@ -41,6 +55,21 @@ function Get-AzVMGuestPolicyStatusHistory-InitiativeIdScope
4155
Assert-True { $historicalStatuses.Count -gt 0 }
4256
}
4357

58+
<#
59+
.SYNOPSIS
60+
Get guest configuration policy status history by Initiative id scope
61+
#>
62+
function Get-AzVMGuestPolicyStatusHistory-InitiativeIdScope_Custom
63+
{
64+
$rgName = "amits-test"
65+
$vmName = "amits-winser6"
66+
$initiativeId = "/subscriptions/b5e4748c-f69a-467c-8749-e2f9c8cd3db0/providers/Microsoft.Authorization/policySetDefinitions/8174929b-2752-46af-9167-89d2d6780439"
67+
68+
$historicalStatuses = Get-AzVMGuestPolicyStatusHistory -ResourceGroupName $rgName -VMName $vmName -InitiativeId $initiativeId
69+
Assert-NotNull $historicalStatuses
70+
Assert-True { $historicalStatuses.Count -gt 0 }
71+
}
72+
4473
<#
4574
.SYNOPSIS
4675
Get guest configuration policy status history by Initiative name scope
@@ -56,6 +85,21 @@ function Get-AzVMGuestPolicyStatusHistory-InitiativeNameScope
5685
Assert-True { $historicalStatuses.Count -gt 0 }
5786
}
5887

88+
<#
89+
.SYNOPSIS
90+
Get guest configuration policy status history by Initiative name scope
91+
#>
92+
function Get-AzVMGuestPolicyStatusHistory-InitiativeNameScope_Custom
93+
{
94+
$rgName = "amits-test"
95+
$vmName = "amits-winser6"
96+
$initiativeName = "8174929b-2752-46af-9167-89d2d6780439"
97+
98+
$historicalStatuses = Get-AzVMGuestPolicyStatusHistory -ResourceGroupName $rgName -VMName $vmName -InitiativeName $initiativeName
99+
Assert-NotNull $historicalStatuses
100+
Assert-True { $historicalStatuses.Count -gt 0 }
101+
}
102+
59103
<#
60104
.SYNOPSIS
61105
Get guest configuration policy by vmName scope, using ShowOnlyChange switch
@@ -65,6 +109,20 @@ function Get-AzVMGuestPolicyStatusHistory-ShowOnlyChangeSwitch-VmNameScope
65109
$rgName = "vivga"
66110
$vmName = "Viv1809SDDC"
67111

112+
$historicalStatuses = Get-AzVMGuestPolicyStatusHistory -ResourceGroupName $rgName -VMName $vmName -ShowOnlyChange
113+
Assert-NotNull $historicalStatuses
114+
Assert-True { $historicalStatuses.Count -gt 0 }
115+
}
116+
117+
<#
118+
.SYNOPSIS
119+
Get guest configuration policy by vmName scope, using ShowOnlyChange switch
120+
#>
121+
function Get-AzVMGuestPolicyStatusHistory-ShowOnlyChangeSwitch-VmNameScope_Custom
122+
{
123+
$rgName = "amits-test"
124+
$vmName = "amits-winser6"
125+
68126
$historicalStatuses = Get-AzVMGuestPolicyStatusHistory -ResourceGroupName $rgName -VMName $vmName -ShowOnlyChange
69127
Assert-NotNull $historicalStatuses
70128
Assert-True { $historicalStatuses.Count -gt 0 }

src/GuestConfiguration/GuestConfiguration.Test/ScenarioTests/GetVmGuestPolicyStatusTests.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,27 @@ public void VmNameScope()
3939
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatus-VmNameScope");
4040
}
4141

42+
[Fact]
43+
[Trait(Category.AcceptanceType, Category.CheckIn)]
44+
public void VmNameScope_Custom()
45+
{
46+
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatus-VmNameScope_Custom");
47+
}
48+
4249
[Fact]
4350
[Trait(Category.AcceptanceType, Category.CheckIn)]
4451
public void InitiativeIdScope()
4552
{
4653
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatus-InitiativeIdScope");
4754
}
4855

56+
[Fact]
57+
[Trait(Category.AcceptanceType, Category.CheckIn)]
58+
public void InitiativeIdScope_Custom()
59+
{
60+
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatus-InitiativeIdScope_Custom");
61+
}
62+
4963
[Fact]
5064
[Trait(Category.AcceptanceType, Category.CheckIn)]
5165
public void InitiativeNameScope()
@@ -55,9 +69,23 @@ public void InitiativeNameScope()
5569

5670
[Fact]
5771
[Trait(Category.AcceptanceType, Category.CheckIn)]
72+
public void InitiativeNameScope_Custom()
73+
{
74+
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatus-InitiativeNameScope_Custom");
75+
}
76+
77+
[Fact]
78+
[Trait(Category.AcceptanceType, Category.CheckIn)]
5879
public void ReportIdScope()
5980
{
6081
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatus-ReportIdScope");
6182
}
83+
84+
[Fact]
85+
[Trait(Category.AcceptanceType, Category.CheckIn)]
86+
public void ReportIdScope_Custom()
87+
{
88+
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatus-ReportIdScope_Custom");
89+
}
6290
}
6391
}

src/GuestConfiguration/GuestConfiguration.Test/ScenarioTests/GetVmGuestPolicyStatusTests.ps1

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,20 @@ function Get-AzVMGuestPolicyStatus-VmNameScope
2626
Assert-True { $reports.Count -gt 0 }
2727
}
2828

29+
<#
30+
.SYNOPSIS
31+
Get guest configuration policy report by Vm name scope for custom policy
32+
#>
33+
function Get-AzVMGuestPolicyStatus-VmNameScope_Custom
34+
{
35+
$rgName = "amits-test"
36+
$vmName = "amits-winser6"
37+
38+
$reports = Get-AzVMGuestPolicyStatus -ResourceGroupName $rgName -VMName $vmName
39+
Assert-NotNull $reports
40+
Assert-True { $reports.Count -gt 0 }
41+
}
42+
2943
<#
3044
.SYNOPSIS
3145
Get guest configuration policy report by Initiative id scope
@@ -41,6 +55,21 @@ function Get-AzVMGuestPolicyStatus-InitiativeIdScope
4155
Assert-True { $reports.Count -gt 0 }
4256
}
4357

58+
<#
59+
.SYNOPSIS
60+
Get guest configuration custom policy report by Initiative id scope
61+
#>
62+
function Get-AzVMGuestPolicyStatus-InitiativeIdScope_Custom
63+
{
64+
$rgName = "amits-test"
65+
$vmName = "amits-winser6"
66+
$initiativeId = "/subscriptions/b5e4748c-f69a-467c-8749-e2f9c8cd3db0/providers/Microsoft.Authorization/policySetDefinitions/8174929b-2752-46af-9167-89d2d6780439"
67+
68+
$reports = Get-AzVMGuestPolicyStatus -ResourceGroupName $rgName -VMName $vmName -InitiativeId $initiativeId
69+
Assert-NotNull $reports
70+
Assert-True { $reports.Count -gt 0 }
71+
}
72+
4473
<#
4574
.SYNOPSIS
4675
Get guest configuration policy report by Initiative name scope
@@ -56,6 +85,21 @@ function Get-AzVMGuestPolicyStatus-InitiativeNameScope
5685
Assert-True { $reports.Count -gt 0 }
5786
}
5887

88+
<#
89+
.SYNOPSIS
90+
Get guest configuration custom policy report by Initiative name scope
91+
#>
92+
function Get-AzVMGuestPolicyStatus-InitiativeNameScope_Custom
93+
{
94+
$rgName = "amits-test"
95+
$vmName = "amits-winser6"
96+
$initiativeName = "8174929b-2752-46af-9167-89d2d6780439"
97+
98+
$reports = Get-AzVMGuestPolicyStatus -ResourceGroupName $rgName -VMName $vmName -InitiativeName $initiativeName
99+
Assert-NotNull $reports
100+
Assert-True { $reports.Count -gt 0 }
101+
}
102+
59103
<#
60104
.SYNOPSIS
61105
Get guest configuration policy by ReportId scope
@@ -74,3 +118,22 @@ function Get-AzVMGuestPolicyStatus-ReportIdScope
74118
$report = Get-AzVMGuestPolicyStatus -ReportId $Id
75119
Assert-NotNull $report
76120
}
121+
122+
<#
123+
.SYNOPSIS
124+
Get guest configuration custom policy by ReportId scope
125+
#>
126+
function Get-AzVMGuestPolicyStatus-ReportIdScope_Custom
127+
{
128+
$rgName = "amits-test"
129+
$vmName = "amits-winser6"
130+
$initiativeName = "8174929b-2752-46af-9167-89d2d6780439"
131+
$reports = Get-AzVMGuestPolicyStatus -ResourceGroupName $rgName -VMName $vmName -InitiativeName $initiativeName
132+
Assert-NotNull $reports
133+
Assert-True { $reports.Count -gt 0 }
134+
135+
$Id= $reports[0].ReportId;
136+
137+
$report = Get-AzVMGuestPolicyStatus -ReportId $Id
138+
Assert-NotNull $report
139+
}

0 commit comments

Comments
 (0)