Skip to content

Commit 03b7ca7

Browse files
author
Will Ehrich
committed
Add testing and update change log
1 parent 0d28214 commit 03b7ca7

File tree

2 files changed

+45
-2
lines changed

2 files changed

+45
-2
lines changed

src/Network/Network.Test/ScenarioTests/NetworkSecurityGroupTests.ps1

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,8 @@ function Test-NetworkSecurityGroup-MultiValuedRules
263263
$securityRule1Name = Get-ResourceName
264264
$securityRule2Name = Get-ResourceName
265265
$securityRule3Name = Get-ResourceName
266+
$securityRule4Name = Get-ResourceName
267+
$securityRule5Name = Get-ResourceName
266268
$domainNameLabel = Get-ResourceName
267269
$rglocation = Get-ProviderLocation ResourceManagement
268270
$resourceTypeParent = "Microsoft.Network/NetworkSecurityGroups"
@@ -277,9 +279,11 @@ function Test-NetworkSecurityGroup-MultiValuedRules
277279
$securityRule1 = New-AzNetworkSecurityRuleConfig -Name $securityRule1Name -Description "desciption" -Protocol Tcp -SourcePortRange 23-45,80-90 -DestinationPortRange 46-56,70-80 -SourceAddressPrefix 10.10.20.0/24,192.168.0.0/24 -DestinationAddressPrefix 10.10.30.0/24,192.168.2.0/24 -Access Allow -Priority 123 -Direction Inbound
278280
$securityRule2 = New-AzNetworkSecurityRuleConfig -Name $securityRule2Name -Description "desciption" -Protocol Tcp -SourcePortRange 10-20,30-40 -DestinationPortRange 10-20,30-40 -SourceAddressPrefix Storage -DestinationAddressPrefix Storage -Access Allow -Priority 120 -Direction Inbound
279281
$securityRule3 = New-AzNetworkSecurityRuleConfig -Name $securityRule3Name -Description "desciption" -Protocol Icmp -SourcePortRange 50-60,100-110 -DestinationPortRange 120-130,131-140 -SourceAddressPrefix Storage -DestinationAddressPrefix Storage -Access Allow -Priority 125 -Direction Inbound
282+
$securityRule4 = New-AzNetworkSecurityRuleConfig -Name $securityRule4Name -Description "desciption" -Protocol Esp -SourcePortRange 150-160,170-180 -DestinationPortRange 190-200,210-220 -SourceAddressPrefix Storage -DestinationAddressPrefix Storage -Access Allow -Priority 127 -Direction Inbound
283+
$securityRule5 = New-AzNetworkSecurityRuleConfig -Name $securityRule5Name -Description "desciption" -Protocol Ah -SourcePortRange 230-240,250-260 -DestinationPortRange 270-280,290-300 -SourceAddressPrefix Storage -DestinationAddressPrefix Storage -Access Allow -Priority 129 -Direction Inbound
280284

281285
# Create NetworkSecurityGroup
282-
$nsg = New-AzNetworkSecurityGroup -name $nsgName -ResourceGroupName $rgname -Location $location -SecurityRules $securityRule1,$securityRule2,$securityRule3
286+
$nsg = New-AzNetworkSecurityGroup -name $nsgName -ResourceGroupName $rgname -Location $location -SecurityRules $securityRule1,$securityRule2,$securityRule3,$securityRule4,$securityRule5
283287

284288
# Get NetworkSecurityGroup
285289
$getNsg = Get-AzNetworkSecurityGroup -name $nsgName -ResourceGroupName $rgName
@@ -289,7 +293,7 @@ function Test-NetworkSecurityGroup-MultiValuedRules
289293
Assert-AreEqual $nsgName $getNsg.Name
290294
Assert-NotNull $getNsg.Location
291295
Assert-NotNull $getNsg.Etag
292-
Assert-AreEqual 3 @($getNsg.SecurityRules).Count
296+
Assert-AreEqual 5 @($getNsg.SecurityRules).Count
293297
Assert-AreEqual 6 @($getNsg.DefaultSecurityRules).Count
294298
Assert-AreEqual "AllowVnetInBound" $getNsg.DefaultSecurityRules[0].Name
295299
Assert-AreEqual "AllowAzureLoadBalancerInBound" $getNsg.DefaultSecurityRules[1].Name
@@ -353,6 +357,40 @@ function Test-NetworkSecurityGroup-MultiValuedRules
353357
Assert-AreEqual "125" $getNsg.SecurityRules[2].Priority
354358
Assert-AreEqual "Inbound" $getNsg.SecurityRules[2].Direction
355359

360+
# verify rule 4
361+
Assert-AreEqual "desciption" $getNsg.SecurityRules[3].Description
362+
Assert-AreEqual "Esp" $getNsg.SecurityRules[3].Protocol
363+
Assert-AreEqual 2 @($getNsg.SecurityRules[3].SourcePortRange).Count
364+
Assert-AreEqual "150-160" $getNsg.SecurityRules[3].SourcePortRange[0]
365+
Assert-AreEqual "170-180" $getNsg.SecurityRules[3].SourcePortRange[1]
366+
Assert-AreEqual 2 @($getNsg.SecurityRules[3].DestinationPortRange).Count
367+
Assert-AreEqual "190-200" $getNsg.SecurityRules[3].DestinationPortRange[0]
368+
Assert-AreEqual "210-220" $getNsg.SecurityRules[3].DestinationPortRange[1]
369+
Assert-AreEqual 1 @($getNsg.SecurityRules[3].SourceAddressPrefix).Count
370+
Assert-AreEqual "Storage" $getNsg.SecurityRules[3].SourceAddressPrefix[0]
371+
Assert-AreEqual 1 @($getNsg.SecurityRules[3].DestinationAddressPrefix).Count
372+
Assert-AreEqual "Storage" $getNsg.SecurityRules[3].DestinationAddressPrefix[0]
373+
Assert-AreEqual "Allow" $getNsg.SecurityRules[3].Access
374+
Assert-AreEqual "127" $getNsg.SecurityRules[3].Priority
375+
Assert-AreEqual "Inbound" $getNsg.SecurityRules[3].Direction
376+
377+
# verify rule 5
378+
Assert-AreEqual "desciption" $getNsg.SecurityRules[4].Description
379+
Assert-AreEqual "Ah" $getNsg.SecurityRules[4].Protocol
380+
Assert-AreEqual 2 @($getNsg.SecurityRules[4].SourcePortRange).Count
381+
Assert-AreEqual "230-240" $getNsg.SecurityRules[4].SourcePortRange[0]
382+
Assert-AreEqual "250-260" $getNsg.SecurityRules[4].SourcePortRange[1]
383+
Assert-AreEqual 2 @($getNsg.SecurityRules[4].DestinationPortRange).Count
384+
Assert-AreEqual "270-280" $getNsg.SecurityRules[4].DestinationPortRange[0]
385+
Assert-AreEqual "290-300" $getNsg.SecurityRules[4].DestinationPortRange[1]
386+
Assert-AreEqual 1 @($getNsg.SecurityRules[4].SourceAddressPrefix).Count
387+
Assert-AreEqual "Storage" $getNsg.SecurityRules[4].SourceAddressPrefix[0]
388+
Assert-AreEqual 1 @($getNsg.SecurityRules[4].DestinationAddressPrefix).Count
389+
Assert-AreEqual "Storage" $getNsg.SecurityRules[4].DestinationAddressPrefix[0]
390+
Assert-AreEqual "Allow" $getNsg.SecurityRules[4].Access
391+
Assert-AreEqual "129" $getNsg.SecurityRules[4].Priority
392+
Assert-AreEqual "Inbound" $getNsg.SecurityRules[4].Direction
393+
356394
# list
357395
$list = Get-AzNetworkSecurityGroup -ResourceGroupName $rgname
358396
Assert-AreEqual 1 @($list).Count

src/Network/Network/ChangeLog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
--->
2020

2121
## Upcoming Release
22+
* Add support for ESP and AH protocols in network security rule configurations
23+
- Updated cmdlets:
24+
- Add-AzNetworkSecurityRuleConfig
25+
- New-AzNetworkSecurityRuleConfig
26+
- Set-AzNetworkSecurityRuleConfig
2227
* Improve handling of exceptions in Cortex cmdlets
2328
* Fix incorrect example in `New-AzApplicationGateway` reference documentation
2429
* Add note in `Get-AzNetworkWatcherPacketCapture` reference documentation about retrieving all properties for a packet capture

0 commit comments

Comments
 (0)