Skip to content
Closed
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
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<PsModuleName>GuestConfiguration</PsModuleName>
</PropertyGroup>

<Import Project="$(MSBuildThisFileDirectory)..\..\Az.Test.props" />

<PropertyGroup>
<RootNamespace>$(LegacyAssemblyPrefix)$(PsModuleName)$(AzTestAssemblySuffix)</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.GuestConfiguration" Version="0.10.0-preview" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using System;
using System.Reflection;
using System.Runtime.InteropServices;
using Xunit;

[assembly: AssemblyTitle("Microsoft Azure Powershell - Guest Configuration Tests")]
[assembly: AssemblyCompany(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyCompany)]
[assembly: AssemblyProduct(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyProduct)]
[assembly: AssemblyCopyright(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyCopyright)]

[assembly: ComVisible(false)]
[assembly: CLSCompliant(false)]
[assembly: Guid("840516AC-34D7-4F12-925B-37509D240277")]

[assembly: AssemblyVersion("1.0.0")]
[assembly: AssemblyFileVersion("1.0.0")]

[assembly: CollectionBehavior(DisableTestParallelization = true)]
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# ----------------------------------------------------------------------------------
#
# Copyright Microsoft Corporation
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ----------------------------------------------------------------------------------

<#
.SYNOPSIS
Validates a string is not null or empty
#>
function Assert-NotNullOrEmpty
{
param([string]$value)

Assert-False { [string]::IsNullOrEmpty($value) }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.Azure.ServiceManagement.Common.Models;

namespace Microsoft.Azure.Commands.GuestConfiguration.Test.ScenarioTests
{
using Microsoft.Azure.Commands.ScenarioTest;
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Xunit;


public class GetVmGuestPolicyReportTests
{
private readonly XunitTracingInterceptor _logger;

public GetVmGuestPolicyReportTests(Xunit.Abstractions.ITestOutputHelper output)
{
_logger = new XunitTracingInterceptor(output);
XunitTracingInterceptor.AddToContext(_logger);
TestExecutionHelpers.SetUpSessionAndProfile();
}

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

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

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

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void ReportIdScope()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmVMGuestPolicyReport-ReportIdScope");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# ----------------------------------------------------------------------------------
#
# Copyright Microsoft Corporation
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ----------------------------------------------------------------------------------

<#
.SYNOPSIS
Get guest configuration policy report by Vm name scope
#>
function Get-AzureRmVMGuestPolicyReport-VmNameScope
{
$rgName = "VivsGL"
$vmName = "VivsGL0"

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

<#
.SYNOPSIS
Get guest configuration policy report by Initiative id scope
#>
function Get-AzureRmVMGuestPolicyReport-InitiativeIdScope
{
$rgName = "VivsGL"
$vmName = "VivsGL0"
$initiativeId = "/providers/Microsoft.Authorization/policySetDefinitions/3fa7cbf5-c0a4-4a59-85a5-cca4d996d5a6"

$reports = Get-AzVMGuestPolicyReport -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
#>
function Get-AzureRmVMGuestPolicyReport-InitiativeNameScope
{
$rgName = "VivsGL"
$vmName = "VivsGL0"
$initiativeName = "3fa7cbf5-c0a4-4a59-85a5-cca4d996d5a6"

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

<#
.SYNOPSIS
Get guest configuration policy by reportId scope
#>
function Get-AzureRmVMGuestPolicyReport-ReportIdScope
{
$rgName = "VivsGL"
$vmName = "VivsGL0"
$reportId= "/subscriptions/b5e4748c-f69a-467c-8749-e2f9c8cd3db0/resourceGroups/VivsGL/providers/Microsoft.Compute/virtualMachines/VivsGL0/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/PasswordMustMeetComplexityRequirements/reports/7421bae4-60f0-4712-a45f-c9c960ffc75c"

$report = Get-AzVMGuestPolicyReport -ReportId $reportId
Assert-NotNull $report
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.Azure.ServiceManagement.Common.Models;

namespace Microsoft.Azure.Commands.GuestConfiguration.Test.ScenarioTests
{
using Microsoft.Azure.Commands.ScenarioTest;
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Xunit;


public class GetVmGuestPolicyStatusHistoryTests
{
private readonly XunitTracingInterceptor _logger;

public GetVmGuestPolicyStatusHistoryTests(Xunit.Abstractions.ITestOutputHelper output)
{
_logger = new XunitTracingInterceptor(output);
XunitTracingInterceptor.AddToContext(_logger);
TestExecutionHelpers.SetUpSessionAndProfile();
}

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

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

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

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void ShowOnlyChangeSwitchVmNameScope()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmVMGuestPolicyStatusHistory-ShowOnlyChangeSwitch-VmNameScope");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# ----------------------------------------------------------------------------------
#
# Copyright Microsoft Corporation
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ----------------------------------------------------------------------------------

<#
.SYNOPSIS
Get guest configuration policy status history by Vm name scope
#>
function Get-AzureRmVMGuestPolicyStatusHistory-VmNameScope
{
$rgName = "VivsGL"
$vmName = "VivsGL0"

$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
#>
function Get-AzureRmVMGuestPolicyStatusHistory-InitiativeIdScope
{
$rgName = "VivsGL"
$vmName = "VivsGL0"
$initiativeId = "/providers/Microsoft.Authorization/policySetDefinitions/3fa7cbf5-c0a4-4a59-85a5-cca4d996d5a6"

$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
#>
function Get-AzureRmVMGuestPolicyStatusHistory-InitiativeNameScope
{
$rgName = "VivsGL"
$vmName = "VivsGL0"
$initiativeName = "3fa7cbf5-c0a4-4a59-85a5-cca4d996d5a6"

$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
#>
function Get-AzureRmVMGuestPolicyStatusHistory-ShowOnlyChangeSwitch-VmNameScope
{
$rgName = "VivsGL"
$vmName = "VivsGL0"

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