-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#115 Merged cmdlets and tests of Session (with PesterV5, 132)... Brok…
…e compatiblity regarding ParameterSets based on Issuer, TimeoutIssue, TimeoutService and PSCredential... Tests are working...
- Loading branch information
ddemeyer
committed
Sep 15, 2021
1 parent
cd0dad0
commit 19ef488
Showing
8 changed files
with
319 additions
and
145 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
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
75 changes: 75 additions & 0 deletions
75
Source/ISHRemote/Trisoft.ISHRemote/Cmdlets/Session/TestIshSession.Tests.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,75 @@ | ||
BeforeAll { | ||
$cmdletName = "Test-IshSession" | ||
Write-Host ("`r`nLoading ISHRemote.PesterSetup.ps1 over BeforeAll-block for MyCommand[" + $cmdletName + "]...") | ||
. (Join-Path (Split-Path -Parent $PSCommandPath) "\..\..\ISHRemote.PesterSetup.ps1") | ||
|
||
Write-Host ("Running "+$cmdletName+" Test Data and Variables initialization") | ||
} | ||
|
||
Describe "Test-IshSession" -Tags "Read" { | ||
Context "Test-IshSession ISHDeploy::Enable-ISHIntegrationSTSInternalAuthentication/Prepare-SupportAccess.ps1" { | ||
It "Parameter WsBaseUrl contains 'SDL' (legacy script)" -Skip { | ||
Test-IshSession -WsBaseUrl https://example.com/ISHWS/SDL/ -IshUserName x -IshPassword y | Should -Be $true | ||
} | ||
It "Parameter WsBaseUrl contains 'Internal' (ISHDeploy)" -Skip { | ||
Test-IshSession -WsBaseUrl https://example.com/ISHWS/Internal/ -IshUserName x -IshPassword y | Should -Be $true | ||
} | ||
} | ||
|
||
Context "Test-IshSession UserNamePassword" { | ||
It "Parameter WsBaseUrl invalid" { | ||
Test-IshSession -WsBaseUrl "http:///INVALIDWSBASEURL" -IshUserName "INVALIDISHUSERNAME" -IshPassword "INVALIDISHPASSWORD" | Should -Be $false | ||
} | ||
It "Parameter IshUserName invalid" { | ||
Test-IshSession -WsBaseUrl $webServicesBaseUrl -IshUserName "INVALIDISHUSERNAME" -IshPassword "INVALIDISHPASSWORD" | Should -Be $false | ||
} | ||
It "Parameter IshPassword specified" { | ||
Test-IshSession -WsBaseUrl $webServicesBaseUrl -IshUserName $ishUserName -IshPassword "INVALIDISHPASSWORD" | Should -Be $false | ||
} | ||
} | ||
|
||
Context "Test-IshSession returns bool" { | ||
BeforeAll { | ||
$ishSessionResult = Test-IshSession -WsBaseUrl $webServicesBaseUrl -IshUserName $ishUserName -IshPassword $ishPassword | ||
} | ||
It "GetType()" { | ||
$ishSessionResult.GetType().Name | Should -BeExactly "Boolean" | ||
} | ||
} | ||
|
||
Context "Test-IshSession WsBaseUrl without ending slash" { | ||
It "WsBaseUrl without ending slash" { | ||
# .NET throws unhandy "Reference to undeclared entity 'raquo'." error | ||
$webServicesBaseUrlWithoutEndingSlash = $webServicesBaseUrl.Substring(0,$webServicesBaseUrl.Length-1) | ||
Test-IshSession -WsBaseUrl $webServicesBaseUrlWithoutEndingSlash -IshUserName $ishUserName -IshPassword $ishPassword | Should -Be $true | ||
} | ||
} | ||
|
||
Context "Test-IshSession Timeout" { | ||
It "Parameter Timeout Invalid" { | ||
{ Test-IshSession -WsBaseUrl $webServicesBaseUrl -IshUserName $ishUserName -IshPassword $ishPassword -Timeout "INVALIDTIMEOUT" } | Should -Throw | ||
} | ||
It "IshSession.Timeout on INVALID url set to 1ms execution" { | ||
# TaskCanceledException: A task was canceled. | ||
$invalidWebServicesBaseUrl = $webServicesBaseUrl -replace "://", "://INVALID" | ||
Test-IshSession -WsBaseUrl $invalidWebServicesBaseUrl -IshUserName $ishUserName -IshPassword $ishPassword -Timeout (New-Object TimeSpan(0,0,0,0,1)) | Should -Be $false | ||
} | ||
} | ||
|
||
Context "Test-IshSession IgnoreSslPolicyErrors" { | ||
It "Parameter IgnoreSslPolicyErrors specified negative flow (segment-one-url)" -Skip { | ||
# replace hostname like machinename.somedomain.com to machinename only, marked as skipped for non-development machines | ||
$slash1Position = $webServicesBaseUrl.IndexOf("/") | ||
$slash2Position = $webServicesBaseUrl.IndexOf("/",$slash1Position+1) | ||
$slash3Position = $webServicesBaseUrl.IndexOf("/",$slash2Position+1) | ||
$hostname = $webServicesBaseUrl.Substring($slash2Position+1,$slash3Position-$slash2Position-1) | ||
$computername = $hostname.Substring(0,$hostname.IndexOf(".")) | ||
$webServicesBaseUrlToComputerName = $webServicesBaseUrl.Replace($hostname,$computername) | ||
Test-IshSession -WsBaseUrl $webServicesBaseUrlToComputerName -IshUserName $ishUserName -IshPassword $ishPassword -IgnoreSslPolicyErrors -WarningAction Ignore | Should -Be $true | ||
} | ||
} | ||
} | ||
|
||
AfterAll { | ||
Write-Host ("Running "+$cmdletName+" Test Data and Variables cleanup") | ||
} |
Oops, something went wrong.