Skip to content

Commit 1c95f3a

Browse files
committed
Review comments #2
1 parent c8106b8 commit 1c95f3a

30 files changed

+247
-80
lines changed

src/ResourceManager/Network/AzureRM.Network.psd1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,8 @@ CmdletsToExport = 'Add-AzureRmApplicationGatewayAuthenticationCertificate',
307307

308308
# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
309309
AliasesToExport = 'List-AzureRmApplicationGatewayAvailableWafRuleSets',
310-
'List-AzureRmApplicationGatewayAvailableSslOptions'
310+
'List-AzureRmApplicationGatewayAvailableSslOptions',
311+
'List-AzureRmApplicationGatewaySslPredefinedPolicy'
311312

312313
# DSC resources to export from this module
313314
# DscResourcesToExport = @()

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,18 @@ public ApplicationGatewayTests(ITestOutputHelper output)
2828
XunitTracingInterceptor.AddToContext(new XunitTracingInterceptor(output));
2929
}
3030

31+
[Fact]
32+
[Trait(Category.AcceptanceType, Category.CheckIn)]
33+
public void TestAvailableSslOptions()
34+
{
35+
NetworkResourcesController.NewInstance.RunPsTest(string.Format("Test-AvailableSslOptions"));
36+
}
37+
3138
[Fact]
3239
[Trait(Category.AcceptanceType, Category.CheckIn)]
3340
public void TestAvailableWafRuleSets()
3441
{
35-
NetworkResourcesController.NewInstance.RunPsTest(string.Format("Test-AvailableWafRuleSets -baseDir '{0}'", AppDomain.CurrentDomain.BaseDirectory));
42+
NetworkResourcesController.NewInstance.RunPsTest(string.Format("Test-AvailableWafRuleSets"));
3643
}
3744

3845
[Fact]
@@ -41,5 +48,12 @@ public void TestApplicationGatewayCRUD()
4148
{
4249
NetworkResourcesController.NewInstance.RunPsTest(string.Format("Test-ApplicationGatewayCRUD -baseDir '{0}'", AppDomain.CurrentDomain.BaseDirectory));
4350
}
51+
52+
[Fact]
53+
[Trait(Category.AcceptanceType, Category.CheckIn)]
54+
public void TestApplicationGatewayCRUD2()
55+
{
56+
NetworkResourcesController.NewInstance.RunPsTest(string.Format("Test-ApplicationGatewayCRUD2 -baseDir '{0}'", AppDomain.CurrentDomain.BaseDirectory));
57+
}
4458
}
4559
}

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

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,135 @@ function Test-ApplicationGatewayCRUD
285285
}
286286
}
287287

288+
<#
289+
.SYNOPSIS
290+
Application gateway tests
291+
#>
292+
function Test-ApplicationGatewayCRUD2
293+
{
294+
param
295+
(
296+
$basedir = ".\"
297+
)
298+
299+
# Setup
300+
301+
$rglocation = Get-ProviderLocation ResourceManagement
302+
$resourceTypeParent = "Microsoft.Network/applicationgateways"
303+
$location = Get-ProviderLocation $resourceTypeParent
304+
305+
$rgname = Get-ResourceGroupName
306+
$appgwName = Get-ResourceName
307+
$vnetName = Get-ResourceName
308+
$gwSubnetName = Get-ResourceName
309+
$nicSubnetName = Get-ResourceName
310+
$publicIpName = Get-ResourceName
311+
$gipconfigname = Get-ResourceName
312+
313+
$frontendPort01Name = Get-ResourceName
314+
$frontendPort02Name = Get-ResourceName
315+
$fipconfigName = Get-ResourceName
316+
$listener01Name = Get-ResourceName
317+
$listener02Name = Get-ResourceName
318+
319+
$poolName = Get-ResourceName
320+
$poolSetting01Name = Get-ResourceName
321+
322+
$redirect01Name = Get-ResourceName
323+
$redirect02Name = Get-ResourceName
324+
$redirect03Name = Get-ResourceName
325+
$rule01Name = Get-ResourceName
326+
$rule02Name = Get-ResourceName
327+
328+
$probeHttpName = Get-ResourceName
329+
330+
try
331+
{
332+
# Create the resource group
333+
$resourceGroup = New-AzureRmResourceGroup -Name $rgname -Location $location -Tags @{ testtag = "APPGw tag"}
334+
      
335+
# Create the Virtual Network
336+
$gwSubnet = New-AzureRmVirtualNetworkSubnetConfig -Name $gwSubnetName -AddressPrefix 10.0.0.0/24
337+
$nicSubnet = New-AzureRmVirtualNetworkSubnetConfig -Name $nicSubnetName -AddressPrefix 10.0.2.0/24
338+
$vnet = New-AzureRmvirtualNetwork -Name $vnetName -ResourceGroupName $rgname -Location $location -AddressPrefix 10.0.0.0/16 -Subnet $gwSubnet, $nicSubnet
339+
$vnet = Get-AzureRmvirtualNetwork -Name $vnetName -ResourceGroupName $rgname
340+
$gwSubnet = Get-AzureRmVirtualNetworkSubnetConfig -Name $gwSubnetName -VirtualNetwork $vnet
341+
  $nicSubnet = Get-AzureRmVirtualNetworkSubnetConfig -Name $nicSubnetName -VirtualNetwork $vnet
342+
343+
# Create public ip
344+
$publicip = New-AzureRmPublicIpAddress -ResourceGroupName $rgname -name $publicIpName -location $location -AllocationMethod Dynamic
345+
346+
# Create ip configuration
347+
$gipconfig = New-AzureRmApplicationGatewayIPConfiguration -Name $gipconfigname -Subnet $gwSubnet
348+
349+
#frontend part
350+
$fipconfig = New-AzureRmApplicationGatewayFrontendIPConfig -Name $fipconfigName -PublicIPAddress $publicip
351+
$fp01 = New-AzureRmApplicationGatewayFrontendPort -Name $frontendPort01Name  -Port 80
352+
$fp02 = New-AzureRmApplicationGatewayFrontendPort -Name $frontendPort02Name  -Port 81
353+
$listener01 = New-AzureRmApplicationGatewayHttpListener -Name $listener01Name -Protocol Http -FrontendIPConfiguration $fipconfig -FrontendPort $fp01
354+
$listener02 = New-AzureRmApplicationGatewayHttpListener -Name $listener02Name -Protocol Http -FrontendIPConfiguration $fipconfig -FrontendPort $fp02
355+
356+
# backend part
357+
$pool = New-AzureRmApplicationGatewayBackendAddressPool -Name $poolName -BackendIPAddresses www.microsoft.com, www.bing.com
358+
$match = New-AzureRmApplicationGatewayProbeHealthResponseMatch -Body "helloworld" -StatusCode "200-300","404"
359+
$probeHttp = New-AzureRmApplicationGatewayProbeConfig -Name $probeHttpName -Protocol Http -HostName "probe.com" -Path "/path/path.htm" -Interval 89 -Timeout 88 -UnhealthyThreshold 8 -Match $match
360+
$poolSetting01 = New-AzureRmApplicationGatewayBackendHttpSettings -Name $poolSetting01Name -Port 80 -Protocol Http -Probe $probeHttp -CookieBasedAffinity Enabled -ProbeEnabled -PickHostNameFromBackendAddress
361+
362+
# rule part
363+
$redirect01 = New-AzureRmApplicationGatewayRedirectConfiguration -Name $redirect01Name -RedirectType Permanent -TargetListener $listener01
364+
365+
$rule01 = New-AzureRmApplicationGatewayRequestRoutingRule -Name $rule01Name -RuleType basic -BackendHttpSettings $poolSetting01 -HttpListener $listener01 -BackendAddressPool $pool
366+
$rule02 = New-AzureRmApplicationGatewayRequestRoutingRule -Name $rule02Name -RuleType basic -HttpListener $listener02 -RedirectConfiguration $redirect01
367+
368+
$sku = New-AzureRmApplicationGatewaySku -Name Standard_Medium -Tier Standard -Capacity 2
369+
370+
# security part
371+
$sslPolicy = New-AzureRmApplicationGatewaySslPolicy -PolicyType Custom -MinProtocolVersion TLSv1_1 -CipherSuite "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", "TLS_RSA_WITH_AES_128_GCM_SHA256"
372+
373+
# Create Application Gateway
374+
$appgw = New-AzureRmApplicationGateway -Name $appgwName -ResourceGroupName $rgname -Location $location -Probes $probeHttp -BackendAddressPools $pool -BackendHttpSettingsCollection $poolSetting01 -FrontendIpConfigurations $fipconfig -GatewayIpConfigurations $gipconfig -FrontendPorts $fp01, $fp02 -HttpListeners $listener01, $listener02 -RedirectConfiguration $redirect01 -RequestRoutingRules $rule01, $rule02 -Sku $sku -SslPolicy $sslPolicy
375+
376+
# Check get/set/remove for RedirectConfiguration
377+
$redirect02 = Get-AzureRmApplicationGatewayRedirectConfiguration -ApplicationGateway $appgw -Name $redirect01Name
378+
Assert-AreEqual $redirect01.TargetListenerId $redirect02.TargetListenerId
379+
$getgw = Set-AzureRmApplicationGatewayRedirectConfiguration -ApplicationGateway $appgw -Name $redirect01Name -RedirectType Permanent -TargetUrl "https://www.bing.com"
380+
381+
$getgw = Add-AzureRmApplicationGatewayRedirectConfiguration -ApplicationGateway $getgw -Name $redirect03Name -RedirectType Permanent -TargetListener $listener01 -IncludePath
382+
$getgw = Remove-AzureRmApplicationGatewayRedirectConfiguration -ApplicationGateway $getgw -Name $redirect03Name
383+
384+
# Get for SslPolicy
385+
$sslPolicy01 = Get-AzureRmApplicationGatewaySslPolicy -ApplicationGateway $getgw
386+
Assert-AreEqual $sslPolicy.MinProtocolVersion $sslPolicy01.MinProtocolVersion
387+
388+
# Set for sslPolicy
389+
$getgw = Set-AzureRmApplicationGatewaySslPolicy -ApplicationGateway $getgw -PolicyType Predefined -PolicyName AppGwSslPolicy20170401
390+
391+
# Get Match
392+
$probeHttp01 = Get-AzureRmApplicationGatewayProbeConfig -ApplicationGateway $getgw -Name $probeHttpName
393+
Assert-AreEqual $probeHttp.Match.Body $probeHttp01.Match.Body
394+
395+
# Get Application Gateway
396+
$getgw = Get-AzureRmApplicationGateway -Name $appgwName -ResourceGroupName $rgname
397+
398+
# Modify existing application gateway with new configuration
399+
$getgw = Set-AzureRmApplicationGateway -ApplicationGateway $getgw
400+
401+
Assert-AreEqual "Running" $getgw.OperationalState
402+
403+
# Stop Application Gateway
404+
$getgw = Stop-AzureRmApplicationGateway -ApplicationGateway $getgw
405+
406+
Assert-AreEqual "Stopped" $getgw.OperationalState
407+
 
408+
# Delete Application Gateway
409+
Remove-AzureRmApplicationGateway -Name $appgwName -ResourceGroupName $rgname -Force
410+
}
411+
finally
412+
{
413+
# Cleanup
414+
Clean-ResourceGroup $rgname
415+
}
416+
}
288417

289418
<#
290419
.SYNOPSIS

src/ResourceManager/Network/Commands.Network/ApplicationGateway/BackendHttpSettings/AzureApplicationGatewayBackendHttpSettingsBase.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public class AzureApplicationGatewayBackendHttpSettingsBase : NetworkBaseCmdlet
9595

9696
[Parameter(
9797
Mandatory = false,
98-
HelpMessage = "Path which should be used as a prefix for all HTTP requests. Null means no path will be prefixed. Default value is null")]
98+
HelpMessage = "Path which should be used as a prefix for all HTTP requests. If no value is provided for this parameter, then no path will be prefixed.")]
9999
[ValidateNotNullOrEmpty]
100100
public string Path { get; set; }
101101

@@ -144,12 +144,18 @@ public PSApplicationGatewayBackendHttpSettings NewObject()
144144
});
145145
}
146146
}
147-
backendHttpSettings.PickHostNameFromBackendAddress = this.PickHostNameFromBackendAddress;
147+
if(this.PickHostNameFromBackendAddress.IsPresent)
148+
{
149+
backendHttpSettings.PickHostNameFromBackendAddress = true;
150+
}
148151
if (this.AffinityCookieName != null)
149152
{
150153
backendHttpSettings.AffinityCookieName = this.AffinityCookieName;
151154
}
152-
backendHttpSettings.ProbeEnabled = this.ProbeEnabled;
155+
if (this.ProbeEnabled.IsPresent)
156+
{
157+
backendHttpSettings.ProbeEnabled = true;
158+
}
153159
if (this.Path != null)
154160
{
155161
backendHttpSettings.Path = this.Path;
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ public class GetAzureApplicationGatewaySslPredefinedPolicy : ApplicationGatewayB
2929
Mandatory = false,
3030
HelpMessage = "Name of the ssl predefined policy")]
3131
[ValidateNotNullOrEmpty]
32-
public string PredefinedPolicyName { get; set; }
32+
public string Name { get; set; }
3333

3434
public override void ExecuteCmdlet()
3535
{
3636
base.ExecuteCmdlet();
37-
if (this.PredefinedPolicyName != null)
37+
if (this.Name != null)
3838
{
39-
var policy = this.ApplicationGatewayClient.GetSslPredefinedPolicy(this.PredefinedPolicyName);
39+
var policy = this.ApplicationGatewayClient.GetSslPredefinedPolicy(this.Name);
4040
var psPolicy = Mapper.Map<PSApplicationGatewaySslPredefinedPolicy>(policy);
4141
WriteObject(psPolicy);
4242
}
@@ -49,7 +49,7 @@ public override void ExecuteCmdlet()
4949
psPolicies.Add(Mapper.Map<PSApplicationGatewaySslPolicy>(policy));
5050
}
5151

52-
WriteObject(psPolicies);
52+
WriteObject(psPolicies, true);
5353
}
5454
}
5555
}

src/ResourceManager/Network/Commands.Network/ApplicationGateway/Probe/AzureApplicationGatewayProbeConfigBase.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class AzureApplicationGatewayProbeConfigBase : NetworkBaseCmdlet
3434
public string Protocol { get; set; }
3535

3636
[Parameter(
37-
Mandatory = true,
37+
Mandatory = false,
3838
HelpMessage = "Host name to send probe to")]
3939
[ValidateNotNullOrEmpty]
4040
public string HostName { get; set; }
@@ -71,6 +71,7 @@ public class AzureApplicationGatewayProbeConfigBase : NetworkBaseCmdlet
7171
[Parameter(
7272
Mandatory = false,
7373
HelpMessage = "Minimum number of servers that are always marked healthy. Default value is 0")]
74+
[ValidateRange(0, int.MaxValue)]
7475
public uint MinServers { get; set; }
7576

7677
[Parameter(

src/ResourceManager/Network/Commands.Network/ApplicationGateway/ProbeHealthResponseMatch/AzureApplicationGatewayProbeHealthResponseMatchBase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class AzureApplicationGatewayProbeHealthResponseMatchBase : NetworkBaseCm
2929
[Parameter(
3030
HelpMessage = "Allowed ranges of healthy status codes.Default range of healthy status codes is 200 - 399")]
3131
[ValidateNotNullOrEmpty]
32-
public List<string> StatusCodes { get; set; }
32+
public List<string> StatusCode { get; set; }
3333

3434
public override void ExecuteCmdlet()
3535
{
@@ -41,7 +41,7 @@ protected PSApplicationGatewayProbeHealthResponseMatch NewObject()
4141
return new PSApplicationGatewayProbeHealthResponseMatch()
4242
{
4343
Body = this.Body,
44-
StatusCodes = this.StatusCodes
44+
StatusCodes = this.StatusCode
4545
};
4646
}
4747
}

src/ResourceManager/Network/Commands.Network/ApplicationGateway/RedirectConfiguration/AzureApplicationGatewayRedirectConfigurationBase.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,10 @@ public class AzureApplicationGatewayRedirectConfigurationBase : NetworkBaseCmdle
4343
ParameterSetName = "SetByResource",
4444
HelpMessage = "HTTPListener to redirect the request to")]
4545
[ValidateNotNullOrEmpty]
46-
public PSApplicationGatewayBackendHttpSettings TargetListener { get; set; }
46+
public PSApplicationGatewayHttpListener TargetListener { get; set; }
4747

4848
[Parameter(
49+
ParameterSetName = "SetByURL",
4950
HelpMessage = "Target URL fo redirection")]
5051
[ValidateNotNullOrEmpty]
5152
public string TargetUrl { get; set; }
@@ -76,6 +77,7 @@ public PSApplicationGatewayRedirectConfiguration NewObject()
7677
{
7778
var redirectConfiguration = new PSApplicationGatewayRedirectConfiguration();
7879
redirectConfiguration.Name = this.Name;
80+
redirectConfiguration.RedirectType = this.RedirectType;
7981

8082
if (this.TargetUrl != null
8183
&& this.TargetListenerID != null
@@ -92,8 +94,14 @@ public PSApplicationGatewayRedirectConfiguration NewObject()
9294
}
9395

9496
redirectConfiguration.TargetUrl = this.TargetUrl;
95-
redirectConfiguration.IncludePath = this.IncludePath;
96-
redirectConfiguration.IncludeQueryString = this.IncludeQueryString;
97+
if (this.IncludePath)
98+
{
99+
redirectConfiguration.IncludePath = this.IncludePath;
100+
}
101+
if (this.IncludeQueryString)
102+
{
103+
redirectConfiguration.IncludeQueryString = this.IncludeQueryString;
104+
}
97105

98106

99107

src/ResourceManager/Network/Commands.Network/ApplicationGateway/RedirectConfiguration/GetAzureApplicationGatewayRedirectConfigurationCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public override void ExecuteCmdlet()
4646
resource =>
4747
string.Equals(resource.Name, this.Name, System.StringComparison.CurrentCultureIgnoreCase));
4848

49-
WriteObject(redirectConfiguration);
49+
WriteObject(redirectConfiguration, true);
5050
}
5151
else
5252
{

src/ResourceManager/Network/Commands.Network/ApplicationGateway/RedirectConfiguration/RemoveAzureApplicationGatewayRedirectConfigurationCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
namespace Microsoft.Azure.Commands.Network
2020
{
21-
[Cmdlet(VerbsCommon.Remove, "AzureRmApplicationGatewayRedirectConfiguration"), OutputType(typeof(PSApplicationGatewayRedirectConfiguration))]
21+
[Cmdlet(VerbsCommon.Remove, "AzureRmApplicationGatewayRedirectConfiguration"), OutputType(typeof(PSApplicationGateway))]
2222
public class RemoveAzureApplicationGatewayRedirectConfigurationCommand : NetworkBaseCmdlet
2323
{
2424
[Parameter(

src/ResourceManager/Network/Commands.Network/ApplicationGateway/RedirectConfiguration/SetAzureApplicationGatewayRedirectConfigurationCommand.cs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,25 @@ public class SetAzureApplicationGatewayRedirectConfigurationCommand : AzureAppli
2929
public PSApplicationGateway ApplicationGateway { get; set; }
3030
public override void ExecuteCmdlet()
3131
{
32-
base.ExecuteCmdlet();
32+
if (ShouldProcess(Name, Microsoft.Azure.Commands.Network.Properties.Resources.OverwritingResourceMessage))
33+
{
34+
base.ExecuteCmdlet();
3335

34-
var oldRedirectConfiguration = this.ApplicationGateway.RedirectConfigurations.SingleOrDefault
35-
(resource => string.Equals(resource.Name, this.Name, System.StringComparison.CurrentCultureIgnoreCase));
36+
var oldRedirectConfiguration = this.ApplicationGateway.RedirectConfigurations.SingleOrDefault
37+
(resource => string.Equals(resource.Name, this.Name, System.StringComparison.CurrentCultureIgnoreCase));
3638

37-
if (oldRedirectConfiguration == null)
38-
{
39-
throw new ArgumentException("RedirectConfiguration with the specified name does not exist");
40-
}
39+
if (oldRedirectConfiguration == null)
40+
{
41+
throw new ArgumentException("RedirectConfiguration with the specified name does not exist");
42+
}
4143

42-
var newRedirectConfiguration = base.NewObject();
44+
var newRedirectConfiguration = base.NewObject();
4345

44-
this.ApplicationGateway.RedirectConfigurations.Remove(oldRedirectConfiguration);
45-
this.ApplicationGateway.RedirectConfigurations.Add(newRedirectConfiguration);
46+
this.ApplicationGateway.RedirectConfigurations.Remove(oldRedirectConfiguration);
47+
this.ApplicationGateway.RedirectConfigurations.Add(newRedirectConfiguration);
4648

47-
WriteObject(this.ApplicationGateway);
49+
WriteObject(this.ApplicationGateway);
50+
}
4851
}
4952
}
5053
}

0 commit comments

Comments
 (0)