Skip to content

Commit b62ec36

Browse files
PS changes for Uppercase Transform (#19546)
1 parent 4ffd95b commit b62ec36

File tree

6 files changed

+1406
-4
lines changed

6 files changed

+1406
-4
lines changed

src/Network/Network.Test/ScenarioTests/ApplicationGatewayTests.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,5 +230,14 @@ public void TestApplicationGatewayFirewallPolicyWithCustomRules()
230230
{
231231
TestRunner.RunTestScript("Test-ApplicationGatewayFirewallPolicyWithCustomRules");
232232
}
233+
234+
235+
[Fact]
236+
[Trait(Category.AcceptanceType, Category.CheckIn)]
237+
[Trait(Category.Owner, NrpTeamAlias.nvadev_subset1)]
238+
public void TestApplicationGatewayFirewallPolicyWithUppercaseTransform()
239+
{
240+
TestRunner.RunTestScript("Test-ApplicationGatewayFirewallPolicyWithUppercaseTransform");
241+
}
233242
}
234243
}

src/Network/Network.Test/ScenarioTests/ApplicationGatewayTests.ps1

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4208,3 +4208,54 @@ function Test-ApplicationGatewayFirewallPolicyWithCustomRules
42084208
Clean-ResourceGroup $rgname
42094209
}
42104210
}
4211+
4212+
function Test-ApplicationGatewayFirewallPolicyWithUppercaseTransform
4213+
{
4214+
# Setup
4215+
$location = Get-ProviderLocation "Microsoft.Network/applicationGateways" "West US 2"
4216+
4217+
$rgname = Get-ResourceGroupName
4218+
$wafPolicy = Get-ResourceName
4219+
4220+
try
4221+
{
4222+
$resourceGroup = New-AzResourceGroup -Name $rgname -Location $location -Tags @{ testtag = "APPGw tag"}
4223+
4224+
# WAF Policy and Custom Rule
4225+
$variable = New-AzApplicationGatewayFirewallMatchVariable -VariableName RequestHeaders -Selector Content-Length
4226+
$condition = New-AzApplicationGatewayFirewallCondition -MatchVariable $variable -Operator GreaterThan -MatchValue 1000 -Transform Uppercase -NegationCondition $False
4227+
$rule = New-AzApplicationGatewayFirewallCustomRule -Name example -Priority 2 -RuleType MatchRule -MatchCondition $condition -Action Block
4228+
$policySettings = New-AzApplicationGatewayFirewallPolicySetting -Mode Prevention -State Enabled -MaxFileUploadInMb 70 -MaxRequestBodySizeInKb 70
4229+
$managedRuleSet = New-AzApplicationGatewayFirewallPolicyManagedRuleSet -RuleSetType "OWASP" -RuleSetVersion "3.2"
4230+
$managedRule = New-AzApplicationGatewayFirewallPolicyManagedRule -ManagedRuleSet $managedRuleSet
4231+
New-AzApplicationGatewayFirewallPolicy -Name $wafPolicy -ResourceGroupName $rgname -Location $location -ManagedRule $managedRule -PolicySetting $policySettings
4232+
4233+
$policy = Get-AzApplicationGatewayFirewallPolicy -Name $wafPolicy -ResourceGroupName $rgname
4234+
$policy.CustomRules = $rule
4235+
Set-AzApplicationGatewayFirewallPolicy -InputObject $policy
4236+
4237+
$policy = Get-AzApplicationGatewayFirewallPolicy -Name $wafPolicy -ResourceGroupName $rgname
4238+
4239+
# Second check firewll policy
4240+
Assert-AreEqual $policy.CustomRules[0].Name $rule.Name
4241+
Assert-AreEqual $policy.CustomRules[0].RuleType $rule.RuleType
4242+
Assert-AreEqual $policy.CustomRules[0].Action $rule.Action
4243+
Assert-AreEqual $policy.CustomRules[0].Priority $rule.Priority
4244+
Assert-AreEqual $policy.CustomRules[0].MatchConditions[0].OperatorProperty $rule.MatchConditions[0].OperatorProperty
4245+
Assert-AreEqual $policy.CustomRules[0].MatchConditions[0].Transforms[0] $rule.MatchConditions[0].Transforms[0]
4246+
Assert-AreEqual $policy.CustomRules[0].MatchConditions[0].NegationConditon $rule.MatchConditions[0].NegationConditon
4247+
Assert-AreEqual $policy.CustomRules[0].MatchConditions[0].MatchValues[0] $rule.MatchConditions[0].MatchValues[0]
4248+
Assert-AreEqual $policy.CustomRules[0].MatchConditions[0].MatchVariables[0].VariableName $rule.MatchConditions[0].MatchVariables[0].VariableName
4249+
Assert-AreEqual $policy.CustomRules[0].MatchConditions[0].MatchVariables[0].Selector $rule.MatchConditions[0].MatchVariables[0].Selector
4250+
Assert-AreEqual $policy.PolicySettings.FileUploadLimitInMb $policySettings.FileUploadLimitInMb
4251+
Assert-AreEqual $policy.PolicySettings.MaxRequestBodySizeInKb $policySettings.MaxRequestBodySizeInKb
4252+
Assert-AreEqual $policy.PolicySettings.RequestBodyCheck $policySettings.RequestBodyCheck
4253+
Assert-AreEqual $policy.PolicySettings.Mode $policySettings.Mode
4254+
Assert-AreEqual $policy.PolicySettings.State $policySettings.State
4255+
}
4256+
finally
4257+
{
4258+
# Cleanup
4259+
Clean-ResourceGroup $rgname
4260+
}
4261+
}

src/Network/Network.Test/SessionRecords/Commands.Network.Test.ScenarioTests.ApplicationGatewayTests/TestApplicationGatewayFirewallPolicyWithUppercaseTransform.json

Lines changed: 1341 additions & 0 deletions
Large diffs are not rendered by default.

src/Network/Network/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
* Updated commandlets to support specifying an ASN on VPN Gateway
3030
- `NewAzureRmVpnGatewayCommand.cs`
3131
- `UpdateAzureRmVpnGatewayCommand.cs`
32+
* Added Uppercase Transform in New-AzApplicationGatewayFirewallCondition
3233

3334
## Version 4.20.1
3435
* Added breaking change notification for `Get-AzFirewall`, `New-AzFirewall`, `Set-AzFirewall` and `New-AzFirewallHubIpAddress`

src/Network/Network/FirewallPolicy/FirewallCondition/AzureApplicationGatewayFirewallConditionBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public class AzureApplicationGatewayFirewallConditionBase : NetworkBaseCmdlet
5050
[Parameter(
5151
Mandatory = false,
5252
HelpMessage = "List of transforms.")]
53-
[ValidateSet("Lowercase", "Trim", "UrlDecode", "UrlEncode", "RemoveNulls", "HtmlEntityDecode", IgnoreCase = true)]
53+
[ValidateSet("Uppercase","Lowercase", "Trim", "UrlDecode", "UrlEncode", "RemoveNulls", "HtmlEntityDecode", IgnoreCase = true)]
5454
[ValidateNotNullOrEmpty]
5555
public string[] Transform { get; set; }
5656

src/Network/Network/help/New-AzApplicationGatewayFirewallCondition.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Creates a match condition for custom rule
1414

1515
```
1616
New-AzApplicationGatewayFirewallCondition -MatchVariable <PSApplicationGatewayFirewallMatchVariable[]>
17-
-Operator <String> [-NegationCondition <Boolean>] -MatchValue <String[]> [-Transform <String[]>]
17+
-Operator <String> [-NegationCondition <Boolean>] [-MatchValue <String[]>] [-Transform <String[]>]
1818
[-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
1919
```
2020

@@ -55,7 +55,7 @@ Type: System.String[]
5555
Parameter Sets: (All)
5656
Aliases:
5757

58-
Required: True
58+
Required: False
5959
Position: Named
6060
Default value: None
6161
Accept pipeline input: False
@@ -115,7 +115,7 @@ List of transforms.
115115
Type: System.String[]
116116
Parameter Sets: (All)
117117
Aliases:
118-
Accepted values: Lowercase, Trim, UrlDecode, UrlEncode, RemoveNulls, HtmlEntityDecode
118+
Accepted values: Uppercase, Lowercase, Trim, UrlDecode, UrlEncode, RemoveNulls, HtmlEntityDecode
119119

120120
Required: False
121121
Position: Named

0 commit comments

Comments
 (0)