Skip to content

Commit 1d77e70

Browse files
committed
Merge pull request #675 from huangpf/dev
AzureRT PR S52 #2: Fix PIR Cmdlets & +Tests
2 parents 7efd6b9 + a876bb7 commit 1d77e70

File tree

7 files changed

+998
-2
lines changed

7 files changed

+998
-2
lines changed

src/Common/Commands.ScenarioTest/Commands.ScenarioTest.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,9 @@
212212
<None Include="SessionRecords\Microsoft.WindowsAzure.Commands.ScenarioTest.ServiceManagementTests\RunAutoGeneratedVirtualMachineCmdletTests.json">
213213
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
214214
</None>
215+
<None Include="SessionRecords\Microsoft.WindowsAzure.Commands.ScenarioTest.ServiceManagementTests\RunAzurePlatformVMImageNegativeTest.json">
216+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
217+
</None>
215218
<None Include="SessionRecords\Microsoft.WindowsAzure.Commands.ScenarioTest.ServiceManagementTests\RunNewAzureComputeArgumentListTests.json">
216219
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
217220
</None>

src/Common/Commands.ScenarioTest/Resources/ServiceManagement/ServiceManagementTests.ps1

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,4 +342,25 @@ function Run-NewAzureComputeParameterObjectTests
342342
$full_name_query = $full_name.Replace('+', '.').Replace('<', '*').Replace('>', '*');
343343
Assert-True { $param_type_name -like $full_name_query } "`'$param_type_name`' & `'$full_name`'";
344344
}
345+
}
346+
347+
function Run-AzurePlatformVMImageNegativeTest
348+
{
349+
$location = Get-DefaultLocation;
350+
$imgName = Get-DefaultImage $location;
351+
$replicate_locations = (Get-AzureLocation | where { $_.Name -like '*US*' } | select -ExpandProperty Name);
352+
353+
$c1 = New-AzurePlatformComputeImageConfig -Offer test -Sku test -Version test;
354+
$c2 = New-AzurePlatformMarketplaceImageConfig -PlanName test -Product test -Publisher test -PublisherId test;
355+
356+
Assert-ThrowsContains `
357+
{ Set-AzurePlatformVMImage -ImageName $imgName -ReplicaLocations $replicate_locations -ComputeImageConfig $c1 -MarketplaceImageConfig $c2 } `
358+
"ForbiddenError: This operation is not allowed for this subscription.";
359+
360+
foreach ($mode in @("MSDN", "Private", "Public"))
361+
{
362+
Assert-ThrowsContains `
363+
{ Set-AzurePlatformVMImage -ImageName $imgName -Permission $mode } `
364+
"ForbiddenError: This operation is not allowed for this subscription.";
365+
}
345366
}

src/Common/Commands.ScenarioTest/ServiceManagement/ScenarioTests.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,5 +89,14 @@ public void RunNewAzureComputeParameterObjectTests()
8989
{
9090
this.RunPowerShellTest("Run-NewAzureComputeParameterObjectTests");
9191
}
92+
93+
[Fact]
94+
[Trait(Category.Service, Category.ServiceManagement)]
95+
[Trait(Category.AcceptanceType, Category.CheckIn)]
96+
[Trait(Category.AcceptanceType, Category.BVT)]
97+
public void RunAzurePlatformVMImageNegativeTest()
98+
{
99+
this.RunPowerShellTest("Run-AzurePlatformVMImageNegativeTest");
100+
}
92101
}
93102
}

src/Common/Commands.ScenarioTest/ServiceManagement/ServiceManagementTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ protected void RunPowerShellTest(params string[] scripts)
5555
modules.Add("Common.ps1");
5656
modules.Add(@"..\..\..\..\Package\Debug\ServiceManagement\Azure\Azure.psd1");
5757
modules.Add(@"..\..\..\..\Package\Debug\ServiceManagement\Azure\Compute\AzurePreview.psd1");
58+
modules.Add(@"..\..\..\..\Package\Debug\ServiceManagement\Azure\Compute\PIR.psd1");
5859

5960
helper.SetupEnvironment(AzureModule.AzureServiceManagement);
6061
helper.SetupModules(modules.ToArray());

src/Common/Commands.ScenarioTest/SessionRecords/Microsoft.WindowsAzure.Commands.ScenarioTest.ServiceManagementTests/RunAzurePlatformVMImageNegativeTest.json

Lines changed: 961 additions & 0 deletions
Large diffs are not rendered by default.

src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/VirtualMachineProfileTests.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ function Test-VirtualMachineProfile
6363

6464
$p = Add-AzureVMDataDisk -VM $p -Name 'testDataDisk1' -Caching 'ReadOnly' -DiskSizeInGB 10 -Lun 0 -VhdUri $dataDiskVhdUri1 -CreateOption Empty;
6565
$p = Add-AzureVMDataDisk -VM $p -Name 'testDataDisk2' -Caching 'ReadOnly' -DiskSizeInGB 11 -Lun 1 -VhdUri $dataDiskVhdUri2 -CreateOption Empty;
66-
$p = Add-AzureVMDataDisk -VM $p -Name 'testDataDisk3' -Caching 'ReadOnly' -DiskSizeInGB 12 -Lun 2 -VhdUri $dataDiskVhdUri3 -CreateOption Empty;
66+
$p = Add-AzureVMDataDisk -VM $p -Name 'testDataDisk3' -Caching 'ReadOnly' -DiskSizeInGB $null -Lun 2 -VhdUri $dataDiskVhdUri3 -CreateOption Empty;
67+
Assert-Null $p.StorageProfile.DataDisks[2].DiskSizeGB;
6768
$p = Remove-AzureVMDataDisk -VM $p -Name 'testDataDisk3';
6869

6970
Assert-AreEqual $p.StorageProfile.OSDisk.Caching $osDiskCaching;

src/ServiceManagement/Compute/Commands.ServiceManagement.PlatformImageRepository/ImagePublishing/SetAzurePlatformVMImage.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public class SetAzurePlatformVMImage : ServiceManagementBaseCmdlet
4545
public string[] ReplicaLocations { get; set; }
4646

4747
[Parameter(Position = 1, Mandatory = true, ParameterSetName = ShareParameterSetName, ValueFromPipelineByPropertyName = true, HelpMessage = "Specifies the sharing permission of replicated image.")]
48-
[ValidateSet("Public", "Private")]
48+
[ValidateSet("Public", "Private", "MSDN")]
4949
public string Permission { get; set; }
5050

5151
[Parameter(Mandatory = true, ParameterSetName = ReplicateParameterSetName), ValidateNotNullOrEmpty]

0 commit comments

Comments
 (0)