Skip to content

Commit

Permalink
#115 Requires Pester 5.3.0, working New-IshSession test on Windows Po…
Browse files Browse the repository at this point in the history
…werShell use `Invoke-Pester -Path .\NewIshSession.Tests.ps1 -Output Detailed`
  • Loading branch information
ddemeyer committed Sep 10, 2021
1 parent f8b1e92 commit be9b613
Showing 1 changed file with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ Describe "New-IshSession" -Tags "Read" {
It "Parameter IshPassword specified" {
{ New-IshSession -WsBaseUrl $webServicesBaseUrl -IshUserName $ishUserName -IshPassword "INVALIDISHPASSWORD" } | Should -Throw
}
It "Parameter IshUserName empty falls back to NetworkCredential/ActiveDirectory" {
{ New-IshSession -WsBaseUrl $webServicesBaseUrl -IshUserName "" -IshPassword "IGNOREISHPASSWORD" } | Should -Not Throw "Cannot validate argument on parameter 'IshUserName'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again."
It "Parameter IshUserName empty falls back to NetworkCredential/ActiveDirectory" -Skip:(-Not $isISHRemoteWindowsAuthentication) {
{ New-IshSession -WsBaseUrl $webServicesBaseUrl -IshUserName "" -IshPassword "IGNOREISHPASSWORD" } | Should -Not -Throw "Cannot validate argument on parameter 'IshUserName'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again."
}
}

Expand All @@ -46,7 +46,7 @@ Describe "New-IshSession" -Tags "Read" {
$securePassword = ConvertTo-SecureString $ishPassword -AsPlainText -Force
$mycredentials = New-Object System.Management.Automation.PSCredential ($ishUserName, $securePassword)
New-IshSession -WsBaseUrl "http:///INVALIDWSBASEURL" -PSCredential $mycredentials
} | Should -Throw "Invalid URI"
} | Should -Throw "Invalid URI: The hostname could not be parsed."
}
It "Parameter PSCredential invalid" {
$securePassword = ConvertTo-SecureString "INVALIDPASSWORD" -AsPlainText -Force
Expand All @@ -56,7 +56,7 @@ Describe "New-IshSession" -Tags "Read" {
It "Parameter PSCredential" {
$securePassword = ConvertTo-SecureString $ishPassword -AsPlainText -Force
$mycredentials = New-Object System.Management.Automation.PSCredential ($ishUserName, $securePassword)
{ New-IshSession -WsBaseUrl $webServicesBaseUrl -PSCredential $mycredentials } | Should -Not Throw
{ New-IshSession -WsBaseUrl $webServicesBaseUrl -PSCredential $mycredentials } | Should -Not -Throw
}
}

Expand Down Expand Up @@ -146,7 +146,7 @@ Describe "New-IshSession" -Tags "Read" {
It "WsBaseUrl without ending slash" {
# .NET throws unhandy "Reference to undeclared entity 'raquo'." error
$webServicesBaseUrlWithoutEndingSlash = $webServicesBaseUrl.Substring(0,$webServicesBaseUrl.Length-1)
{ $ishSession = New-IshSession -WsBaseUrl $webServicesBaseUrlWithoutEndingSlash -IshUserName $ishUserName -IshPassword $ishPassword } | Should -Not Throw
{ $ishSession = New-IshSession -WsBaseUrl $webServicesBaseUrlWithoutEndingSlash -IshUserName $ishUserName -IshPassword $ishPassword } | Should -Not -Throw
}
}

Expand All @@ -155,7 +155,7 @@ Describe "New-IshSession" -Tags "Read" {
{ $ishSession = New-IshSession -WsBaseUrl $webServicesBaseUrl -IshUserName $ishUserName -IshPassword $ishPassword -Timeout "INVALIDTIMEOUT" } | Should -Throw
}
It "IshSession.Timeout set to 30s" {
$ishSession = New-IshSession -WsBaseUrl $webServicesBaseUrl -IshUserName $ishUserName -IshPassword $ishPassword -Timeout (New-TimeSpan -Seconds 60)
$ishSession = New-IshSession -WsBaseUrl $webServicesBaseUrl -IshUserName $ishUserName -IshPassword $ishPassword -Timeout (New-TimeSpan -Seconds 60) -WarningAction Ignore -ErrorAction Ignore
$ishSession.Timeout.TotalMilliseconds | Should -Be "60000"
}
It "IshSession.Timeout on INVALID url set to 1ms execution" {
Expand All @@ -172,7 +172,7 @@ Describe "New-IshSession" -Tags "Read" {
{ $ishSession = New-IshSession -WsBaseUrl $webServicesBaseUrl -IshUserName $ishUserName -IshPassword $ishPassword -TimeoutIssue "INVALIDTimeoutIssue" } | Should -Throw
}
It "IshSession.TimeoutIssue set to 30s" {
$ishSession = New-IshSession -WsBaseUrl $webServicesBaseUrl -IshUserName $ishUserName -IshPassword $ishPassword -TimeoutIssue (New-TimeSpan -Seconds 30)
$ishSession = New-IshSession -WsBaseUrl $webServicesBaseUrl -IshUserName $ishUserName -IshPassword $ishPassword -TimeoutIssue (New-TimeSpan -Seconds 30) -WarningAction Ignore -ErrorAction Ignore
$ishSession.TimeoutIssue.TotalMilliseconds | Should -Be "30000"
}
It "IshSession.TimeoutIssue set to 1ms execution" {
Expand All @@ -186,7 +186,7 @@ Describe "New-IshSession" -Tags "Read" {
{ $ishSession = New-IshSession -WsBaseUrl $webServicesBaseUrl -IshUserName $ishUserName -IshPassword $ishPassword -TimeoutService "INVALIDTIMEOUTSERVICE" } | Should -Throw
}
It "IshSession.TimeoutService set to 40s" {
$ishSession = New-IshSession -WsBaseUrl $webServicesBaseUrl -IshUserName $ishUserName -IshPassword $ishPassword -TimeoutService (New-TimeSpan -Seconds 40)
$ishSession = New-IshSession -WsBaseUrl $webServicesBaseUrl -IshUserName $ishUserName -IshPassword $ishPassword -TimeoutService (New-TimeSpan -Seconds 40) -WarningAction Ignore -ErrorAction Ignore
$ishSession.TimeoutService.TotalMilliseconds | Should -Be "40000"
}
It "IshSession.TimeoutService set to 1 tickout execution" {
Expand All @@ -201,11 +201,11 @@ Describe "New-IshSession" -Tags "Read" {

Context "New-IshSession IgnoreSslPolicyErrors" {
It "Parameter IgnoreSslPolicyErrors specified positive flow" {
$ishSession = New-IshSession -WsBaseUrl $webServicesBaseUrl -IshUserName $ishUserName -IshPassword $ishPassword -IgnoreSslPolicyErrors
$ishSession = New-IshSession -WsBaseUrl $webServicesBaseUrl -IshUserName $ishUserName -IshPassword $ishPassword -IgnoreSslPolicyErrors -WarningAction Ignore
$ishSession.ServerVersion | Should -Not -BeNullOrEmpty
$ishSession.ServerVersion.Split(".").Length | Should -Be 4
}
It "Parameter IgnoreSslPolicyErrors specified negative flow (segment-one-url)" -skip {
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)
Expand All @@ -218,7 +218,7 @@ Describe "New-IshSession" -Tags "Read" {
$ishSession.ServerVersion.Split(".").Length | Should -Be 4
$ishSession.Dispose()
}
<# It "Parameter IgnoreSslPolicyErrors specified negative flow (Resolve-DnsName)" -skip {
<# It "Parameter IgnoreSslPolicyErrors specified negative flow (Resolve-DnsName)" -Skip {
# replace hostname like example.com with ip-address
$slash1Position = $webServicesBaseUrl.IndexOf("/")
$slash2Position = $webServicesBaseUrl.IndexOf("/",$slash1Position+1)
Expand All @@ -238,8 +238,8 @@ Describe "New-IshSession" -Tags "Read" {
$ishSession.ServerVersion | Should -Not -BeNullOrEmpty
$ishSession.ServerVersion.Split(".").Length | Should -Be 4
}
It "Parameter WsTrustIssuerUrl and WsTrustIssuerMexUrl are using localhost" -skip {
$ishSession = New-IshSession -WsBaseUrl $localWebServicesBaseUrl -WsTrustIssuerUrl $localWsTrustIssuerUrl -WsTrustIssuerMexUrl $localWsTrustIssuerMexUrl -IshUserName $ishUserName -IshPassword $ishPassword -IgnoreSslPolicyErrors
It "Parameter WsTrustIssuerUrl and WsTrustIssuerMexUrl are using localhost" -Skip:($isISHRemoteWcf) {
$ishSession = New-IshSession -WsBaseUrl $localWebServicesBaseUrl -WsTrustIssuerUrl $localWsTrustIssuerUrl -WsTrustIssuerMexUrl $localWsTrustIssuerMexUrl -IshUserName $ishUserName -IshPassword $ishPassword -IgnoreSslPolicyErrors -WarningAction Ignore
$ishSession.ServerVersion | Should -Not -BeNullOrEmpty
$ishSession.ServerVersion.Split(".").Length | Should -Be 4
}
Expand Down

0 comments on commit be9b613

Please sign in to comment.