Skip to content

Commit 17ea233

Browse files
committed
Merge pull request #28 from dud5/nsgbugrethrow
Rethrow exception in Set-AzureNetworkSecurityGroupToSubnet
2 parents 989fe08 + 259915e commit 17ea233

File tree

17 files changed

+2451
-971
lines changed

17 files changed

+2451
-971
lines changed

src/ServiceManagement/Network/Commands.Network.Test/Commands.Network.Test.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
44
<PropertyGroup>
@@ -78,9 +78,9 @@
7878
<Reference Include="Microsoft.WindowsAzure.Common.NetFramework">
7979
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Common.1.4.1\lib\net45\Microsoft.WindowsAzure.Common.NetFramework.dll</HintPath>
8080
</Reference>
81-
<Reference Include="Microsoft.WindowsAzure.Management, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
81+
<Reference Include="Microsoft.WindowsAzure.Management, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
8282
<SpecificVersion>False</SpecificVersion>
83-
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.2.0.0\lib\net40\Microsoft.WindowsAzure.Management.dll</HintPath>
83+
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.2.1.0\lib\net40\Microsoft.WindowsAzure.Management.dll</HintPath>
8484
</Reference>
8585
<Reference Include="Microsoft.WindowsAzure.Management.Compute, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
8686
<SpecificVersion>False</SpecificVersion>

src/ServiceManagement/Network/Commands.Network.Test/ScenarioTests/NetworkSecurityGroup/Common.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Creates a Security Group.
6262
#>
6363
function New-NetworkSecurityGroup
6464
{
65-
param([string] $securityGroupName)
65+
param([string] $securityGroupName, [string] $location = $location)
6666

6767
New-AzureNetworkSecurityGroup -Name $securityGroupName -Location $location -Label $NSGLabel
6868
}

src/ServiceManagement/Network/Commands.Network.Test/ScenarioTests/NetworkSecurityGroup/NSGScenarioTests.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,14 @@ public void TestRemoveNSGFromSubnet()
9999
this.RunPowerShellTest("Test-RemoveNetworkSecurityGroupFromSubnet");
100100
}
101101

102+
[Fact]
103+
[Trait(Category.Service, Category.Network)]
104+
[Trait(Category.AcceptanceType, Category.CheckIn)]
105+
public void TestSetNSGToSubnetInDiffRegion()
106+
{
107+
this.RunPowerShellTest("Test-SetNetworkSecurityGroupToSubnetInDifferentRegion");
108+
}
109+
102110
#region Test setup
103111
protected void SetupManagementClients()
104112
{

src/ServiceManagement/Network/Commands.Network.Test/ScenarioTests/NetworkSecurityGroup/NetworkSecurityGroupTests.ps1

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,24 @@ function Test-SetAndGetNetworkSecurityGroupForSubnet
174174
Assert-AreEqual $securityGroupFromSubnet.Name $securityGroupName
175175
}
176176

177+
<#
178+
.SYNOPSIS
179+
Tests Set and Get-AzureNetworkSecurityGroupForSubnet
180+
#>
181+
function Test-SetNetworkSecurityGroupToSubnetInDifferentRegion
182+
{
183+
# Setup
184+
$securityGroupName = Get-SecurityGroupName
185+
$securityRuleName = Get-SecurityRuleName
186+
$securityGroupLocation = $locations[1].Name
187+
$createdSecurityGroup = New-NetworkSecurityGroup $securityGroupName $securityGroupLocation
188+
Set-AzureVNetConfig ($(Get-Location).Path + "\TestData\SimpleNetworkConfiguration.xml")
189+
190+
# Assert
191+
$expectedMessage = "BadRequest : The region europewest specified for the Network Security Group $securityGroupName is different than the region europenorth that Virtual Network $VirtualNetworkName belongs to, they need to belong to the same region."
192+
Assert-Throws { Set-AzureNetworkSecurityGroupToSubnet -Name $securityGroupName -VirtualNetwork $VirtualNetworkName -Subnet $SubnetName -Force } $expectedMessage
193+
}
194+
177195
########################## Remove Network Security Group for Subnet Tests #############################
178196

179197
<#

src/ServiceManagement/Network/Commands.Network.Test/SessionRecords/Microsoft.Azure.Commands.Network.Test.ScenarioTests.NSGScenarioTests/.ctor.json

Lines changed: 169 additions & 88 deletions
Large diffs are not rendered by default.

src/ServiceManagement/Network/Commands.Network.Test/SessionRecords/Microsoft.Azure.Commands.Network.Test.ScenarioTests.NSGScenarioTests/TestCreateAndRemoveNSG.json

Lines changed: 189 additions & 99 deletions
Large diffs are not rendered by default.

src/ServiceManagement/Network/Commands.Network.Test/SessionRecords/Microsoft.Azure.Commands.Network.Test.ScenarioTests.NSGScenarioTests/TestGetMultipleNSGs.json

Lines changed: 215 additions & 110 deletions
Large diffs are not rendered by default.

src/ServiceManagement/Network/Commands.Network.Test/SessionRecords/Microsoft.Azure.Commands.Network.Test.ScenarioTests.NSGScenarioTests/TestRemoveNSGFromSubnet.json

Lines changed: 309 additions & 159 deletions
Large diffs are not rendered by default.

src/ServiceManagement/Network/Commands.Network.Test/SessionRecords/Microsoft.Azure.Commands.Network.Test.ScenarioTests.NSGScenarioTests/TestRemoveNSGWithNonExistingName.json

Lines changed: 93 additions & 51 deletions
Large diffs are not rendered by default.

src/ServiceManagement/Network/Commands.Network.Test/SessionRecords/Microsoft.Azure.Commands.Network.Test.ScenarioTests.NSGScenarioTests/TestRemoveNSR.json

Lines changed: 285 additions & 147 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)