Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Private Range (No SNAT) Support to Firewall Policies #14577

Merged
merged 11 commits into from
Mar 29, 2021
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 @@ -132,5 +132,13 @@ public void TestAzureFirewallPolicyPremiumWithTerminateTLSEnabledAndTargetUrls()
{
TestRunner.RunTestScript("Test-AzureFirewallPolicyPremiumWithTerminateTLSEnabledAndTargetUrls");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
[Trait(Category.Owner, NrpTeamAlias.azurefirewall)]
public void TestAzureFirewallPolicyPrivateRangeCRUD()
{
TestRunner.RunTestScript("Test-AzureFirewallPolicyPrivateRangeCRUD");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1417,4 +1417,48 @@ function Test-AzureFirewallPolicyPremiumFeatures {
# Cleanup
Clean-ResourceGroup $rgname
}
}

<#
.SYNOPSIS
Tests AzureFirewall Policy PrivateRange
#>
function Test-AzureFirewallPolicyPrivateRangeCRUD {
$rgname = Get-ResourceGroupName
$azureFirewallPolicyName = Get-ResourceName
$resourceTypeParent = "Microsoft.Network/FirewallPolicies"
$location = "westus2"
$vnetName = Get-ResourceName
$privateRange2 = @("IANAPrivateRanges", "0.0.0.0/0", "66.92.0.0/16")
$privateRange1 = @("3.3.0.0/24", "98.0.0.0/8")
$privateRange2Translated = @("0.0.0.0/0", "66.92.0.0/16", "10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16", "100.64.0.0/10")

try {

# Create the resource group
$resourceGroup = New-AzResourceGroup -Name $rgname -Location $location -Tags @{ testtag = "testval" }

# Create AzureFirewallPolicy (with no rules, ThreatIntel is in Alert mode by default)
$azureFirewallPolicy = New-AzFirewallPolicy -Name $azureFirewallPolicyName -ResourceGroupName $rgname -Location $location -PrivateRange $privateRange1

# Get AzureFirewallPolicy
$getAzureFirewallPolicy = Get-AzFirewallPolicy -Name $azureFirewallPolicyName -ResourceGroupName $rgname

#verification
Assert-AreEqual $rgName $getAzureFirewallPolicy.ResourceGroupName
Assert-AreEqual $azureFirewallPolicyName $getAzureFirewallPolicy.Name
Assert-NotNull $getAzureFirewallPolicy.Location
Assert-AreEqual (Normalize-Location $location) $getAzureFirewallPolicy.Location
Assert-AreEqualArray $privateRange1 $getAzureFirewallPolicy.PrivateRange

# Modify
$azureFirewallPolicy.PrivateRange = $privateRange2
Set-AzFirewallPolicy -InputObject $azureFirewallPolicy
$getAzureFirewallPolicy = Get-AzFirewallPolicy -Name $azureFirewallPolicyName -ResourceGroupName $rgname
Assert-AreEqualArray $privateRange2Translated $getAzureFirewallPolicy.PrivateRange
}
finally {
# Cleanup
Clean-ResourceGroup $rgname
}
}
Loading