Skip to content

Commit 3c2cc1c

Browse files
committed
+Test
1 parent 2d6fe9e commit 3c2cc1c

File tree

5 files changed

+995
-0
lines changed

5 files changed

+995
-0
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.

0 commit comments

Comments
 (0)