Skip to content

Commit 7cebca7

Browse files
authored
Port latest iis manage task changes to releases/m114 (#3726)
1 parent 0504bc7 commit 7cebca7

23 files changed

+1502
-31
lines changed

Tasks/IISWebAppManagementOnMachineGroup/Strings/resources.resjson/en-US/resources.resjson

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"loc.input.label.WebsiteAuthUserName": "Username",
2626
"loc.input.help.WebsiteAuthUserName": "Provide the user name that will be used to access the website's physical path.",
2727
"loc.input.label.WebsiteAuthUserPassword": "Password",
28-
"loc.input.help.WebsiteAuthUserPassword": "Provide the user's password that will be used to access the website's physical path.",
28+
"loc.input.help.WebsiteAuthUserPassword": "Provide the user's password that will be used to access the website's physical path. <br/>The best practice is to create a variable in the Build or Release definition, and mark it as 'Secret' to secure it, and then use it here, like '$(userCredentials)'. <br> Note: Special characters in password are interpreted as per <a href=\"https://go.microsoft.com/fwlink/?linkid=843470\">command-line arguments</a>",
2929
"loc.input.label.AddBinding": "Add binding",
3030
"loc.input.help.AddBinding": "Select the option to add port binding for the website.",
3131
"loc.input.label.Protocol": "Protocol",
@@ -57,7 +57,7 @@
5757
"loc.input.label.AppPoolUsernameForWebsite": "Username",
5858
"loc.input.help.AppPoolUsernameForWebsite": "Provide the username of the custom account that you want to use.",
5959
"loc.input.label.AppPoolPasswordForWebsite": "Password",
60-
"loc.input.help.AppPoolPasswordForWebsite": "Provide the password for custom account. <br/>The best practice is to create a variable in the Build or Release definition, and mark it as 'Secret' to secure it, and then use it here, like '$(userCredentials)'. ",
60+
"loc.input.help.AppPoolPasswordForWebsite": "Provide the password for custom account. <br/>The best practice is to create a variable in the Build or Release definition, and mark it as 'Secret' to secure it, and then use it here, like '$(userCredentials)'. <br> Note: Special characters in password are interpreted as per <a href=\"https://go.microsoft.com/fwlink/?linkid=843470\">command-line arguments</a>",
6161
"loc.input.label.ParentWebsiteNameForVD": "Parent website name",
6262
"loc.input.help.ParentWebsiteNameForVD": "Provide the name of the parent Website of the virtual directory.",
6363
"loc.input.label.VirtualPathForVD": "Virtual path",
@@ -69,7 +69,7 @@
6969
"loc.input.label.VDAuthUserName": "Username",
7070
"loc.input.help.VDAuthUserName": "Provide the user name that will be used to access the virtual directory's physical path.",
7171
"loc.input.label.VDAuthUserPassword": "Password",
72-
"loc.input.help.VDAuthUserPassword": "Provide the user's password that will be used to access the virtual directory's physical path.",
72+
"loc.input.help.VDAuthUserPassword": "Provide the user's password that will be used to access the virtual directory's physical path. <br/>The best practice is to create a variable in the Build or Release definition, and mark it as 'Secret' to secure it, and then use it here, like '$(userCredentials)'. <br> Note: Special characters in password are interpreted as per <a href=\"https://go.microsoft.com/fwlink/?linkid=843470\">command-line arguments</a>",
7373
"loc.input.label.ParentWebsiteNameForApplication": "Parent website name",
7474
"loc.input.help.ParentWebsiteNameForApplication": "Provide the name of the parent Website under which the application will be created or updated.",
7575
"loc.input.label.VirtualPathForApplication": "Virtual path",
@@ -81,7 +81,7 @@
8181
"loc.input.label.ApplicationAuthUserName": "Username",
8282
"loc.input.help.ApplicationAuthUserName": "Provide the user name that will be used to access the application's physical path.",
8383
"loc.input.label.ApplicationAuthUserPassword": "Password",
84-
"loc.input.help.ApplicationAuthUserPassword": "Provide the user's password that will be used to access the application's physical path.",
84+
"loc.input.help.ApplicationAuthUserPassword": "Provide the user's password that will be used to access the application's physical path. <br/>The best practice is to create a variable in the Build or Release definition, and mark it as 'Secret' to secure it, and then use it here, like '$(userCredentials)'. <br> Note: Special characters in password are interpreted as per <a href=\"https://go.microsoft.com/fwlink/?linkid=843470\">command-line arguments</a>",
8585
"loc.input.label.CreateOrUpdateAppPoolForApplication": "Create or update app pool",
8686
"loc.input.help.CreateOrUpdateAppPoolForApplication": "Select the option to create or update an application pool. If checked, the application will be created in the specified app pool.",
8787
"loc.input.label.AppPoolNameForApplication": "Name",
@@ -95,7 +95,7 @@
9595
"loc.input.label.AppPoolUsernameForApplication": "Username",
9696
"loc.input.help.AppPoolUsernameForApplication": "Provide the username of the custom account that you want to use.",
9797
"loc.input.label.AppPoolPasswordForApplication": "Password",
98-
"loc.input.help.AppPoolPasswordForApplication": "Provide the password for custom account. <br/>The best practice is to create a variable in the Build or Release definition, and mark it as 'Secret' to secure it, and then use it here, like '$(userCredentials)'.",
98+
"loc.input.help.AppPoolPasswordForApplication": "Provide the password for custom account. <br/>The best practice is to create a variable in the Build or Release definition, and mark it as 'Secret' to secure it, and then use it here, like '$(userCredentials)'. <br> Note: Special characters in password are interpreted as per <a href=\"https://go.microsoft.com/fwlink/?linkid=843470\">command-line arguments</a>",
9999
"loc.input.label.AppPoolName": "Name",
100100
"loc.input.help.AppPoolName": "Provide the name of the IIS application pool to create or update.",
101101
"loc.input.label.DotNetVersion": ".NET version",
@@ -107,12 +107,15 @@
107107
"loc.input.label.AppPoolUsername": "Username",
108108
"loc.input.help.AppPoolUsername": "Provide the username of the custom account that you want to use.",
109109
"loc.input.label.AppPoolPassword": "Password",
110-
"loc.input.help.AppPoolPassword": "Provide the password for custom account. <br/>The best practice is to create a variable in the Build or Release definition, and mark it as 'Secret' to secure it, and then use it here, like '$(userCredentials)'.",
110+
"loc.input.help.AppPoolPassword": "Provide the password for custom account. <br/>The best practice is to create a variable in the Build or Release definition, and mark it as 'Secret' to secure it, and then use it here, like '$(userCredentials)'. <br> Note: Special characters in password are interpreted as per <a href=\"https://go.microsoft.com/fwlink/?linkid=843470\">command-line arguments</a>",
111111
"loc.input.label.StartStopRecycleAppPoolName": "Application pool name",
112112
"loc.input.help.StartStopRecycleAppPoolName": "Provide the name of the IIS application pool.",
113113
"loc.input.label.AppCmdCommands": "Additional appcmd.exe commands",
114114
"loc.input.help.AppCmdCommands": "Enter additional AppCmd.exe commands. For more than one command use a line separator, like <br/> list apppools <br/> list sites<br/> recycle apppool /apppool.name:ExampleAppPoolName",
115115
"loc.messages.InvalidSslThumbprint": "Invalid thumbprint. Length is not 40 characters or contains invalid characters.",
116116
"loc.messages.InvalidVirtualPath": "Virtual path should begin with a /",
117-
"loc.messages.InvalidIISDeploymentType": "Invalid IIS Deployment Type : {0}"
117+
"loc.messages.InvalidIISDeploymentType": "Invalid IIS Deployment Type : {0}",
118+
"loc.messages.InvalidActionIISWebsite": "Invalid action '{0}' selected for the IIS Website.",
119+
"loc.messages.InvalidActionIISAppPool": "Invalid action '{0}' selected for the IIS Application Pool.",
120+
"loc.messages.SSLCertWarningInvalidCharacters": "SSL Certificate thumbprint contains non-hexadecimal characters. Trimming all non-hexadecimal characters."
118121
}
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/// <reference path="../../../definitions/mocha.d.ts"/>
2+
/// <reference path="../../../definitions/node.d.ts"/>
3+
/// <reference path="../../../definitions/Q.d.ts"/>
4+
5+
import Q = require('q');
6+
import assert = require('assert');
7+
var path = require('path');
8+
var psm = require('../../../Tests/lib/psRunner');
9+
var shell = require('shelljs');
10+
var ps = shell.which('powershell.exe');
11+
var psr = null;
12+
13+
describe('IISWebAppManagementOnMachineGroup Suite', function () {
14+
this.timeout(20000);
15+
16+
before((done) => {
17+
if (ps) {
18+
psr = new psm.PSRunner();
19+
psr.start();
20+
}
21+
22+
done();
23+
});
24+
25+
after(function () {
26+
psr.kill();
27+
});
28+
29+
if (ps) {
30+
31+
it('test website exists', (done) => {
32+
psr.run(path.join(__dirname, 'L0AppcmdTestWebsiteExists.ps1'), done);
33+
})
34+
35+
it('test add and update website', (done) => {
36+
psr.run(path.join(__dirname, 'L0AppcmdAddUpdateWebsite.ps1'), done);
37+
})
38+
39+
it('test add binding for website', (done) => {
40+
psr.run(path.join(__dirname, 'L0AppcmdTestBinding.ps1'), done);
41+
})
42+
43+
it('test sni and sslcert addition for https binding', (done) => {
44+
psr.run(path.join(__dirname, 'L0AppcmdTestSSLandSNI.ps1'), done);
45+
})
46+
47+
it('test application pool exists', (done) => {
48+
psr.run(path.join(__dirname, 'L0AppcmdTestApplicationPoolExists.ps1'), done);
49+
})
50+
51+
it('test add and update appPool', (done) => {
52+
psr.run(path.join(__dirname, 'L0AppcmdAddUpdateAppPool.ps1'), done);
53+
})
54+
55+
it('test application exists', (done) => {
56+
psr.run(path.join(__dirname, 'L0AppcmdTestApplicationExists.ps1'), done);
57+
})
58+
59+
it('test add and update application', (done) => {
60+
psr.run(path.join(__dirname, 'L0AppcmdAddUpdateApplication.ps1'), done);
61+
})
62+
63+
it('test virtual directory exists', (done) => {
64+
psr.run(path.join(__dirname, 'L0AppcmdTestVirtualDirExists.ps1'), done);
65+
})
66+
67+
it('test add and update virtual directory', (done) => {
68+
psr.run(path.join(__dirname, 'L0AppcmdAddUpdateVDir.ps1'), done);
69+
})
70+
71+
it('test additional actions for website and application pool', (done) => {
72+
psr.run(path.join(__dirname, 'L0AppcmdAdditionalActions.ps1'), done);
73+
})
74+
75+
it('test execute main for appcmd', (done) => {
76+
psr.run(path.join(__dirname, 'L0AppcmdExecuteMain.ps1'), done);
77+
})
78+
79+
it('test iis manage utility - manage website', (done) => {
80+
psr.run(path.join(__dirname, 'L0UtilityManageWebsite.ps1'), done);
81+
})
82+
83+
it('test iis manage utility - manage application', (done) => {
84+
psr.run(path.join(__dirname, 'L0UtilityManageApp.ps1'), done);
85+
})
86+
87+
it('test iis manage utility - manage virtual directory', (done) => {
88+
psr.run(path.join(__dirname, 'L0UtilityManageVDir.ps1'), done);
89+
})
90+
91+
it('test iis manage utility - manage application pool', (done) => {
92+
psr.run(path.join(__dirname, 'L0UtilityManageAppPool.ps1'), done);
93+
})
94+
}
95+
});
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
[CmdletBinding()]
2+
param()
3+
4+
. $PSScriptRoot\..\..\..\Tests\lib\Initialize-Test.ps1
5+
. $PSScriptRoot\MockHelpers.ps1
6+
7+
. $PSScriptRoot\..\ps_modules\TaskModuleIISManageUtility\AppCmdOnTargetMachines.ps1
8+
9+
$appPoolName = "Sample App Pool"
10+
$dotNetVersion = "v4.0"
11+
$pipeLineMode = "Integrated"
12+
$appPoolIdentity = "ApplicationPoolIdentity"
13+
$appPoolCredentials = $null
14+
15+
#Test 1 : App pool doesn't exist. Create and update the app pool
16+
17+
Register-Mock Test-AppPoolExist { return $false }
18+
Register-Mock Invoke-VstsTool { }
19+
20+
Add-And-Update-AppPool -appPoolName $appPoolName -clrVersion $dotNetVersion -pipeLineMode $pipeLineMode -identity $appPoolIdentity -appPoolCredentials $appPoolCredentials
21+
22+
Assert-WasCalled Test-AppPoolExist -Times 1
23+
Assert-WasCalled Invoke-VstsTool -Times 2
24+
Assert-WasCalled Invoke-VstsTool -- -FileName "appcmdPath" -Arguments " add apppool /name:`"Sample App Pool`"" -RequireExitCodeZero
25+
Assert-WasCalled Invoke-VstsTool -- -FileName "appcmdPath" -Arguments " set apppool /apppool.name:`"Sample App Pool`" -managedRuntimeVersion:v4.0 -managedPipelineMode:Integrated -processModel.identityType:ApplicationPoolIdentity" -RequireExitCodeZero
26+
27+
#Test 2 : App pool exists. Update the app pool
28+
29+
$pipeLineMode = "Classic"
30+
$dotNetVersion = "No Managed Code"
31+
$appPoolIdentity = "NetworkService"
32+
33+
Unregister-Mock Test-AppPoolExist
34+
Unregister-Mock Invoke-VstsTool
35+
36+
Register-Mock Test-AppPoolExist { return $true }
37+
Register-Mock Invoke-VstsTool { }
38+
39+
Add-And-Update-AppPool -appPoolName $appPoolName -clrVersion $dotNetVersion -pipeLineMode $pipeLineMode -identity $appPoolIdentity -appPoolCredentials $appPoolCredentials
40+
41+
Assert-WasCalled Test-AppPoolExist -Times 1
42+
Assert-WasCalled Invoke-VstsTool -Times 1
43+
Assert-WasCalled Invoke-VstsTool -- -FileName "appcmdPath" -Arguments " set apppool /apppool.name:`"Sample App Pool`" -managedRuntimeVersion: -managedPipelineMode:Classic -processModel.identityType:NetworkService" -RequireExitCodeZero
44+
45+
#Test 3: Applicatin pool exists and updating the app pool identity for specific user
46+
47+
$pipeLineMode = "Classic"
48+
$dotNetVersion = "v2.0"
49+
$appPoolIdentity = "SpecificUser"
50+
$appPoolCredentials = Get-MockCredentials
51+
52+
Unregister-Mock Test-AppPoolExist
53+
Unregister-Mock Invoke-VstsTool
54+
55+
Register-Mock Test-AppPoolExist { return $true }
56+
Register-Mock Invoke-VstsTool { }
57+
58+
Add-And-Update-AppPool -appPoolName $appPoolName -clrVersion $dotNetVersion -pipeLineMode $pipeLineMode -identity $appPoolIdentity -appPoolCredentials $appPoolCredentials
59+
60+
Assert-WasCalled Test-AppPoolExist -Times 1
61+
Assert-WasCalled Invoke-VstsTool -Times 1
62+
Assert-WasCalled Invoke-VstsTool -- -FileName "appcmdPath" -Arguments " set apppool /apppool.name:`"Sample App Pool`" -managedRuntimeVersion:v2.0 -managedPipelineMode:Classic -processModel.identityType:SpecificUser -processModel.userName:`"domain\name`" -processModel.password:`"random!123```"`$password`"" -RequireExitCodeZero
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
[CmdletBinding()]
2+
param()
3+
4+
. $PSScriptRoot\..\..\..\Tests\lib\Initialize-Test.ps1
5+
. $PSScriptRoot\MockHelpers.ps1
6+
7+
. $PSScriptRoot\..\ps_modules\TaskModuleIISManageUtility\AppCmdOnTargetMachines.ps1
8+
9+
$websiteName = "Sample Web Site"
10+
$virtualPath = "/Application"
11+
$physicalPath = "Drive:/Physical Path"
12+
$appPoolName = ""
13+
$physicalPathAuth = "ApplicationUserPassThrough"
14+
$physicalPathAuthCredentials = $null
15+
16+
Register-Mock Test-Path { return $true } -ParametersEvaluator { $Path -eq $physicalPath }
17+
18+
# Test 1 : Application doesn't exist
19+
20+
Register-Mock Test-ApplicationExist { return $false }
21+
Register-Mock Invoke-VstsTool { }
22+
23+
Add-And-Update-Application -siteName $websiteName -virtualPath $virtualPath -physicalPath $physicalPath -applicationPool $appPoolName -physicalPathAuthentication $physicalPathAuth -physicalPathAuthenticationCredentials $physicalPathAuthCredentials
24+
25+
Assert-WasCalled Test-ApplicationExist -Times 1
26+
Assert-WasCalled Invoke-VstsTool -Times 2
27+
Assert-WasCalled Invoke-VstsTool -- -FileName "appcmdPath" -Arguments " add app /site.name:`"Sample Web Site`" /path:`"/Application`" /physicalPath:`"Drive:/Physical Path`"" -RequireExitCodeZero
28+
Assert-WasCalled Invoke-VstsTool -- -FileName "appcmdPath" -Arguments " set app /app.name:`"Sample Web Site/Application`" -[path='/'].physicalPath:`"Drive:/Physical Path`" -[path='/'].userName: -[path='/'].password:" -RequireExitCodeZero
29+
30+
# Test 2 : Application Exists. Updating properties
31+
32+
$physicalPath = "Drive:/New Physical Path"
33+
$appPoolName = "Sample App Pool"
34+
35+
Unregister-Mock Test-ApplicationExist
36+
Unregister-Mock Invoke-VstsTool
37+
38+
Register-Mock Test-ApplicationExist { return $true }
39+
Register-Mock Invoke-VstsTool { }
40+
41+
Add-And-Update-Application -siteName $websiteName -virtualPath $virtualPath -physicalPath $physicalPath -applicationPool $appPoolName -physicalPathAuthentication $physicalPathAuth -physicalPathAuthenticationCredentials $physicalPathAuthCredentials
42+
43+
Assert-WasCalled Test-ApplicationExist -Times 1
44+
Assert-WasCalled Invoke-VstsTool -Times 1
45+
Assert-WasCalled Invoke-VstsTool -- -FileName "appcmdPath" -Arguments " set app /app.name:`"Sample Web Site/Application`" -applicationPool:`"Sample App Pool`" -[path='/'].physicalPath:`"Drive:/New Physical Path`" -[path='/'].userName: -[path='/'].password:" -RequireExitCodeZero
46+
47+
# Test 3 : Updating the application's physical path authentication
48+
49+
$physicalPathAuth = "ApplicationWindowsAuth"
50+
$physicalPathAuthCredentials = Get-MockCredentials
51+
52+
Unregister-Mock Test-ApplicationExist
53+
Unregister-Mock Invoke-VstsTool
54+
55+
Register-Mock Test-ApplicationExist { return $true }
56+
Register-Mock Invoke-VstsTool { }
57+
58+
Add-And-Update-Application -siteName $websiteName -virtualPath $virtualPath -physicalPath $physicalPath -applicationPool $appPoolName -physicalPathAuthentication $physicalPathAuth -physicalPathAuthenticationCredentials $physicalPathAuthCredentials
59+
60+
Assert-WasCalled Test-ApplicationExist -Times 1
61+
Assert-WasCalled Invoke-VstsTool -Times 1
62+
Assert-WasCalled Invoke-VstsTool -- -FileName "appcmdPath" -Arguments " set app /app.name:`"Sample Web Site/Application`" -applicationPool:`"Sample App Pool`" -[path='/'].physicalPath:`"Drive:/New Physical Path`" -[path='/'].userName:`"domain\name`" -[path='/'].password:`"random!123```"`$password`"" -RequireExitCodeZero
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
[CmdletBinding()]
2+
param()
3+
4+
. $PSScriptRoot\..\..\..\Tests\lib\Initialize-Test.ps1
5+
. $PSScriptRoot\MockHelpers.ps1
6+
7+
. $PSScriptRoot\..\ps_modules\TaskModuleIISManageUtility\AppCmdOnTargetMachines.ps1
8+
9+
$websiteName = "Sample Web Site"
10+
$virtualPath = "/Applcation/VDir"
11+
$physicalPath = "Drive:/Physical Path"
12+
$physicalPathAuth = "VDUserPassThrough"
13+
$physicalPathAuthCredentials = $null
14+
15+
Register-Mock Test-Path { return $true } -ParametersEvaluator { $Path -eq $physicalPath }
16+
17+
#Test 1 : Virtual Directory doesn't exist. Create new
18+
19+
Register-Mock Test-VirtualDirectoryExist { return $false }
20+
Register-Mock Invoke-VstsTool { }
21+
22+
Add-And-Update-VirtualDirectory -siteName $websiteName -virtualPath $virtualPath -physicalPath $physicalPath -physicalPathAuthentication $physicalPathAuth -physicalPathAuthenticationCredentials $physicalPathAuthCredentials
23+
24+
Assert-WasCalled Test-VirtualDirectoryExist -Times 1
25+
Assert-WasCalled Invoke-VstsTool -Times 2
26+
Assert-WasCalled Invoke-VstsTool -- -FileName "appcmdPath" -Arguments " add vdir /app.name:`"Sample Web Site/Applcation`" /path:`"/VDir`" /physicalPath:`"Drive:/Physical Path`"" -RequireExitCodeZero
27+
Assert-WasCalled Invoke-VstsTool -- -FileName "appcmdPath" -Arguments " set vdir /vdir.name:`"Sample Web Site/Applcation/VDir`" -physicalPath:`"Drive:/Physical Path`" -userName: -password:" -RequireExitCodeZero
28+
29+
# Test 2 : Virtual Directory exists. Updating
30+
31+
$physicalPathAuth = "VDWindowsAuth"
32+
$physicalPathAuthCredentials = Get-MockCredentials
33+
34+
Unregister-Mock Test-VirtualDirectoryExist
35+
Unregister-Mock Invoke-VstsTool
36+
37+
Register-Mock Test-VirtualDirectoryExist { return $true }
38+
Register-Mock Invoke-VstsTool { }
39+
40+
Add-And-Update-VirtualDirectory -siteName $websiteName -virtualPath $virtualPath -physicalPath $physicalPath -physicalPathAuthentication $physicalPathAuth -physicalPathAuthenticationCredentials $physicalPathAuthCredentials
41+
42+
Assert-WasCalled Test-VirtualDirectoryExist -Times 1
43+
Assert-WasCalled Invoke-VstsTool -Times 1
44+
Assert-WasCalled Invoke-VstsTool -- -FileName "appcmdPath" -Arguments " set vdir /vdir.name:`"Sample Web Site/Applcation/VDir`" -physicalPath:`"Drive:/Physical Path`" -userName:`"domain\name`" -password:`"random!123```"`$password`"" -RequireExitCodeZero

0 commit comments

Comments
 (0)