-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added L0 tests for IIS Web App Manage task (#3705)
- Loading branch information
Showing
23 changed files
with
1,476 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/// <reference path="../../../definitions/mocha.d.ts"/> | ||
/// <reference path="../../../definitions/node.d.ts"/> | ||
/// <reference path="../../../definitions/Q.d.ts"/> | ||
|
||
import Q = require('q'); | ||
import assert = require('assert'); | ||
var path = require('path'); | ||
var psm = require('../../../Tests/lib/psRunner'); | ||
var shell = require('shelljs'); | ||
var ps = shell.which('powershell.exe'); | ||
var psr = null; | ||
|
||
describe('IISWebAppManagementOnMachineGroup Suite', function () { | ||
this.timeout(20000); | ||
|
||
before((done) => { | ||
if (ps) { | ||
psr = new psm.PSRunner(); | ||
psr.start(); | ||
} | ||
|
||
done(); | ||
}); | ||
|
||
after(function () { | ||
psr.kill(); | ||
}); | ||
|
||
if (ps) { | ||
|
||
it('test website exists', (done) => { | ||
psr.run(path.join(__dirname, 'L0AppcmdTestWebsiteExists.ps1'), done); | ||
}) | ||
|
||
it('test add and update website', (done) => { | ||
psr.run(path.join(__dirname, 'L0AppcmdAddUpdateWebsite.ps1'), done); | ||
}) | ||
|
||
it('test website add binding', (done) => { | ||
psr.run(path.join(__dirname, 'L0AppcmdTestBinding.ps1'), done); | ||
}) | ||
|
||
it('test sni and sslcert addition', (done) => { | ||
psr.run(path.join(__dirname, 'L0AppcmdTestSSLandSNI.ps1'), done); | ||
}) | ||
|
||
it('test application pool exists', (done) => { | ||
psr.run(path.join(__dirname, 'L0AppcmdTestApplicationPoolExists.ps1'), done); | ||
}) | ||
|
||
it('test add and update appPool', (done) => { | ||
psr.run(path.join(__dirname, 'L0AppcmdAddUpdateAppPool.ps1'), done); | ||
}) | ||
|
||
it('test application exists', (done) => { | ||
psr.run(path.join(__dirname, 'L0AppcmdTestApplicationExists.ps1'), done); | ||
}) | ||
|
||
it('test add and update application function', (done) => { | ||
psr.run(path.join(__dirname, 'L0AppcmdAddUpdateApplication.ps1'), done); | ||
}) | ||
|
||
it('test virtual directory exists function', (done) => { | ||
psr.run(path.join(__dirname, 'L0AppcmdTestVirtualDirExists.ps1'), done); | ||
}) | ||
|
||
it('test add and update virtual directory function', (done) => { | ||
psr.run(path.join(__dirname, 'L0AppcmdAddUpdateVDir.ps1'), done); | ||
}) | ||
|
||
it('test additional actions', (done) => { | ||
psr.run(path.join(__dirname, 'L0AppcmdAdditionalActions.ps1'), done); | ||
}) | ||
|
||
it('test execute-main function', (done) => { | ||
psr.run(path.join(__dirname, 'L0AppcmdExecuteMain.ps1'), done); | ||
}) | ||
|
||
it('test iis manage utility - manage virtual directory', (done) => { | ||
psr.run(path.join(__dirname, 'L0UtilityManageVDir.ps1'), done); | ||
}) | ||
|
||
it('test iis manage utility - manage application', (done) => { | ||
psr.run(path.join(__dirname, 'L0UtilityManageApp.ps1'), done); | ||
}) | ||
|
||
it('test iis manage utility - manage application pool', (done) => { | ||
psr.run(path.join(__dirname, 'L0UtilityManageAppPool.ps1'), done); | ||
}) | ||
|
||
it('test iis manage utility - manage website', (done) => { | ||
psr.run(path.join(__dirname, 'L0UtilityManageWebsite.ps1'), done); | ||
}) | ||
} | ||
}); |
62 changes: 62 additions & 0 deletions
62
Tasks/IISWebAppManagementOnMachineGroup/Tests/L0AppcmdAddUpdateAppPool.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
[CmdletBinding()] | ||
param() | ||
|
||
. $PSScriptRoot\..\..\..\Tests\lib\Initialize-Test.ps1 | ||
. $PSScriptRoot\MockHelpers.ps1 | ||
|
||
. $PSScriptRoot\..\ps_modules\TaskModuleIISManageUtility\AppCmdOnTargetMachines.ps1 | ||
|
||
$appPoolName = "Sample App Pool" | ||
$dotNetVersion = "v4.0" | ||
$pipeLineMode = "Integrated" | ||
$appPoolIdentity = "ApplicationPoolIdentity" | ||
$appPoolCredentials = $null | ||
|
||
#Test 1 : App pool doesn't exist. Create and update the app pool | ||
|
||
Register-Mock Test-AppPoolExist { return $false } | ||
Register-Mock Invoke-VstsTool { } | ||
|
||
Add-And-Update-AppPool -appPoolName $appPoolName -clrVersion $dotNetVersion -pipeLineMode $pipeLineMode -identity $appPoolIdentity -appPoolCredentials $appPoolCredentials | ||
|
||
Assert-WasCalled Test-AppPoolExist -Times 1 | ||
Assert-WasCalled Invoke-VstsTool -Times 2 | ||
Assert-WasCalled Invoke-VstsTool -- -FileName "appcmdPath" -Arguments " add apppool /name:`"Sample App Pool`"" -RequireExitCodeZero | ||
Assert-WasCalled Invoke-VstsTool -- -FileName "appcmdPath" -Arguments " set apppool /apppool.name:`"Sample App Pool`" -managedRuntimeVersion:v4.0 -managedPipelineMode:Integrated -processModel.identityType:ApplicationPoolIdentity" -RequireExitCodeZero | ||
|
||
#Test 2 : App pool exists. Update the app pool | ||
|
||
$pipeLineMode = "Classic" | ||
$dotNetVersion = "No Managed Code" | ||
$appPoolIdentity = "NetworkService" | ||
|
||
Unregister-Mock Test-AppPoolExist | ||
Unregister-Mock Invoke-VstsTool | ||
|
||
Register-Mock Test-AppPoolExist { return $true } | ||
Register-Mock Invoke-VstsTool { } | ||
|
||
Add-And-Update-AppPool -appPoolName $appPoolName -clrVersion $dotNetVersion -pipeLineMode $pipeLineMode -identity $appPoolIdentity -appPoolCredentials $appPoolCredentials | ||
|
||
Assert-WasCalled Test-AppPoolExist -Times 1 | ||
Assert-WasCalled Invoke-VstsTool -Times 1 | ||
Assert-WasCalled Invoke-VstsTool -- -FileName "appcmdPath" -Arguments " set apppool /apppool.name:`"Sample App Pool`" -managedRuntimeVersion: -managedPipelineMode:Classic -processModel.identityType:NetworkService" -RequireExitCodeZero | ||
|
||
#Test 3: Applicatin pool exists and updating the app pool identity for specific user | ||
|
||
$pipeLineMode = "Classic" | ||
$dotNetVersion = "v2.0" | ||
$appPoolIdentity = "SpecificUser" | ||
$appPoolCredentials = Get-MockCredentials | ||
|
||
Unregister-Mock Test-AppPoolExist | ||
Unregister-Mock Invoke-VstsTool | ||
|
||
Register-Mock Test-AppPoolExist { return $true } | ||
Register-Mock Invoke-VstsTool { } | ||
|
||
Add-And-Update-AppPool -appPoolName $appPoolName -clrVersion $dotNetVersion -pipeLineMode $pipeLineMode -identity $appPoolIdentity -appPoolCredentials $appPoolCredentials | ||
|
||
Assert-WasCalled Test-AppPoolExist -Times 1 | ||
Assert-WasCalled Invoke-VstsTool -Times 1 | ||
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 |
62 changes: 62 additions & 0 deletions
62
Tasks/IISWebAppManagementOnMachineGroup/Tests/L0AppcmdAddUpdateApplication.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
[CmdletBinding()] | ||
param() | ||
|
||
. $PSScriptRoot\..\..\..\Tests\lib\Initialize-Test.ps1 | ||
. $PSScriptRoot\MockHelpers.ps1 | ||
|
||
. $PSScriptRoot\..\ps_modules\TaskModuleIISManageUtility\AppCmdOnTargetMachines.ps1 | ||
|
||
$websiteName = "Sample Web Site" | ||
$virtualPath = "/Application" | ||
$physicalPath = "Drive:/Physical Path" | ||
$appPoolName = "" | ||
$physicalPathAuth = "ApplicationUserPassThrough" | ||
$physicalPathAuthCredentials = $null | ||
|
||
Register-Mock Test-Path { return $true } -ParametersEvaluator { $Path -eq $physicalPath } | ||
|
||
# Test 1 : Application doesn't exist | ||
|
||
Register-Mock Test-ApplicationExist { return $false } | ||
Register-Mock Invoke-VstsTool { } | ||
|
||
Add-And-Update-Application -siteName $websiteName -virtualPath $virtualPath -physicalPath $physicalPath -applicationPool $appPoolName -physicalPathAuthentication $physicalPathAuth -physicalPathAuthenticationCredentials $physicalPathAuthCredentials | ||
|
||
Assert-WasCalled Test-ApplicationExist -Times 1 | ||
Assert-WasCalled Invoke-VstsTool -Times 2 | ||
Assert-WasCalled Invoke-VstsTool -- -FileName "appcmdPath" -Arguments " add app /site.name:`"Sample Web Site`" /path:`"/Application`" /physicalPath:`"Drive:/Physical Path`"" -RequireExitCodeZero | ||
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 | ||
|
||
# Test 2 : Application Exists. Updating properties | ||
|
||
$physicalPath = "Drive:/New Physical Path" | ||
$appPoolName = "Sample App Pool" | ||
|
||
Unregister-Mock Test-ApplicationExist | ||
Unregister-Mock Invoke-VstsTool | ||
|
||
Register-Mock Test-ApplicationExist { return $true } | ||
Register-Mock Invoke-VstsTool { } | ||
|
||
Add-And-Update-Application -siteName $websiteName -virtualPath $virtualPath -physicalPath $physicalPath -applicationPool $appPoolName -physicalPathAuthentication $physicalPathAuth -physicalPathAuthenticationCredentials $physicalPathAuthCredentials | ||
|
||
Assert-WasCalled Test-ApplicationExist -Times 1 | ||
Assert-WasCalled Invoke-VstsTool -Times 1 | ||
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 | ||
|
||
# Test 3 : Updating the application's physical path authentication | ||
|
||
$physicalPathAuth = "ApplicationWindowsAuth" | ||
$physicalPathAuthCredentials = Get-MockCredentials | ||
|
||
Unregister-Mock Test-ApplicationExist | ||
Unregister-Mock Invoke-VstsTool | ||
|
||
Register-Mock Test-ApplicationExist { return $true } | ||
Register-Mock Invoke-VstsTool { } | ||
|
||
Add-And-Update-Application -siteName $websiteName -virtualPath $virtualPath -physicalPath $physicalPath -applicationPool $appPoolName -physicalPathAuthentication $physicalPathAuth -physicalPathAuthenticationCredentials $physicalPathAuthCredentials | ||
|
||
Assert-WasCalled Test-ApplicationExist -Times 1 | ||
Assert-WasCalled Invoke-VstsTool -Times 1 | ||
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 |
44 changes: 44 additions & 0 deletions
44
Tasks/IISWebAppManagementOnMachineGroup/Tests/L0AppcmdAddUpdateVDir.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
[CmdletBinding()] | ||
param() | ||
|
||
. $PSScriptRoot\..\..\..\Tests\lib\Initialize-Test.ps1 | ||
. $PSScriptRoot\MockHelpers.ps1 | ||
|
||
. $PSScriptRoot\..\ps_modules\TaskModuleIISManageUtility\AppCmdOnTargetMachines.ps1 | ||
|
||
$websiteName = "Sample Web Site" | ||
$virtualPath = "/Applcation/VDir" | ||
$physicalPath = "Drive:/Physical Path" | ||
$physicalPathAuth = "VDUserPassThrough" | ||
$physicalPathAuthCredentials = $null | ||
|
||
Register-Mock Test-Path { return $true } -ParametersEvaluator { $Path -eq $physicalPath } | ||
|
||
#Test 1 : Virtual Directory doesn't exist. Create new | ||
|
||
Register-Mock Test-VirtualDirectoryExist { return $false } | ||
Register-Mock Invoke-VstsTool { } | ||
|
||
Add-And-Update-VirtualDirectory -siteName $websiteName -virtualPath $virtualPath -physicalPath $physicalPath -physicalPathAuthentication $physicalPathAuth -physicalPathAuthenticationCredentials $physicalPathAuthCredentials | ||
|
||
Assert-WasCalled Test-VirtualDirectoryExist -Times 1 | ||
Assert-WasCalled Invoke-VstsTool -Times 2 | ||
Assert-WasCalled Invoke-VstsTool -- -FileName "appcmdPath" -Arguments " add vdir /app.name:`"Sample Web Site/Applcation`" /path:`"/VDir`" /physicalPath:`"Drive:/Physical Path`"" -RequireExitCodeZero | ||
Assert-WasCalled Invoke-VstsTool -- -FileName "appcmdPath" -Arguments " set vdir /vdir.name:`"Sample Web Site/Applcation/VDir`" -physicalPath:`"Drive:/Physical Path`" -userName: -password:" -RequireExitCodeZero | ||
|
||
# Test 2 : Virtual Directory exists. Updating | ||
|
||
$physicalPathAuth = "VDWindowsAuth" | ||
$physicalPathAuthCredentials = Get-MockCredentials | ||
|
||
Unregister-Mock Test-VirtualDirectoryExist | ||
Unregister-Mock Invoke-VstsTool | ||
|
||
Register-Mock Test-VirtualDirectoryExist { return $true } | ||
Register-Mock Invoke-VstsTool { } | ||
|
||
Add-And-Update-VirtualDirectory -siteName $websiteName -virtualPath $virtualPath -physicalPath $physicalPath -physicalPathAuthentication $physicalPathAuth -physicalPathAuthenticationCredentials $physicalPathAuthCredentials | ||
|
||
Assert-WasCalled Test-VirtualDirectoryExist -Times 1 | ||
Assert-WasCalled Invoke-VstsTool -Times 1 | ||
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 |
Oops, something went wrong.