Skip to content

Commit c60e802

Browse files
Merge branch 'network-september' into PacketCaptureChanges
2 parents 0d89e8e + 7696797 commit c60e802

20 files changed

+26254
-0
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
namespace Commands.Network.Test.ScenarioTests
16+
{
17+
using Microsoft.Azure.Commands.Network.Test.ScenarioTests;
18+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
19+
using Xunit;
20+
using Xunit.Abstractions;
21+
22+
public class BastionTests : NetworkTestRunner
23+
{
24+
public BastionTests(ITestOutputHelper output)
25+
: base(output)
26+
{
27+
}
28+
29+
[Fact]
30+
[Trait(Category.AcceptanceType, Category.CheckIn)]
31+
[Trait(Category.Owner, Category.bastion)]
32+
public void TestBastionCRUD()
33+
{
34+
TestRunner.RunTestScript("Test-BastionCRUD");
35+
}
36+
37+
[Fact]
38+
[Trait(Category.AcceptanceType, Category.CheckIn)]
39+
[Trait(Category.Owner, Category.bastion)]
40+
public void TestBastionVnetsIpObjectsParams()
41+
{
42+
TestRunner.RunTestScript("Test-BastionVnetsIpObjectsParams");
43+
}
44+
45+
[Fact]
46+
[Trait(Category.AcceptanceType, Category.CheckIn)]
47+
[Trait(Category.Owner, Category.bastion)]
48+
public void TestBastionVnetObjectParam()
49+
{
50+
TestRunner.RunTestScript("Test-BastionVnetObjectParam");
51+
}
52+
53+
[Fact]
54+
[Trait(Category.AcceptanceType, Category.CheckIn)]
55+
[Trait(Category.Owner, Category.bastion)]
56+
public void TestBastionIpObjectParam()
57+
{
58+
TestRunner.RunTestScript("Test-BastionIpObjectParam");
59+
}
60+
}
61+
}
Lines changed: 298 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,298 @@
1+
# ----------------------------------------------------------------------------------
2+
#
3+
# Copyright Microsoft Corporation
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
# ----------------------------------------------------------------------------------
14+
15+
<#
16+
.SYNOPSIS
17+
BastionCRUD
18+
#>
19+
function Test-BastionCRUD
20+
{
21+
22+
#Register-AzResourceProvider -ProviderNamespace "Microsoft.Network"
23+
# Setup
24+
$rgname = Get-ResourceGroupName
25+
$bastionName = Get-ResourceName
26+
$resourceTypeParent = "Microsoft.Network/bastionHosts"
27+
$location = Get-ProviderLocation $resourceTypeParent
28+
29+
$vnetName = Get-ResourceName
30+
$subnetName = "AzureBastionSubnet"
31+
$publicIpName = Get-ResourceName
32+
33+
try
34+
{
35+
# Create the resource group
36+
$resourceGroup = New-AzResourceGroup -Name $rgName -Location $location
37+
38+
# Create the Virtual Network
39+
$subnet = New-AzVirtualNetworkSubnetConfig -Name $subnetName -AddressPrefix 10.0.0.0/24
40+
$vnet = New-AzVirtualNetwork -Name $vnetName -ResourceGroupName $rgname -Location $location -AddressPrefix 10.0.0.0/16 -Subnet $subnet
41+
# Get full subnet details
42+
$subnet = Get-AzVirtualNetworkSubnetConfig -VirtualNetwork $vnet -Name $subnetName
43+
44+
# Create public ip
45+
$publicip = New-AzPublicIpAddress -ResourceGroupName $rgname -name $publicIpName -location $location -AllocationMethod Static -Sku Standard
46+
47+
# Create Bastion
48+
$bastion = New-AzBastion -ResourceGroupName $rgname –Name $bastionName -PublicIpAddressRgName $rgname -PublicIpAddressName $publicIpName -VirtualNetworkRgName $rgname -VirtualNetworkName $vnetName
49+
50+
# Get Bastion by Name
51+
$bastionObj = Get-AzBastion -ResourceGroupName $rgname -Name $bastionName
52+
Assert-NotNull $bastionObj
53+
54+
#verification
55+
Assert-AreEqual $rgName $bastionObj.ResourceGroupName
56+
Assert-AreEqual $bastionName $bastionObj.Name
57+
Assert-NotNull $bastionObj.Etag
58+
Assert-AreEqual 1 @($bastionObj.IpConfigurations).Count
59+
Assert-NotNull $bastionObj.IpConfigurations[0].Subnet.Id
60+
Assert-NotNull $bastionObj.IpConfigurations[0].PublicIpAddress.Id
61+
Assert-AreEqual $subnet.Id $bastionObj.IpConfigurations[0].Subnet.Id
62+
Assert-AreEqual $publicip.Id $bastionObj.IpConfigurations[0].PublicIpAddress.Id
63+
64+
# Get Bastion by Id
65+
$bastionObj = Get-AzBastion -ResourceId $bastion.id
66+
Assert-NotNull $bastionObj
67+
68+
#verification
69+
Assert-AreEqual $rgName $bastionObj.ResourceGroupName
70+
Assert-AreEqual $bastionName $bastionObj.Name
71+
Assert-NotNull $bastionObj.Etag
72+
Assert-AreEqual 1 @($bastionObj.IpConfigurations).Count
73+
Assert-NotNull $bastionObj.IpConfigurations[0].Subnet.Id
74+
Assert-NotNull $bastionObj.IpConfigurations[0].PublicIpAddress.Id
75+
Assert-AreEqual $subnet.Id $bastionObj.IpConfigurations[0].Subnet.Id
76+
Assert-AreEqual $publicip.Id $bastionObj.IpConfigurations[0].PublicIpAddress.Id
77+
78+
# Get all Bastions in ResourceGroup
79+
$bastions = Get-AzBastion -ResourceGroupName $rgName
80+
Assert-NotNull $bastions
81+
82+
# list all Azure Bastion under subscription
83+
$bastionsAll = Get-AzBastion
84+
Assert-NotNull $bastionsAll
85+
86+
# Delete Bastion
87+
$delete = Remove-AzBastion -ResourceGroupName $rgname -Name $bastionName -PassThru -Force
88+
Assert-AreEqual true $delete
89+
90+
# Delete VirtualNetwork
91+
$delete = Remove-AzVirtualNetwork -ResourceGroupName $rgname -name $vnetName -PassThru -Force
92+
Assert-AreEqual true $delete
93+
94+
$list = Get-AzBastion -ResourceGroupName $rgname
95+
Assert-AreEqual 0 @($list).Count
96+
}
97+
finally
98+
{
99+
# Clean up
100+
Clean-ResourceGroup $rgname
101+
}
102+
}
103+
104+
<#
105+
.SYNOPSIS
106+
BastionVnetsIpObjectsParams
107+
#>
108+
function Test-BastionVnetsIpObjectsParams
109+
{
110+
111+
# Setup
112+
$rgname = Get-ResourceGroupName
113+
$bastionName = Get-ResourceName
114+
$resourceTypeParent = "Microsoft.Network/bastionHosts"
115+
$location = Get-ProviderLocation $resourceTypeParent
116+
117+
$vnetName = Get-ResourceName
118+
$subnetName = "AzureBastionSubnet"
119+
$publicIpName = Get-ResourceName
120+
121+
try
122+
{
123+
# Create the resource group
124+
$resourceGroup = New-AzResourceGroup -Name $rgName -Location $location
125+
126+
# Create the Virtual Network
127+
$subnet = New-AzVirtualNetworkSubnetConfig -Name $subnetName -AddressPrefix 10.0.0.0/24
128+
$vnet = New-AzVirtualNetwork -Name $vnetName -ResourceGroupName $rgname -Location $location -AddressPrefix 10.0.0.0/16 -Subnet $subnet
129+
# Get full subnet details
130+
$subnet = Get-AzVirtualNetworkSubnetConfig -VirtualNetwork $vnet -Name $subnetName
131+
132+
# Create public ip
133+
$publicip = New-AzPublicIpAddress -ResourceGroupName $rgname -name $publicIpName -location $location -AllocationMethod Static -Sku Standard
134+
135+
# Create Bastion
136+
$bastion = New-AzBastion -ResourceGroupName $rgname –Name $bastionName -PublicIpAddress $publicip -VirtualNetwork $vnet
137+
138+
# Get Bastion by Name
139+
$bastionObj = Get-AzBastion -ResourceGroupName $rgname -Name $bastionName
140+
Assert-NotNull $bastionObj
141+
142+
#verification
143+
Assert-AreEqual $rgName $bastionObj.ResourceGroupName
144+
Assert-AreEqual $bastionName $bastionObj.Name
145+
Assert-NotNull $bastionObj.Etag
146+
Assert-AreEqual 1 @($bastionObj.IpConfigurations).Count
147+
Assert-NotNull $bastionObj.IpConfigurations[0].Subnet.Id
148+
Assert-NotNull $bastionObj.IpConfigurations[0].PublicIpAddress.Id
149+
Assert-AreEqual $subnet.Id $bastionObj.IpConfigurations[0].Subnet.Id
150+
Assert-AreEqual $publicip.Id $bastionObj.IpConfigurations[0].PublicIpAddress.Id
151+
152+
# Delete Bastion
153+
$delete = Remove-AzBastion -ResourceGroupName $rgname -Name $bastionName -PassThru -Force
154+
Assert-AreEqual true $delete
155+
156+
# Delete VirtualNetwork
157+
$delete = Remove-AzVirtualNetwork -ResourceGroupName $rgname -name $vnetName -PassThru -Force
158+
Assert-AreEqual true $delete
159+
160+
$list = Get-AzBastion -ResourceGroupName $rgname
161+
Assert-AreEqual 0 @($list).Count
162+
}
163+
finally
164+
{
165+
# Clean up
166+
Clean-ResourceGroup $rgname
167+
}
168+
}
169+
<#
170+
.SYNOPSIS
171+
BastionVnetObjectParam
172+
#>
173+
function Test-BastionVnetObjectParam
174+
{
175+
176+
# Setup
177+
$rgname = Get-ResourceGroupName
178+
$bastionName = Get-ResourceName
179+
$resourceTypeParent = "Microsoft.Network/bastionHosts"
180+
$location = Get-ProviderLocation $resourceTypeParent
181+
182+
$vnetName = Get-ResourceName
183+
$subnetName = "AzureBastionSubnet"
184+
$publicIpName = Get-ResourceName
185+
186+
try
187+
{
188+
# Create the resource group
189+
$resourceGroup = New-AzResourceGroup -Name $rgName -Location $location
190+
191+
# Create the Virtual Network
192+
$subnet = New-AzVirtualNetworkSubnetConfig -Name $subnetName -AddressPrefix 10.0.0.0/24
193+
$vnet = New-AzVirtualNetwork -Name $vnetName -ResourceGroupName $rgname -Location $location -AddressPrefix 10.0.0.0/16 -Subnet $subnet
194+
# Get full subnet details
195+
$subnet = Get-AzVirtualNetworkSubnetConfig -VirtualNetwork $vnet -Name $subnetName
196+
197+
# Create public ip
198+
$publicip = New-AzPublicIpAddress -ResourceGroupName $rgname -name $publicIpName -location $location -AllocationMethod Static -Sku Standard
199+
200+
# Create Bastion
201+
$bastion = New-AzBastion -ResourceGroupName $rgname –Name $bastionName -PublicIpAddressRgName $rgname -PublicIpAddressName $publicIpName -VirtualNetwork $vnet
202+
203+
# Get Bastion by Name
204+
$bastionObj = Get-AzBastion -ResourceGroupName $rgname -Name $bastionName
205+
Assert-NotNull $bastionObj
206+
207+
#verification
208+
Assert-AreEqual $rgName $bastionObj.ResourceGroupName
209+
Assert-AreEqual $bastionName $bastionObj.Name
210+
Assert-NotNull $bastionObj.Etag
211+
Assert-AreEqual 1 @($bastionObj.IpConfigurations).Count
212+
Assert-NotNull $bastionObj.IpConfigurations[0].Subnet.Id
213+
Assert-NotNull $bastionObj.IpConfigurations[0].PublicIpAddress.Id
214+
Assert-AreEqual $subnet.Id $bastionObj.IpConfigurations[0].Subnet.Id
215+
Assert-AreEqual $publicip.Id $bastionObj.IpConfigurations[0].PublicIpAddress.Id
216+
217+
# Delete Bastion by ResourceId
218+
$delete = Remove-AzBastion -InputObject $bastionObj -PassThru -Force
219+
Assert-AreEqual true $delete
220+
221+
# Delete VirtualNetwork
222+
$delete = Remove-AzVirtualNetwork -ResourceGroupName $rgname -name $vnetName -PassThru -Force
223+
Assert-AreEqual true $delete
224+
225+
$list = Get-AzBastion -ResourceGroupName $rgname
226+
Assert-AreEqual 0 @($list).Count
227+
}
228+
finally
229+
{
230+
# Clean up
231+
Clean-ResourceGroup $rgname
232+
}
233+
}
234+
<#
235+
.SYNOPSIS
236+
BastionIpObjectParam
237+
#>
238+
function Test-BastionIpObjectParam
239+
{
240+
241+
# Setup
242+
$rgname = Get-ResourceGroupName
243+
$bastionName = Get-ResourceName
244+
$resourceTypeParent = "Microsoft.Network/bastionHosts"
245+
$location = Get-ProviderLocation $resourceTypeParent
246+
247+
$vnetName = Get-ResourceName
248+
$subnetName = "AzureBastionSubnet"
249+
$publicIpName = Get-ResourceName
250+
251+
try
252+
{
253+
# Create the resource group
254+
$resourceGroup = New-AzResourceGroup -Name $rgName -Location $location
255+
256+
# Create the Virtual Network
257+
$subnet = New-AzVirtualNetworkSubnetConfig -Name $subnetName -AddressPrefix 10.0.0.0/24
258+
$vnet = New-AzVirtualNetwork -Name $vnetName -ResourceGroupName $rgname -Location $location -AddressPrefix 10.0.0.0/16 -Subnet $subnet
259+
# Get full subnet details
260+
$subnet = Get-AzVirtualNetworkSubnetConfig -VirtualNetwork $vnet -Name $subnetName
261+
262+
# Create public ip
263+
$publicip = New-AzPublicIpAddress -ResourceGroupName $rgname -name $publicIpName -location $location -AllocationMethod Static -Sku Standard
264+
265+
# Create Bastion
266+
$bastion = New-AzBastion -ResourceGroupName $rgname –Name $bastionName -PublicIpAddress $publicip -VirtualNetworkRgName $rgname -VirtualNetworkName $vnetName
267+
268+
# Get Bastion by Name
269+
$bastionObj = Get-AzBastion -ResourceGroupName $rgname -Name $bastionName
270+
Assert-NotNull $bastionObj
271+
272+
#verification
273+
Assert-AreEqual $rgName $bastionObj.ResourceGroupName
274+
Assert-AreEqual $bastionName $bastionObj.Name
275+
Assert-NotNull $bastionObj.Etag
276+
Assert-AreEqual 1 @($bastionObj.IpConfigurations).Count
277+
Assert-NotNull $bastionObj.IpConfigurations[0].Subnet.Id
278+
Assert-NotNull $bastionObj.IpConfigurations[0].PublicIpAddress.Id
279+
Assert-AreEqual $subnet.Id $bastionObj.IpConfigurations[0].Subnet.Id
280+
Assert-AreEqual $publicip.Id $bastionObj.IpConfigurations[0].PublicIpAddress.Id
281+
282+
# Delete Bastion by ResourceId
283+
$delete = Remove-AzBastion -InputObject $bastionObj -PassThru -Force
284+
Assert-AreEqual true $delete
285+
286+
# Delete VirtualNetwork
287+
$delete = Remove-AzVirtualNetwork -ResourceGroupName $rgname -name $vnetName -PassThru -Force
288+
Assert-AreEqual true $delete
289+
290+
$list = Get-AzBastion -ResourceGroupName $rgname
291+
Assert-AreEqual 0 @($list).Count
292+
}
293+
finally
294+
{
295+
# Clean up
296+
Clean-ResourceGroup $rgname
297+
}
298+
}

0 commit comments

Comments
 (0)