Skip to content

Add support for Custom Policies for Guest Configuration cmdlets #8574

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Mar 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.GuestConfiguration" Version="1.0.0" />
<PackageReference Include="Microsoft.Azure.Management.GuestConfiguration" Version="1.1.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,33 @@ public void ShowOnlyChangeSwitchVmNameScope()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatusHistory-ShowOnlyChangeSwitch-VmNameScope");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void VmNameScope_Custom()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatusHistory-VmNameScope_Custom");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void InitiativeIdScope_Custom()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatusHistory-InitiativeIdScope_Custom");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void InitiativeNameScope_Custom()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatusHistory-InitiativeNameScope_Custom");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void ShowOnlyChangeSwitchVmNameScope_Custom()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatusHistory-ShowOnlyChangeSwitch-VmNameScope_Custom");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,20 @@ function Get-AzVMGuestPolicyStatusHistory-VmNameScope
Assert-True { $historicalStatuses.Count -gt 0 }
}

<#
.SYNOPSIS
Get guest configuration policy status history by Vm name scope
#>
function Get-AzVMGuestPolicyStatusHistory-VmNameScope_Custom
{
$rgName = "amits-test"
$vmName = "amits-winser6"

$historicalStatuses = Get-AzVMGuestPolicyStatusHistory -ResourceGroupName $rgName -VMName $vmName
Assert-NotNull $historicalStatuses
Assert-True { $historicalStatuses.Count -gt 0 }
}

<#
.SYNOPSIS
Get guest configuration policy status history by Initiative id scope
Expand All @@ -41,6 +55,21 @@ function Get-AzVMGuestPolicyStatusHistory-InitiativeIdScope
Assert-True { $historicalStatuses.Count -gt 0 }
}

<#
.SYNOPSIS
Get guest configuration policy status history by Initiative id scope
#>
function Get-AzVMGuestPolicyStatusHistory-InitiativeIdScope_Custom
{
$rgName = "amits-test"
$vmName = "amits-winser6"
$initiativeId = "/subscriptions/b5e4748c-f69a-467c-8749-e2f9c8cd3db0/providers/Microsoft.Authorization/policySetDefinitions/8174929b-2752-46af-9167-89d2d6780439"

$historicalStatuses = Get-AzVMGuestPolicyStatusHistory -ResourceGroupName $rgName -VMName $vmName -InitiativeId $initiativeId
Assert-NotNull $historicalStatuses
Assert-True { $historicalStatuses.Count -gt 0 }
}

<#
.SYNOPSIS
Get guest configuration policy status history by Initiative name scope
Expand All @@ -56,6 +85,21 @@ function Get-AzVMGuestPolicyStatusHistory-InitiativeNameScope
Assert-True { $historicalStatuses.Count -gt 0 }
}

<#
.SYNOPSIS
Get guest configuration policy status history by Initiative name scope
#>
function Get-AzVMGuestPolicyStatusHistory-InitiativeNameScope_Custom
{
$rgName = "amits-test"
$vmName = "amits-winser6"
$initiativeName = "8174929b-2752-46af-9167-89d2d6780439"

$historicalStatuses = Get-AzVMGuestPolicyStatusHistory -ResourceGroupName $rgName -VMName $vmName -InitiativeName $initiativeName
Assert-NotNull $historicalStatuses
Assert-True { $historicalStatuses.Count -gt 0 }
}

<#
.SYNOPSIS
Get guest configuration policy by vmName scope, using ShowOnlyChange switch
Expand All @@ -65,6 +109,20 @@ function Get-AzVMGuestPolicyStatusHistory-ShowOnlyChangeSwitch-VmNameScope
$rgName = "vivga"
$vmName = "Viv1809SDDC"

$historicalStatuses = Get-AzVMGuestPolicyStatusHistory -ResourceGroupName $rgName -VMName $vmName -ShowOnlyChange
Assert-NotNull $historicalStatuses
Assert-True { $historicalStatuses.Count -gt 0 }
}

<#
.SYNOPSIS
Get guest configuration policy by vmName scope, using ShowOnlyChange switch
#>
function Get-AzVMGuestPolicyStatusHistory-ShowOnlyChangeSwitch-VmNameScope_Custom
{
$rgName = "amits-test"
$vmName = "amits-winser6"

$historicalStatuses = Get-AzVMGuestPolicyStatusHistory -ResourceGroupName $rgName -VMName $vmName -ShowOnlyChange
Assert-NotNull $historicalStatuses
Assert-True { $historicalStatuses.Count -gt 0 }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,27 @@ public void VmNameScope()
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatus-VmNameScope");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void VmNameScope_Custom()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatus-VmNameScope_Custom");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void InitiativeIdScope()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatus-InitiativeIdScope");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void InitiativeIdScope_Custom()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatus-InitiativeIdScope_Custom");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void InitiativeNameScope()
Expand All @@ -55,9 +69,23 @@ public void InitiativeNameScope()

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void InitiativeNameScope_Custom()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatus-InitiativeNameScope_Custom");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void ReportIdScope()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatus-ReportIdScope");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void ReportIdScope_Custom()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzVMGuestPolicyStatus-ReportIdScope_Custom");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,20 @@ function Get-AzVMGuestPolicyStatus-VmNameScope
Assert-True { $reports.Count -gt 0 }
}

<#
.SYNOPSIS
Get guest configuration policy report by Vm name scope for custom policy
#>
function Get-AzVMGuestPolicyStatus-VmNameScope_Custom
{
$rgName = "amits-test"
$vmName = "amits-winser6"

$reports = Get-AzVMGuestPolicyStatus -ResourceGroupName $rgName -VMName $vmName
Assert-NotNull $reports
Assert-True { $reports.Count -gt 0 }
}

<#
.SYNOPSIS
Get guest configuration policy report by Initiative id scope
Expand All @@ -41,6 +55,21 @@ function Get-AzVMGuestPolicyStatus-InitiativeIdScope
Assert-True { $reports.Count -gt 0 }
}

<#
.SYNOPSIS
Get guest configuration custom policy report by Initiative id scope
#>
function Get-AzVMGuestPolicyStatus-InitiativeIdScope_Custom
{
$rgName = "amits-test"
$vmName = "amits-winser6"
$initiativeId = "/subscriptions/b5e4748c-f69a-467c-8749-e2f9c8cd3db0/providers/Microsoft.Authorization/policySetDefinitions/8174929b-2752-46af-9167-89d2d6780439"

$reports = Get-AzVMGuestPolicyStatus -ResourceGroupName $rgName -VMName $vmName -InitiativeId $initiativeId
Assert-NotNull $reports
Assert-True { $reports.Count -gt 0 }
}

<#
.SYNOPSIS
Get guest configuration policy report by Initiative name scope
Expand All @@ -56,6 +85,21 @@ function Get-AzVMGuestPolicyStatus-InitiativeNameScope
Assert-True { $reports.Count -gt 0 }
}

<#
.SYNOPSIS
Get guest configuration custom policy report by Initiative name scope
#>
function Get-AzVMGuestPolicyStatus-InitiativeNameScope_Custom
{
$rgName = "amits-test"
$vmName = "amits-winser6"
$initiativeName = "8174929b-2752-46af-9167-89d2d6780439"

$reports = Get-AzVMGuestPolicyStatus -ResourceGroupName $rgName -VMName $vmName -InitiativeName $initiativeName
Assert-NotNull $reports
Assert-True { $reports.Count -gt 0 }
}

<#
.SYNOPSIS
Get guest configuration policy by ReportId scope
Expand All @@ -74,3 +118,22 @@ function Get-AzVMGuestPolicyStatus-ReportIdScope
$report = Get-AzVMGuestPolicyStatus -ReportId $Id
Assert-NotNull $report
}

<#
.SYNOPSIS
Get guest configuration custom policy by ReportId scope
#>
function Get-AzVMGuestPolicyStatus-ReportIdScope_Custom
{
$rgName = "amits-test"
$vmName = "amits-winser6"
$initiativeName = "8174929b-2752-46af-9167-89d2d6780439"
$reports = Get-AzVMGuestPolicyStatus -ResourceGroupName $rgName -VMName $vmName -InitiativeName $initiativeName
Assert-NotNull $reports
Assert-True { $reports.Count -gt 0 }

$Id= $reports[0].ReportId;

$report = Get-AzVMGuestPolicyStatus -ReportId $Id
Assert-NotNull $report
}
Loading