Skip to content

GuestConfig PS Cmdlets: Fix Inconsistencies in compliance status #9344

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 11 commits into from
Jul 8, 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.1.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 @@ -18,8 +18,8 @@ Get guest configuration policy status history by Vm name scope
#>
function Get-AzVMGuestPolicyStatusHistory-VmNameScope
{
$rgName = "vivga"
$vmName = "Viv1809SDDC"
$rgName = "aashishGoodPolicy"
$vmName = "aashishvm1"

$historicalStatuses = Get-AzVMGuestPolicyStatusHistory -ResourceGroupName $rgName -VMName $vmName
Assert-NotNull $historicalStatuses
Expand All @@ -32,8 +32,8 @@ Get guest configuration policy status history by Vm name scope
#>
function Get-AzVMGuestPolicyStatusHistory-VmNameScope_Custom
{
$rgName = "amits-test"
$vmName = "amits-winser6"
$rgName = "aashishCustomrole7ux"
$vmName = "aashishCustomrole7ux"

$historicalStatuses = Get-AzVMGuestPolicyStatusHistory -ResourceGroupName $rgName -VMName $vmName
Assert-NotNull $historicalStatuses
Expand All @@ -46,9 +46,9 @@ Get guest configuration policy status history by Initiative id scope
#>
function Get-AzVMGuestPolicyStatusHistory-InitiativeIdScope
{
$rgName = "vivga"
$vmName = "Viv1809SDDC"
$initiativeId = "/providers/Microsoft.Authorization/policySetDefinitions/25ef9b72-4af2-4501-acd1-fc814e73dde1"
$rgName = "aashishGoodPolicy"
$vmName = "aashishvm1"
$initiativeId = "/providers/Microsoft.Authorization/policySetDefinitions/8bc55e6b-e9d5-4266-8dac-f688d151ec9c"

$historicalStatuses = Get-AzVMGuestPolicyStatusHistory -ResourceGroupName $rgName -VMName $vmName -InitiativeId $initiativeId
Assert-NotNull $historicalStatuses
Expand All @@ -61,9 +61,9 @@ 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"
$rgName = "aashishCustomrole7ux"
$vmName = "aashishCustomrole7ux"
$initiativeId = "/subscriptions/b5e4748c-f69a-467c-8749-e2f9c8cd3db0/providers/Microsoft.Authorization/policySetDefinitions/60062d3c-3282-4a3d-9bc4-3557dded22ca"

$historicalStatuses = Get-AzVMGuestPolicyStatusHistory -ResourceGroupName $rgName -VMName $vmName -InitiativeId $initiativeId
Assert-NotNull $historicalStatuses
Expand All @@ -76,9 +76,9 @@ Get guest configuration policy status history by Initiative name scope
#>
function Get-AzVMGuestPolicyStatusHistory-InitiativeNameScope
{
$rgName = "vivga"
$vmName = "Viv1809SDDC"
$initiativeName = "25ef9b72-4af2-4501-acd1-fc814e73dde1"
$rgName = "aashishGoodPolicy"
$vmName = "aashishvm1"
$initiativeName = "8bc55e6b-e9d5-4266-8dac-f688d151ec9c"

$historicalStatuses = Get-AzVMGuestPolicyStatusHistory -ResourceGroupName $rgName -VMName $vmName -InitiativeName $initiativeName
Assert-NotNull $historicalStatuses
Expand All @@ -91,9 +91,9 @@ 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"
$rgName = "aashishCustomrole7ux"
$vmName = "aashishCustomrole7ux"
$initiativeName = "60062d3c-3282-4a3d-9bc4-3557dded22ca"

$historicalStatuses = Get-AzVMGuestPolicyStatusHistory -ResourceGroupName $rgName -VMName $vmName -InitiativeName $initiativeName
Assert-NotNull $historicalStatuses
Expand All @@ -106,8 +106,8 @@ Get guest configuration policy by vmName scope, using ShowOnlyChange switch
#>
function Get-AzVMGuestPolicyStatusHistory-ShowOnlyChangeSwitch-VmNameScope
{
$rgName = "vivga"
$vmName = "Viv1809SDDC"
$rgName = "aashishGoodPolicy"
$vmName = "aashishvm1"

$historicalStatuses = Get-AzVMGuestPolicyStatusHistory -ResourceGroupName $rgName -VMName $vmName -ShowOnlyChange
Assert-NotNull $historicalStatuses
Expand All @@ -120,8 +120,8 @@ Get guest configuration policy by vmName scope, using ShowOnlyChange switch
#>
function Get-AzVMGuestPolicyStatusHistory-ShowOnlyChangeSwitch-VmNameScope_Custom
{
$rgName = "amits-test"
$vmName = "amits-winser6"
$rgName = "aashishCustomrole7ux"
$vmName = "aashishCustomrole7ux"

$historicalStatuses = Get-AzVMGuestPolicyStatusHistory -ResourceGroupName $rgName -VMName $vmName -ShowOnlyChange
Assert-NotNull $historicalStatuses
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ Get guest configuration policy report by Vm name scope for custom policy
#>
function Get-AzVMGuestPolicyStatus-VmNameScope_Custom
{
$rgName = "amits-test"
$vmName = "amits-winser6"
$rgName = "aashishCustomrole7ux"
$vmName = "aashishCustomrole7ux"

$reports = Get-AzVMGuestPolicyStatus -ResourceGroupName $rgName -VMName $vmName
Assert-NotNull $reports
Expand Down Expand Up @@ -61,9 +61,9 @@ 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"
$rgName = "aashishCustomrole7ux"
$vmName = "aashishCustomrole7ux"
$initiativeId = "/subscriptions/b5e4748c-f69a-467c-8749-e2f9c8cd3db0/providers/Microsoft.Authorization/policySetDefinitions/60062d3c-3282-4a3d-9bc4-3557dded22ca"

$reports = Get-AzVMGuestPolicyStatus -ResourceGroupName $rgName -VMName $vmName -InitiativeId $initiativeId
Assert-NotNull $reports
Expand Down Expand Up @@ -91,9 +91,9 @@ 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"
$rgName = "aashishCustomrole7ux"
$vmName = "aashishCustomrole7ux"
$initiativeName = "60062d3c-3282-4a3d-9bc4-3557dded22ca"

$reports = Get-AzVMGuestPolicyStatus -ResourceGroupName $rgName -VMName $vmName -InitiativeName $initiativeName
Assert-NotNull $reports
Expand Down Expand Up @@ -125,9 +125,9 @@ 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"
$rgName = "aashishCustomrole7ux"
$vmName = "aashishCustomrole7ux"
$initiativeName = "60062d3c-3282-4a3d-9bc4-3557dded22ca"
$reports = Get-AzVMGuestPolicyStatus -ResourceGroupName $rgName -VMName $vmName -InitiativeName $initiativeName
Assert-NotNull $reports
Assert-True { $reports.Count -gt 0 }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ namespace Microsoft.Azure.Commands.GuestConfiguration.Test.ScenarioTests

using Microsoft.Azure.Commands.Common.Authentication;
using Microsoft.Azure.Management.GuestConfiguration;
using Microsoft.Azure.Management.PolicyInsights_2018_04;
using Microsoft.Azure.Management.PolicyInsights_2018_04.Models;
using Microsoft.Azure.Test.HttpRecorder;
using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
using Microsoft.WindowsAzure.Commands.ScenarioTest;
Expand All @@ -38,6 +40,8 @@ public class TestController : RMTestBase

public PolicyClient PolicyClient { get; private set; }

public PolicyInsightsClient PolicyInsightsClient { get; private set; }

public static TestController NewInstance => new TestController();

protected TestController()
Expand Down Expand Up @@ -83,7 +87,8 @@ protected void SetupManagementClients(MockContext context)
{
GuestConfigurationClient = GetGuestConfigurationClient(context);
PolicyClient = GetPolicyClient(context);
_helper.SetupManagementClients(GuestConfigurationClient, PolicyClient);
PolicyInsightsClient = GetPolicyInsightsClient(context);
_helper.SetupManagementClients(GuestConfigurationClient, PolicyClient, PolicyInsightsClient);
}

private static GuestConfigurationClient GetGuestConfigurationClient(MockContext context)
Expand All @@ -95,5 +100,10 @@ private static PolicyClient GetPolicyClient(MockContext context)
{
return context.GetServiceClient<PolicyClient>(TestEnvironmentFactory.GetTestEnvironment());
}

private static PolicyInsightsClient GetPolicyInsightsClient(MockContext context)
{
return context.GetServiceClient<PolicyInsightsClient>(TestEnvironmentFactory.GetTestEnvironment());
}
}
}
Loading