Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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 @@ -66,8 +66,8 @@
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.0.18.2-preview\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Management.Network, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.2.0.3-preview\lib\net40\Microsoft.Azure.Management.Network.dll</HintPath>
<Private>True</Private>
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.2.0.4-preview\lib\net40\Microsoft.Azure.Management.Network.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.ResourceManager">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Resources.2.18.0-preview\lib\net40\Microsoft.Azure.ResourceManager.dll</HintPath>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function Test-LocalNetworkGatewayCRUD
$rglocation = Get-ProviderLocation ResourceManagement
$resourceTypeParent = "Microsoft.Network/localNetworkGateways"
$location = Get-ProviderLocation $resourceTypeParent

try
{
# Create the resource group
Expand All @@ -36,7 +36,9 @@ function Test-LocalNetworkGatewayCRUD
Assert-AreEqual $expected.ResourceGroupName $actual.ResourceGroupName
Assert-AreEqual $expected.Name $actual.Name
Assert-AreEqual "192.168.3.4" $expected.GatewayIpAddress

Assert-AreEqual "192.168.0.0/16" $expected.LocalNetworkAddressSpace.AddressPrefixes[0]
$expected.Location = $location

# List LocalNetworkGateways
$list = Get-AzureLocalNetworkGateway -ResourceGroupName $rgname
Assert-AreEqual 1 @($list).Count
Expand All @@ -45,11 +47,10 @@ function Test-LocalNetworkGatewayCRUD
Assert-AreEqual $list[0].Location $actual.Location
Assert-AreEqual "192.168.3.4" $list[0].GatewayIpAddress

# Reset/Update LocalNetworkGateway
$expected.GatewayIpAddress = "192.168.3.5"
$actual = Reset-AzureLocalNetworkGateway -LocalNetworkGateway $expected
# Set/Update LocalNetworkGateway
$actual = Set-AzureLocalNetworkGateway -LocalNetworkGateway $expected -AddressPrefix "200.168.0.0/16"
$expected = Get-AzureLocalNetworkGateway -ResourceGroupName $rgname -name $rname
Assert-AreEqual "192.168.3.5" $expected.GatewayIpAddress
Assert-AreEqual "200.168.0.0/16" $expected.LocalNetworkAddressSpace.AddressPrefixes[0]

# Delete LocalNetworkGateway
$delete = Remove-AzureLocalNetworkGateway -ResourceGroupName $actual.ResourceGroupName -name $rname -PassThru -Force
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void TestVirtualNetworkGatewayConnectionCRUD()
NetworkResourcesController.NewInstance.RunPsTest("Test-VirtualNetworkGatewayConnectionCRUD");
}

[Fact]
[Fact(Skip = "TODO: Will send another PR after re-recording test")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestVirtualNetworkGatewayConnectionSharedKeyCRUD()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,21 @@ function Test-VirtualNetworkGatewayConnectionCRUD
# Create VirtualNetworkGateway
$vnetIpConfig = New-AzureVirtualNetworkGatewayIpConfig -Name $vnetGatewayConfigName -PublicIpAddress $publicip -Subnet $subnet

$actual = New-AzureVirtualNetworkGateway -ResourceGroupName $rgname -name $rname -location $location -IpConfigurations $vnetIpConfig -GatewaySize Default -GatewayType DynamicRouting -EnableBgp $false
$actual = New-AzureVirtualNetworkGateway -ResourceGroupName $rgname -name $rname -location $location -IpConfigurations $vnetIpConfig -GatewayType Vpn -VpnType RouteBased -EnableBgp $false
$vnetGateway = Get-AzureVirtualNetworkGateway -ResourceGroupName $rgname -name $rname
Assert-AreEqual $vnetGateway.ResourceGroupName $actual.ResourceGroupName
Assert-AreEqual $vnetGateway.Name $actual.Name
Assert-AreEqual "Default" $vnetGateway.GatewaySize
Assert-AreEqual "DynamicRouting" $vnetGateway.GatewayType
#Assert-AreEqual "Vpn" $expected.GatewayType
#Assert-AreEqual "RouteBased" $expected.VpnType

# Create LocalNetworkGateway
$actual = New-AzureLocalNetworkGateway -ResourceGroupName $rgname -name $localnetName -location $location -AddressPrefix 192.168.0.0/16 -GatewayIpAddress 192.168.3.10
$localnetGateway = Get-AzureLocalNetworkGateway -ResourceGroupName $rgname -name $localnetName
Assert-AreEqual $localnetGateway.ResourceGroupName $actual.ResourceGroupName
Assert-AreEqual $localnetGateway.Name $actual.Name
Assert-AreEqual "192.168.3.10" $localnetGateway.GatewayIpAddress
Assert-AreEqual "192.168.3.10" $localnetGateway.GatewayIpAddress
Assert-AreEqual "192.168.0.0/16" $localnetGateway.LocalNetworkAddressSpace.AddressPrefixes[0]
$localnetGateway.Location = $location

# Create & Get VirtualNetworkGatewayConnection
$actual = New-AzureVirtualNetworkGatewayConnection -ResourceGroupName $rgname -name $vnetConnectionName -location $location -VirtualNetworkGateway1 $vnetGateway -LocalNetworkGateway2 $localnetGateway -ConnectionType IPsec -RoutingWeight 3 -SharedKey abc
Expand All @@ -80,17 +82,18 @@ function Test-VirtualNetworkGatewayConnectionCRUD
Assert-AreEqual "IPsec" $list[0].ConnectionType
Assert-AreEqual "3" $list[0].RoutingWeight
Assert-AreEqual "abc" $list[0].SharedKey

# Reset/Update VirtualNetworkGatewayConnection
$expected.ConnectionType = "Vnet2Vnet"

# Set/Update VirtualNetworkGatewayConnection
$expected.Location = $location
$expected.VirtualNetworkGateway1.Location = $location
$expected.LocalNetworkGateway2.Location = $location
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix indentation.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done,

$expected.RoutingWeight = "4"
$expected.SharedKey = "xyz"

$actual = Reset-AzureVirtualNetworkGatewayConnection -VirtualNetworkGatewayConnection $expected -Force
$expected = Get-AzureVirtualNetworkGatewayConnection -ResourceGroupName $rgname -name $vnetConnectionName
Assert-AreEqual "Vnet2Vnet" $expected.ConnectionType
$actual = Set-AzureVirtualNetworkGatewayConnection -VirtualNetworkGatewayConnection $expected -Force
$expected = Get-AzureVirtualNetworkGatewayConnection -ResourceGroupName $rgname -name $vnetConnectionName
Assert-AreEqual "4" $expected.RoutingWeight
Assert-AreEqual "xyz" $expected.SharedKey
Assert-AreEqual "xyz" $expected.SharedKey

# Delete VirtualNetworkGatewayConnection
$delete = Remove-AzureVirtualNetworkGatewayConnection -ResourceGroupName $actual.ResourceGroupName -name $vnetConnectionName -PassThru -Force
Expand Down Expand Up @@ -142,19 +145,21 @@ function Test-VirtualNetworkGatewayConnectionSharedKeyCRUD
# Create VirtualNetworkGateway
$vnetIpConfig = New-AzureVirtualNetworkGatewayIpConfig -Name $vnetGatewayConfigName -PublicIpAddress $publicip -Subnet $subnet

$actual = New-AzureVirtualNetworkGateway -ResourceGroupName $rgname -name $rname -location $location -IpConfigurations $vnetIpConfig -GatewaySize Default -GatewayType DynamicRouting -EnableBgp $false
$actual = New-AzureVirtualNetworkGateway -ResourceGroupName $rgname -name $rname -location $location -IpConfigurations $vnetIpConfig -GatewayType Vpn -VpnType RouteBased -EnableBgp $false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

$vnetGateway = Get-AzureVirtualNetworkGateway -ResourceGroupName $rgname -name $rname
Assert-AreEqual $vnetGateway.ResourceGroupName $actual.ResourceGroupName
Assert-AreEqual $vnetGateway.Name $actual.Name
Assert-AreEqual "Default" $vnetGateway.GatewaySize
Assert-AreEqual "DynamicRouting" $vnetGateway.GatewayType
#Assert-AreEqual "Vpn" $expected.GatewayType
#Assert-AreEqual "RouteBased" $expected.VpnType

# Create LocalNetworkGateway
$actual = New-AzureLocalNetworkGateway -ResourceGroupName $rgname -name $localnetName -location $location -AddressPrefix 192.168.0.0/16 -GatewayIpAddress 192.168.3.11
$localnetGateway = Get-AzureLocalNetworkGateway -ResourceGroupName $rgname -name $localnetName
Assert-AreEqual $localnetGateway.ResourceGroupName $actual.ResourceGroupName
Assert-AreEqual $localnetGateway.Name $actual.Name
Assert-AreEqual "192.168.3.11" $localnetGateway.GatewayIpAddress
Assert-AreEqual "192.168.0.0/16" $localnetGateway.LocalNetworkAddressSpace.AddressPrefixes[0]
$localnetGateway.Location = $location

# Create VirtualNetworkGatewayConnection
$actual = New-AzureVirtualNetworkGatewayConnection -ResourceGroupName $rgname -name $vnetConnectionName -location $location -VirtualNetworkGateway1 $vnetGateway -LocalNetworkGateway2 $localnetGateway -ConnectionType IPsec -RoutingWeight 3 -SharedKey abc
Expand All @@ -166,13 +171,16 @@ function Test-VirtualNetworkGatewayConnectionSharedKeyCRUD
Assert-AreEqual "abc" $expected.SharedKey

# Set VirtualNetworkGatewayConnectionSharedKey
$actual = Set-AzureVirtualNetworkGatewayConnectionSharedKey -ResourceGroupName $rgname -name $vnetConnectionName -Value TestSharedKeyValue -Force
$actual = Set-AzureVirtualNetworkGatewayConnectionSharedKey -ResourceGroupName $rgname -name $vnetConnectionName -Value "TestSharedKeyValue" -Force

# Get VirtualNetworkGatewayConnectionSharedKey
$expected = Get-AzureVirtualNetworkGatewayConnectionSharedKey -ResourceGroupName $rgname -name $vnetConnectionName

# Reset VirtualNetworkGatewayConnectionSharedKey
#$actual = Reset-AzureVirtualNetworkGatewayConnectionSharedKey -ResourceGroupName $rgname -name $rname -KeyLength 50 -Force
$actual = Reset-AzureVirtualNetworkGatewayConnectionSharedKey -ResourceGroupName $rgname -name $rname -KeyLength 50 -Force

# Get VirtualNetworkGatewayConnectionSharedKey after Reset-VirtualNetworkGatewayConnectionSharedKey
$expected = Get-AzureVirtualNetworkGatewayConnectionSharedKey -ResourceGroupName $rgname -name $vnetConnectionName
}
finally
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,29 +46,22 @@ function Test-VirtualNetworkGatewayCRUD
# Create & Get virtualnetworkgateway
$vnetIpConfig = New-AzureVirtualNetworkGatewayIpConfig -Name $vnetGatewayConfigName -PublicIpAddress $publicip -Subnet $subnet

$actual = New-AzureVirtualNetworkGateway -ResourceGroupName $rgname -name $rname -location $location -IpConfigurations $vnetIpConfig -GatewaySize Default -GatewayType DynamicRouting -EnableBgp $false
$actual = New-AzureVirtualNetworkGateway -ResourceGroupName $rgname -name $rname -location $location -IpConfigurations $vnetIpConfig -GatewayType Vpn -VpnType RouteBased -EnableBgp $false
$expected = Get-AzureVirtualNetworkGateway -ResourceGroupName $rgname -name $rname
Assert-AreEqual $expected.ResourceGroupName $actual.ResourceGroupName
Assert-AreEqual $expected.Name $actual.Name
Assert-AreEqual "Default" $expected.GatewaySize
Assert-AreEqual "DynamicRouting" $expected.GatewayType
#Assert-AreEqual "Vpn" $expected.GatewayType
#Assert-AreEqual "RouteBased" $expected.VpnType

# List VirtualNetworkGateways
# List virtualNetworkGateways
$list = Get-AzureVirtualNetworkGateway -ResourceGroupName $rgname
Assert-AreEqual 1 @($list).Count
Assert-AreEqual $list[0].ResourceGroupName $actual.ResourceGroupName
Assert-AreEqual $list[0].Name $actual.Name
Assert-AreEqual $list[0].Location $actual.Location
Assert-AreEqual "Default" $list[0].GatewaySize
Assert-AreEqual "DynamicRouting" $list[0].GatewayType

# Resize virtualNetworkGateway
$actual = Resize-AzureVirtualNetworkGateway -ResourceGroupName $rgname -name $rname -location $location -GatewaySize HighPerformance
$expected = Get-AzureVirtualNetworkGateway -ResourceGroupName $rgname -name $rname
Assert-AreEqual "HighPerformance" $expected.GatewaySize

# Reset virtualNetworkGateway
#$actual = Reset-AzureVirtualNetworkGateway -VirtualNetworkGateway $expected
# Reset/Reboot virtualNetworkGateway primary
$actual = Reset-AzureVirtualNetworkGateway -VirtualNetworkGateway $expected
$list = Get-AzureVirtualNetworkGateway -ResourceGroupName $rgname
Assert-AreEqual 1 @($list).Count

Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<package id="Microsoft.Azure.Gallery" version="2.6.2-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Graph.RBAC" version="1.7.0-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Authorization" version="0.18.2-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Network" version="2.0.3-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Network" version="2.0.4-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Resources" version="2.18.0-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Test.Framework" version="1.0.5571.32271-prerelease" targetFramework="net45" />
<package id="Microsoft.Azure.Test.HttpRecorder" version="1.0.5571.32271-prerelease" targetFramework="net45" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.0.18.2-preview\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Management.Network, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.2.0.3-preview\lib\net40\Microsoft.Azure.Management.Network.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.2.0.4-preview\lib\net40\Microsoft.Azure.Management.Network.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory, Version=2.14.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
Expand Down Expand Up @@ -140,7 +140,6 @@
<Compile Include="VirtualNetworkGateway\NewAzureVirtualNetworkGatewayIpConfigCommand.cs" />
<Compile Include="VirtualNetworkGateway\RemoveAzureVirtualNetworkGatewayCommand.cs" />
<Compile Include="VirtualNetworkGateway\ResetAzureVirtualNetworkGatewayCommand.cs" />
<Compile Include="VirtualNetworkGateway\ResizeAzureVirtualNetworkGatewayCommand.cs" />
<Compile Include="LocalNetworkGateway\LocalNetworkGatewayBaseCmdlet.cs" />
<Compile Include="LocalNetworkGateway\RemoveAzureLocalNetworkGatewayCommand.cs" />
<Compile Include="LocalNetworkGateway\GetAzureLocalNetworkGatewayCommand.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ private PSLocalNetworkGateway CreateLocalNetworkGateway()
localnetGateway.Name = this.Name;
localnetGateway.ResourceGroupName = this.ResourceGroupName;
localnetGateway.Location = this.Location;
localnetGateway.LocalNetworkSiteAddressSpace = new PSAddressSpace();
localnetGateway.LocalNetworkSiteAddressSpace.AddressPrefixes = this.AddressPrefix;
localnetGateway.LocalNetworkAddressSpace = new PSAddressSpace();
localnetGateway.LocalNetworkAddressSpace.AddressPrefixes = this.AddressPrefix;
localnetGateway.GatewayIpAddress = this.GatewayIpAddress;

// Map to the sdk object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@
using MNM = Microsoft.Azure.Management.Network.Models;
using System.Collections;
using Microsoft.Azure.Commands.Tags.Model;
using System.Collections.Generic;

namespace Microsoft.Azure.Commands.Network
{
[Cmdlet(VerbsCommon.Reset, "AzureLocalNetworkGateway"), OutputType(typeof(PSLocalNetworkGateway))]
[Cmdlet(VerbsCommon.Set, "AzureLocalNetworkGateway"), OutputType(typeof(PSLocalNetworkGateway))]
public class SetAzureLocalNetworkGatewayCommand : LocalNetworkGatewayBaseCmdlet
{
[Parameter(
Expand All @@ -33,6 +34,13 @@ public class SetAzureLocalNetworkGatewayCommand : LocalNetworkGatewayBaseCmdlet
HelpMessage = "The LocalNetworkGateway")]
public PSLocalNetworkGateway LocalNetworkGateway { get; set; }

[Parameter(
Mandatory = true,
ValueFromPipelineByPropertyName = true,
HelpMessage = "The address prefixes of the local network to be changed.")]
[ValidateNotNullOrEmpty]
public List<string> AddressPrefix { get; set; }

public override void ExecuteCmdlet()
{
base.ExecuteCmdlet();
Expand All @@ -42,6 +50,8 @@ public override void ExecuteCmdlet()
throw new ArgumentException(Microsoft.Azure.Commands.Network.Properties.Resources.ResourceNotFound);
}

this.LocalNetworkGateway.LocalNetworkAddressSpace.AddressPrefixes = this.AddressPrefix;

// Map to the sdk object
var localnetGatewayModel = Mapper.Map<MNM.LocalNetworkGateway>(this.LocalNetworkGateway);
localnetGatewayModel.Type = Microsoft.Azure.Commands.Network.Properties.Resources.LocalNetworkGatewayType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ public class PSLocalNetworkGateway : PSTopLevelResource
{
public string GatewayIpAddress { get; set; }

public PSAddressSpace LocalNetworkSiteAddressSpace { get; set; }
public PSAddressSpace LocalNetworkAddressSpace { get; set; }

public string ProvisioningState { get; set; }

[JsonIgnore]
public string AddressSpaceText
{
get { return JsonConvert.SerializeObject(LocalNetworkSiteAddressSpace, Formatting.Indented); }
get { return JsonConvert.SerializeObject(LocalNetworkAddressSpace, Formatting.Indented); }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ public class PSVirtualNetworkGateway : PSTopLevelResource
{
public List<PSVirtualNetworkGatewayIpConfiguration> IpConfigurations { get; set; }

public string GatewaySize { get; set; }

public string GatewayType { get; set; }

public string VpnType { get; set; }

public bool EnableBgp { get; set; }

public string ProvisioningState { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,21 @@ public class NewAzureVirtualNetworkGatewayCommand : VirtualNetworkGatewayBaseCmd
[Parameter(
Mandatory = false,
ValueFromPipelineByPropertyName = true,
HelpMessage = "The size of this virtual network gateway.")]
public string GatewaySize { get; set; }
HelpMessage = "The type of this virtual network gateway: Vpn")]
[ValidateSet(
MNM.VirtualNetworkGatewayType.Vpn,
IgnoreCase = true)]
public string GatewayType { get; set; }

[Parameter(
Mandatory = false,
ValueFromPipelineByPropertyName = true,
HelpMessage = "The size of this virtual network gateway.")]
public string GatewayType { get; set; }
HelpMessage = "The type of the Vpn:PolicyBased/RouteBased")]
[ValidateSet(
MNM.VpnType.PolicyBased,
MNM.VpnType.RouteBased,
IgnoreCase = true)]
public string VpnType { get; set; }

[Parameter(
Mandatory = false,
Expand Down Expand Up @@ -120,8 +127,8 @@ private PSVirtualNetworkGateway CreateVirtualNetworkGateway()
vnetGateway.IpConfigurations = this.IpConfigurations;
}

vnetGateway.GatewaySize = this.GatewaySize;
vnetGateway.GatewayType = this.GatewayType;
vnetGateway.VpnType = this.VpnType;
vnetGateway.EnableBgp = this.EnableBgp;

// Map to the sdk object
Expand Down
Loading