Skip to content

Commit

Permalink
Merge pull request Azure#13474 from VeryEarly/internal/network-july
Browse files Browse the repository at this point in the history
Internal/network july
  • Loading branch information
VeryEarly authored Nov 10, 2020
2 parents a8ae7fd + bdfc5a0 commit 808f984
Show file tree
Hide file tree
Showing 313 changed files with 41,321 additions and 28,338 deletions.
2 changes: 1 addition & 1 deletion src/Batch/Batch.Test/Batch.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<PackageReference Include="Microsoft.Azure.Batch" Version="13.0.0" />
<PackageReference Include="Microsoft.Azure.Management.Batch" Version="11.0.0" />
<PackageReference Include="WindowsAzure.Storage" Version="9.3.0" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="20.1.1" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="20.2.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.CognitiveServices" Version="7.4.0-preview" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="20.1.1" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="20.2.0" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/Compute/Compute.Test/Compute.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<PackageReference Include="Microsoft.Azure.Graph.RBAC" Version="3.4.0-preview" />
<PackageReference Include="Microsoft.Azure.Management.Compute" Version="39.0.0" />
<PackageReference Include="Microsoft.Azure.Management.KeyVault" Version="3.1.0-preview.2" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="20.1.1" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="20.2.0" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/CosmosDB/CosmosDB.Test/CosmosDB.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
</PropertyGroup>
<Import Project="$(MSBuildThisFileDirectory)..\..\Az.Test.props" />
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.Network" Version="20.1.1" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="20.2.0" />
<PackageReference Include="Microsoft.Azure.Management.CosmosDB" Version="1.2.1" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.DataLake.Store" Version="2.4.2-preview" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="20.1.1" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="20.2.0" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Dns/Dns.Test/Dns.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.Dns" Version="3.0.1" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="20.1.1" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="20.2.0" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/HDInsight/HDInsight.Test/HDInsight.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<PackageReference Include="Microsoft.Azure.Management.HDInsight.Job" Version="2.0.7" />
<PackageReference Include="Microsoft.Azure.Management.KeyVault" Version="3.1.0-preview.2" />
<PackageReference Include="Microsoft.Azure.Management.ManagedServiceIdentity" Version="0.11.0" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="20.1.1" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="20.2.0" />
<PackageReference Include="Microsoft.Azure.Management.OperationalInsights" Version="0.21.0-preview" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/HPCCache/HPCCache.Test/HPCCache.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.Authorization" Version="2.11.0-preview" />
<PackageReference Include="Microsoft.Azure.Management.Storage" Version="14.5.0" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="20.1.1" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="20.2.0" />
<PackageReference Include="WindowsAzure.Storage" Version="9.3.0" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/KeyVault/KeyVault.Test/KeyVault.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<PackageReference Include="Microsoft.Azure.KeyVault" Version="3.0.1" />
<PackageReference Include="Microsoft.Azure.KeyVault.WebKey" Version="3.0.1" />
<PackageReference Include="Microsoft.Azure.Management.KeyVault" Version="3.1.0-preview.2" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="20.1.1" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="20.2.0" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Monitor/Monitor.Test/Monitor.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.Monitor" Version="0.25.2-preview" />
<PackageReference Include="Microsoft.Azure.Management.ApplicationInsights" Version="0.3.0-preview" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="20.1.1" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="20.2.0" />
<PackageReference Include="Microsoft.Azure.Management.OperationalInsights" Version="0.21.0-preview" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/NetAppFiles/NetAppFiles.Test/NetAppFiles.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.NetApp" Version="1.7.0" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="20.1.1" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="20.2.0" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/Network/Network.Test/Network.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Graph.RBAC" Version="3.4.0-preview" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="20.1.1" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="20.2.0" />
<PackageReference Include="Microsoft.Azure.KeyVault" Version="3.0.5" />
<PackageReference Include="Microsoft.Azure.Management.KeyVault" Version="3.1.0-preview.2" />
<PackageReference Include="Microsoft.Azure.Insights" Version="0.16.0-preview" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,13 @@ public void TestAzureFirewallPolicyWithIpGroups()
{
TestRunner.RunTestScript("Test-AzureFirewallPolicyWithIpGroups");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
[Trait(Category.Owner, NrpTeamAlias.azurefirewall)]
public void TestAzureFirewallPolicyCRUDWithNatRuleTranslatedFQDN()
{
TestRunner.RunTestScript("Test-AzureFirewallPolicyCRUDWithNatRuleTranslatedFQDN");
}
}
}
118 changes: 118 additions & 0 deletions src/Network/Network.Test/ScenarioTests/AzureFirewallPolicyTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -756,3 +756,121 @@ function Test-AzureFirewallPolicyWithIpGroups {
Clean-ResourceGroup $rgname
}
}

<#
.SYNOPSIS
Tests function Test-AzureFirewallPolicyCRUDWithNatRuleTranslatedFQDN.
#>
function Test-AzureFirewallPolicyCRUDWithNatRuleTranslatedFQDN {
# Setup
$rgname = Get-ResourceGroupName
$azureFirewallPolicyName = Get-ResourceName
$azureFirewallPolicyAsJobName = Get-ResourceName
$resourceTypeParent = "Microsoft.Network/FirewallPolicies"
$location = "canadacentral"

$ruleGroupName = Get-ResourceName

# AzureFirewallPolicyNatRuleCollection
$natRcName = "natRc"
$natRcPriority = 100
$natRcActionType = "Dnat"

# AzureFirewallPolicyNatRule 1
$natRule1Name = "natRule"
$natRule1Desc = "desc1"
$natRule1SourceAddress1 = "10.0.0.0"
$natRule1SourceAddress2 = "111.1.0.0/24"
$natRule1Protocol1 = "UDP"
$natRule1Protocol2 = "TCP"
$natRule1DestinationAddress1 = "10.10.10.1"
$natRule1DestinationPort1 = "90"
$natRule1TranslatedFqdn = "server1.internal.com"
$natRule1TranslatedPort = "91"

$pipelineRcPriority = 154

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

# Create AzureFirewallPolicy
$azureFirewallPolicy = New-AzFirewallPolicy -Name $azureFirewallPolicyName -ResourceGroupName $rgname -Location $location

# 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-AreEqual "Alert" $getAzureFirewallPolicy.ThreatIntelMode

# Create NAT rule
$natRule = New-AzFirewallPolicyNatRule -Name $natRule1Name -Description $natRule1Desc -Protocol $natRule1Protocol1, $natRule1Protocol2 -SourceAddress $natRule1SourceAddress1, $natRule1SourceAddress2 -DestinationAddress $natRule1DestinationAddress1 -DestinationPort $natRule1DestinationPort1 -TranslatedFqdn $natRule1TranslatedFqdn -TranslatedPort $natRule1TranslatedPort

# Create a NAT Rule Collection
$natRc = New-AzFirewallPolicyNatRuleCollection -Name $natRcName -ActionType $natRcActionType -Priority $natRcPriority -Rule $natRule

New-AzFirewallPolicyRuleCollectionGroup -Name $ruleGroupName -Priority 100 -RuleCollection $natRc -FirewallPolicyObject $azureFirewallPolicy

# Set AzureFirewallPolicy
Set-AzFirewallPolicy -InputObject $azureFirewallPolicy
# 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 $location $getAzureFirewallPolicy.Location

# Check rule collection groups count
Assert-AreEqual 1 @($getAzureFirewallPolicy.RuleCollectionGroups).Count

$getRg = Get-AzFirewallPolicyRuleCollectionGroup -Name $ruleGroupName -AzureFirewallPolicy $getAzureFirewallPolicy

Assert-AreEqual 1 @($getRg.properties.ruleCollection).Count

$natRuleCollection = $getRg.Properties.GetRuleCollectionByName($natRcName)

# Verify NAT rule collection and NAT rule
$natRule = $natRuleCollection.GetRuleByName($natRule1Name)

Assert-AreEqual $natRcName $natRuleCollection.Name
Assert-AreEqual $natRcPriority $natRuleCollection.Priority

Assert-AreEqual $natRule1Name $natRule.Name

Assert-AreEqual 2 $natRule.SourceAddresses.Count
Assert-AreEqual $natRule1SourceAddress1 $natRule.SourceAddresses[0]
Assert-AreEqual $natRule1SourceAddress2 $natRule.SourceAddresses[1]

Assert-AreEqual 1 $natRule.DestinationAddresses.Count

Assert-AreEqual 2 $natRule.Protocols.Count
Assert-AreEqual $natRule1Protocol1 $natRule.Protocols[0]
Assert-AreEqual $natRule1Protocol2 $natRule.Protocols[1]

Assert-AreEqual 1 $natRule.DestinationPorts.Count
Assert-AreEqual $natRule1DestinationPort1 $natRule.DestinationPorts[0]

Assert-AreEqual $natRule1TranslatedFqdn $natRule.TranslatedFqdn
Assert-AreEqual $natRule1TranslatedPort $natRule.TranslatedPort


$testPipelineRg = Get-AzFirewallPolicyRuleCollectionGroup -Name $ruleGroupName -AzureFirewallPolicyName $getAzureFirewallPolicy.Name -ResourceGroupName $rgname
$testPipelineRg|Set-AzFirewallPolicyRuleCollectionGroup -Priority $pipelineRcPriority
$testPipelineRg = Get-AzFirewallPolicyRuleCollectionGroup -Name $ruleGroupName -AzureFirewallPolicyName $getAzureFirewallPolicy.Name -ResourceGroupName $rgname
Assert-AreEqual $pipelineRcPriority $testPipelineRg.properties.Priority

$azureFirewallPolicyAsJob = New-AzFirewallPolicy -Name $azureFirewallPolicyAsJobName -ResourceGroupName $rgname -Location $location -AsJob
$result = $azureFirewallPolicyAsJob | Wait-Job
Assert-AreEqual "Completed" $result.State
}
finally {
# Cleanup
Clean-ResourceGroup $rgname
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2437,7 +2437,7 @@ function Test-CreateSubresourcesOnEmptyLoadBalancer
Assert-NotNull $ipConfig

$lb = Add-AzLoadBalancerBackendAddressPoolConfig -Name $poolName -LoadBalancer $lb
$lb = Add-AzLoadBalancerProbeConfig -Name $probeName -LoadBalancer $lb -Port 2000 -IntervalInSeconds 60 -ProbeCount 3
$lb = Add-AzLoadBalancerProbeConfig -Name $probeName -LoadBalancer $lb -Port 2000 -IntervalInSeconds 60 -ProbeCount 3 -Protocol Tcp
$lb = Add-AzLoadBalancerRuleConfig -Name $ruleName -LoadBalancer $lb -FrontendIpConfiguration $ipConfig -Protocol Tcp -FrontendPort 1024 -BackendPort 2048
$lb = Add-AzLoadBalancerInboundNatRuleConfig -Name $natRuleName -LoadBalancer $lb -FrontendIpConfiguration $ipConfig -FrontendPort 128 -BackendPort 256

Expand Down
Loading

0 comments on commit 808f984

Please sign in to comment.