Skip to content

Commit e586593

Browse files
committed
Merge pull request Azure#1561 from akurmi/dev
Adding Web App Ssl binding cmdlets and renaming existing Web App cmdlet names to use 'Rm' instead of 'RM'
2 parents c99c1eb + 90088ba commit e586593

40 files changed

+18952
-30
lines changed

src/ResourceManager/Websites/Commands.Websites.Test/Commands.Websites.Test.csproj

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@
6363
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.2.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
6464
<Private>True</Private>
6565
</Reference>
66-
<Reference Include="Microsoft.Azure.Management.WebSites, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
67-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Websites.1.0.0-preview\lib\net45\Microsoft.Azure.Management.Websites.dll</HintPath>
66+
<Reference Include="Microsoft.Azure.Management.Websites, Version=1.0.0.2, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
67+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Websites.1.0.2-preview\lib\net45\Microsoft.Azure.Management.Websites.dll</HintPath>
6868
<Private>True</Private>
6969
</Reference>
7070
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
@@ -141,6 +141,7 @@
141141
<ItemGroup>
142142
<Compile Include="NewAzureWebsitesCommandTests.cs" />
143143
<Compile Include="ScenarioTests\AppServicePlanTests.cs" />
144+
<Compile Include="ScenarioTests\SSLBindingTests.cs" />
144145
<Compile Include="ScenarioTests\WebAppSlotTests.cs" />
145146
<Compile Include="ScenarioTests\WebsitesController.cs" />
146147
<Compile Include="ScenarioTests\WebAppTests.cs" />
@@ -158,6 +159,9 @@
158159
<None Include="ScenarioTests\AppServicePlanTests.ps1">
159160
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
160161
</None>
162+
<None Include="ScenarioTests\SSLBindingTests.ps1">
163+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
164+
</None>
161165
<None Include="ScenarioTests\WebAppSlotTests.ps1">
162166
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
163167
</None>
@@ -179,6 +183,21 @@
179183
<None Include="SessionRecords\Microsoft.Azure.Commands.Websites.Test.ScenarioTests.AppServicePlanTests\TestSetAppServicePlan.json">
180184
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
181185
</None>
186+
<None Include="SessionRecords\Microsoft.Azure.Commands.Websites.Test.ScenarioTests.SSLBindingTests\TestCreateNewWebAppSSLBinding.json">
187+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
188+
</None>
189+
<None Include="SessionRecords\Microsoft.Azure.Commands.Websites.Test.ScenarioTests.SSLBindingTests\TestGetNewWebAppSSLBinding.json">
190+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
191+
</None>
192+
<None Include="SessionRecords\Microsoft.Azure.Commands.Websites.Test.ScenarioTests.SSLBindingTests\TestGetWebAppCertificate.json">
193+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
194+
</None>
195+
<None Include="SessionRecords\Microsoft.Azure.Commands.Websites.Test.ScenarioTests.SSLBindingTests\TestRemoveNewWebAppSSLBinding.json">
196+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
197+
</None>
198+
<None Include="SessionRecords\Microsoft.Azure.Commands.Websites.Test.ScenarioTests.SSLBindingTests\TestWebAppSSLBindingPipeSupport.json">
199+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
200+
</None>
182201
<None Include="SessionRecords\Microsoft.Azure.Commands.Websites.Test.ScenarioTests.WebAppSlotTests\TestCloneWebAppSlot.json">
183202
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
184203
</None>
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
16+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
17+
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
18+
using Xunit;
19+
20+
namespace Microsoft.Azure.Commands.Websites.Test.ScenarioTests
21+
{
22+
public class SSLBindingTests : RMTestBase
23+
{
24+
[Fact]
25+
[Trait(Category.AcceptanceType, Category.CheckIn)]
26+
public void TestCreateNewWebAppSSLBinding()
27+
{
28+
WebsitesController.NewInstance.RunPsTest("Test-CreateNewWebAppSSLBinding");
29+
}
30+
31+
[Fact]
32+
[Trait(Category.AcceptanceType, Category.CheckIn)]
33+
public void TestGetNewWebAppSSLBinding()
34+
{
35+
WebsitesController.NewInstance.RunPsTest("Test-GetNewWebAppSSLBinding");
36+
}
37+
38+
[Fact]
39+
[Trait(Category.AcceptanceType, Category.CheckIn)]
40+
public void TestRemoveNewWebAppSSLBinding()
41+
{
42+
WebsitesController.NewInstance.RunPsTest("Test-RemoveNewWebAppSSLBinding");
43+
}
44+
45+
[Fact]
46+
[Trait(Category.AcceptanceType, Category.CheckIn)]
47+
public void TestWebAppSSLBindingPipeSupport()
48+
{
49+
WebsitesController.NewInstance.RunPsTest("Test-WebAppSSLBindingPipeSupport");
50+
}
51+
52+
[Fact]
53+
[Trait(Category.AcceptanceType, Category.CheckIn)]
54+
public void TestGetWebAppCertificate()
55+
{
56+
WebsitesController.NewInstance.RunPsTest("Test-GetWebAppCertificate");
57+
}
58+
}
59+
}
Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
# ----------------------------------------------------------------------------------
2+
#
3+
# Copyright Microsoft Corporation
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
# ----------------------------------------------------------------------------------
14+
15+
<# If you want to run these tests live then create a Basic/Standard/Premium web app,
16+
assign a custom domain to it and update global variable values.
17+
#>
18+
19+
#Global variables
20+
$rgname = "webappsslbindingrb"
21+
$appname = "webappsslbindingtest"
22+
$slot = "testslot"
23+
$prodHostname = "www.webappsslbindingtests.com"
24+
$slotHostname = "testslot.webappsslbindingtests.com"
25+
$thumbprint = "40D6600B0B8740C41BA4B3D13B967DDEF6ED1918"
26+
27+
<#
28+
.SYNOPSIS
29+
Tests creating a new Web App SSL binding.
30+
#>
31+
function Test-CreateNewWebAppSSLBinding
32+
{
33+
try
34+
{
35+
# Test - Create Ssl binding for web app
36+
$createResult = New-AzureRMWebAppSSLBinding -ResourceGroupName $rgname -WebAppName $appname -Name $prodHostname -Thumbprint $thumbprint
37+
Assert-AreEqual $prodHostname $createResult.Name
38+
39+
# Test - Create Ssl binding for web app slot
40+
$createResult = New-AzureRMWebAppSSLBinding -ResourceGroupName $rgname -WebAppName $appname -Slot $slot -Name $slotHostname -Thumbprint $thumbprint
41+
Assert-AreEqual $slotHostname $createResult.Name
42+
}
43+
finally
44+
{
45+
# Cleanup
46+
Remove-AzureRMWebAppSSLBinding -ResourceGroupName $rgname -WebAppName $appname -Name $prodHostname -Force
47+
Remove-AzureRMWebAppSSLBinding -ResourceGroupName $rgname -WebAppName $appname -Slot $slot -Name $slotHostname -Force
48+
}
49+
}
50+
51+
<#
52+
.SYNOPSIS
53+
Tests retrieving Web App SSL binding.
54+
#>
55+
function Test-GetNewWebAppSSLBinding
56+
{
57+
try
58+
{
59+
# Setup - Create Ssl bindings
60+
$createWebAppResult = New-AzureRMWebAppSSLBinding -ResourceGroupName $rgname -WebAppName $appname -Name $prodHostname -Thumbprint $thumbprint
61+
$createWebAppSlotResult = New-AzureRMWebAppSSLBinding -ResourceGroupName $rgname -WebAppName $appname -Slot $slot -Name $slotHostname -Thumbprint $thumbprint
62+
63+
# Test - Get commands for web app
64+
$getResult = Get-AzureRMWebAppSSLBinding -ResourceGroupName $rgname -WebAppName $appname
65+
Assert-AreEqual 2 $getResult.Count
66+
$currentHostNames = $getResult | Select -expand Name
67+
Assert-True { $currentHostNames -contains $createWebAppResult.Name }
68+
$getResult = Get-AzureRMWebAppSSLBinding -ResourceGroupName $rgname -WebAppName $appname -Name $prodHostname
69+
Assert-AreEqual $getResult.Name $createWebAppResult.Name
70+
71+
# Test - Get commands for web app slot
72+
$getResult = Get-AzureRMWebAppSSLBinding -ResourceGroupName $rgname -WebAppName $appname -Slot $slot
73+
Assert-AreEqual 1 $getResult.Count
74+
$currentHostNames = $getResult | Select -expand Name
75+
Assert-True { $currentHostNames -contains $createWebAppSlotResult.Name }
76+
$getResult = Get-AzureRMWebAppSSLBinding -ResourceGroupName $rgname -WebAppName $appname -Slot $slot -Name $slotHostname
77+
Assert-AreEqual $getResult.Name $createWebAppSlotResult.Name
78+
}
79+
finally
80+
{
81+
# Cleanup
82+
Remove-AzureRMWebAppSSLBinding -ResourceGroupName $rgname -WebAppName $appname -Name $prodHostname -Force
83+
Remove-AzureRMWebAppSSLBinding -ResourceGroupName $rgname -WebAppName $appname -Slot $slot -Name $slotHostname -Force
84+
}
85+
}
86+
87+
<#
88+
.SYNOPSIS
89+
Tests removing Web App SSL binding.
90+
#>
91+
function Test-RemoveNewWebAppSSLBinding
92+
{
93+
try
94+
{
95+
# Setup - Create Ssl bindings
96+
New-AzureRMWebAppSSLBinding -ResourceGroupName $rgname -WebAppName $appname -Name $prodHostname -Thumbprint $thumbprint
97+
New-AzureRMWebAppSSLBinding -ResourceGroupName $rgname -WebAppName $appname -Slot $slot -Name $slotHostname -Thumbprint $thumbprint
98+
99+
# Tests - Removing binding from web app and web app slot
100+
Remove-AzureRMWebAppSSLBinding -ResourceGroupName $rgname -WebAppName $appname -Name $prodHostname -Force
101+
Remove-AzureRMWebAppSSLBinding -ResourceGroupName $rgname -WebAppName $appname -Slot $slot -Name $slotHostname -Force
102+
103+
# Assert
104+
$res = Get-AzureRMWebAppSSLBinding -ResourceGroupName $rgname -WebAppName $appname
105+
$currentHostNames = $res | Select -expand Name
106+
Assert-False { $currentHostNames -contains $prodHostname }
107+
108+
$res = Get-AzureRMWebAppSSLBinding -ResourceGroupName $rgname -WebAppName $appname -Slot $slot
109+
$currentHostNames = $res | Select -expand Name
110+
Assert-False { $currentHostNames -contains $slotHostName }
111+
}
112+
finally
113+
{
114+
# Cleanup
115+
Remove-AzureRMWebAppSSLBinding -ResourceGroupName $rgname -WebAppName $appname -Name $prodHostname -Force
116+
Remove-AzureRMWebAppSSLBinding -ResourceGroupName $rgname -WebAppName $appname -Slot $slot -Name $slotHostname -Force
117+
}
118+
}
119+
120+
<#
121+
.SYNOPSIS
122+
Tests executing Ssl binding cmdlets using pipe
123+
#>
124+
function Test-WebAppSSLBindingPipeSupport
125+
{
126+
try
127+
{
128+
# Setup - Retrieve web app and web app slot objects
129+
$webapp = Get-AzureRMWebApp -ResourceGroupName $rgname -Name $appname
130+
$webappslot = Get-AzureRMWebAppSlot -ResourceGroupName $rgname -Name $appname -Slot $slot
131+
132+
# Test - Create Ssl bindings using web app and web app slot objects
133+
$createResult = $webapp | New-AzureRMWebAppSSLBinding -Name $prodHostName -Thumbprint $thumbprint
134+
Assert-AreEqual $prodHostName $createResult.Name
135+
136+
$createResult = $webappslot | New-AzureRMWebAppSSLBinding -Name $slotHostName -Thumbprint $thumbprint
137+
Assert-AreEqual $slotHostName $createResult.Name
138+
139+
# Test - Retrieve Ssl bindings using web app and web app slot objects
140+
$getResult = $webapp | Get-AzureRMWebAppSSLBinding
141+
Assert-AreEqual 2 $getResult.Count
142+
143+
$getResult = $webappslot | Get-AzureRMWebAppSSLBinding
144+
Assert-AreEqual 1 $getResult.Count
145+
146+
# Test - Delete Ssl bindings using web app and web app slot objects
147+
$webapp | Remove-AzureRMWebAppSSLBinding -Name $prodHostName -Force
148+
$res = $webapp | Get-AzureRMWebAppSSLBinding
149+
$currentHostNames = $res | Select -expand Name
150+
Assert-False { $currentHostNames -contains $prodHostName }
151+
152+
$webappslot | Remove-AzureRMWebAppSSLBinding -Name $slotHostName -Force
153+
$res = $webappslot | Get-AzureRMWebAppSSLBinding
154+
$currentHostNames = $res | Select -expand Name
155+
Assert-False { $currentHostNames -contains $slotHostName }
156+
}
157+
finally
158+
{
159+
# Cleanup
160+
Remove-AzureRMWebAppSSLBinding -ResourceGroupName $rgname -WebAppName $appname -Name $prodHostName -Force
161+
Remove-AzureRMWebAppSSLBinding -ResourceGroupName $rgname -WebAppName $appname -Slot $slot -Name $slotHostName -Force
162+
}
163+
}
164+
165+
<#
166+
.SYNOPSIS
167+
Tests retrieving web app certificates
168+
#>
169+
function Test-GetWebAppCertificate
170+
{
171+
try
172+
{
173+
# Setup - Create Ssl bindings
174+
New-AzureRMWebAppSSLBinding -ResourceGroupName $rgname -WebAppName $appname -Name $prodHostname -Thumbprint $thumbprint
175+
176+
# Tests - Retrieve web app certificate objects
177+
$certificates = Get-AzureRMWebAppCertificate
178+
$thumbprints = $certificates | Select -expand Thumbprint
179+
Assert-True { $thumbprints -contains $thumbprint }
180+
181+
$certificate = Get-AzureRMWebAppCertificate -Thumbprint $thumbprint
182+
Assert-AreEqual $thumbprint $certificate.Thumbprint
183+
}
184+
finally
185+
{
186+
# Cleanup
187+
Remove-AzureRMWebAppSSLBinding -ResourceGroupName $rgname -WebAppName $appname -Name $prodHostName -Force
188+
}
189+
}

0 commit comments

Comments
 (0)