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

Update FrontDoor WAF API to 2019-03-01-preview #5556

Merged
merged 6 commits into from
Mar 25, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion src/SDKs/FrontDoor/AzSdk.RP.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--This file and it's contents are updated at build time moving or editing might result in build failure. Take due deligence while editing this file-->
<PropertyGroup>
<AzureApiTag>Network_2018-08-01;</AzureApiTag>
<AzureApiTag>Network_2018-08-01;Network_2019-03-01;</AzureApiTag>
<PackageTags>$(PackageTags);$(CommonTags);$(AzureApiTag);</PackageTags>
</PropertyGroup>
</Project>
61 changes: 39 additions & 22 deletions src/SDKs/FrontDoor/FrontDoor.Tests/ScenarioTests/FrontDoorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,31 +155,35 @@ public void WAFCRUDTest()
// Create a frontDoor
string policyName = TestUtilities.GenerateName("policy");

WebApplicationFirewallPolicy1 createParameters = new WebApplicationFirewallPolicy1
WebApplicationFirewallPolicy createParameters = new WebApplicationFirewallPolicy
{
Location = "global",
Tags = new Dictionary<string, string>
{
{"key1","value1"},
{"key2","value2"}
},
{
{"key1","value1"},
{"key2","value2"}
},
PolicySettings = new PolicySettings
{
EnabledState = "Enabled",
Mode = "Prevention"
Mode = "Prevention",
CustomBlockResponseBody = "PGh0bWw+SGVsbG88L2h0bWw+",
CustomBlockResponseStatusCode = 403,
RedirectUrl = "http://www.bing.com"
},
CustomRules = new CustomRules(
CustomRules = new CustomRuleList(
new List<CustomRule>
{
new CustomRule
{
Name = "rule1",
EnabledState = "Enabled",
Priority = 1,
RuleType = "RateLimitRule",
RateLimitThreshold = 1000,
MatchConditions = new List<MatchCondition1>
MatchConditions = new List<MatchCondition>
{
new MatchCondition1
new MatchCondition
{
MatchVariable = "RemoteAddr",
OperatorProperty = "IPMatch",
Expand All @@ -194,18 +198,27 @@ public void WAFCRUDTest()
}
}
),
ManagedRules = new ManagedRuleSets(
ManagedRules = new ManagedRuleSetList(
new List <ManagedRuleSet> {
new AzureManagedRuleSet
new ManagedRuleSet
{
Priority = 1,
RuleGroupOverrides = new List<AzureManagedOverrideRuleGroup>
RuleSetType = "DefaultRuleSet",
RuleSetVersion = "1.0",
RuleGroupOverrides = new List<ManagedRuleGroupOverride>
{
new AzureManagedOverrideRuleGroup
new ManagedRuleGroupOverride
{
RuleGroupOverride = "SqlInjection",
Action = "Block"
},
RuleGroupName = "SQLI",
Rules = new List<ManagedRuleOverride>
{
new ManagedRuleOverride
{
RuleId = "Rule1",
Action = "Redirect",
EnabledState = "Disabled"
}
}
}
}
}

Expand All @@ -230,9 +243,9 @@ public void WAFCRUDTest()
Name = "rule2",
Priority = 2,
RuleType = "MatchRule",
MatchConditions = new List<MatchCondition1>
MatchConditions = new List<MatchCondition>
{
new MatchCondition1
new MatchCondition
{
MatchVariable = "RemoteAddr",
OperatorProperty = "GeoMatch",
Expand All @@ -247,7 +260,7 @@ public void WAFCRUDTest()
retrievedPolicy.CustomRules.Rules.Add(geoFilter);


var updatedPolicy = frontDoorMgmtClient.Policies.CreateOrUpdate(resourceGroupName,policyName, retrievedPolicy);
var updatedPolicy = frontDoorMgmtClient.Policies.CreateOrUpdate(resourceGroupName, policyName, retrievedPolicy);

// validate that Policy is correctly updated
VerifyPolicy(updatedPolicy, retrievedPolicy);
Expand All @@ -264,15 +277,19 @@ public void WAFCRUDTest()
FrontDoorTestUtilities.DeleteResourceGroup(resourcesClient, resourceGroupName);
}
}
private static void VerifyPolicy(WebApplicationFirewallPolicy1 policy, WebApplicationFirewallPolicy1 parameters)

private static void VerifyPolicy(WebApplicationFirewallPolicy policy, WebApplicationFirewallPolicy parameters)
{
Assert.Equal(policy.Location.ToLower(), parameters.Location.ToLower());
Assert.Equal(policy.Tags.Count, parameters.Tags.Count);
Assert.True(policy.Tags.SequenceEqual(parameters.Tags));
Assert.Equal(policy.PolicySettings.EnabledState, parameters.PolicySettings.EnabledState);
Assert.Equal(policy.PolicySettings.Mode, parameters.PolicySettings.Mode);
Assert.Equal(policy.PolicySettings.CustomBlockResponseBody, parameters.PolicySettings.CustomBlockResponseBody);
Assert.Equal(policy.PolicySettings.CustomBlockResponseStatusCode, parameters.PolicySettings.CustomBlockResponseStatusCode);
Assert.Equal(policy.PolicySettings.RedirectUrl, parameters.PolicySettings.RedirectUrl);
Assert.Equal(policy.CustomRules.Rules.Count, parameters.CustomRules.Rules.Count);
Assert.Equal(policy.ManagedRules.RuleSets.Count, parameters.ManagedRules.RuleSets.Count);
Assert.Equal(policy.ManagedRules.ManagedRuleSets.Count, parameters.ManagedRules.ManagedRuleSets.Count);
}

private static void VerifyFrontDoor(FrontDoorModel frontDoor, FrontDoorModel parameters)
Expand Down
Loading