Skip to content

Commit

Permalink
ADD Tests
Browse files Browse the repository at this point in the history
Added test cases for New-PASSession, New-PASSAMLSession &
New-PASSharedSession to check for condition reported in #63 - Functions
should not return output if authentication error.
  • Loading branch information
pspete committed Apr 17, 2018
1 parent f1c5071 commit c91dfa6
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Tests/New-PASSAMLSession.Tests.ps1
Expand Up @@ -187,6 +187,20 @@ Describe $FunctionName {

}

It "throws error if authentication request fails" {

Mock Invoke-PASRestMethod -MockWith {Write-Error -Message "Some Error" -ErrorId 12345}
{$Credentials | New-PASSAMLSession -BaseURI "https://P_URI" -ErrorAction Stop} | Should throw

}

It "returns no output if authentication request fails" {

Mock Invoke-PASRestMethod -MockWith {Write-Error -Message "Some Error" -ErrorId 12345}
$Credentials | New-PASSAMLSession -BaseURI "https://P_URI" -ErrorAction SilentlyContinue | Should BeNullOrEmpty

}

}

}
Expand Down
14 changes: 14 additions & 0 deletions Tests/New-PASSession.Tests.ps1
Expand Up @@ -175,6 +175,20 @@ Describe $FunctionName {

}

It "throws error if authentication request fails" {

Mock Invoke-PASRestMethod -MockWith {Write-Error -Message "Some Error" -ErrorId 12345}
{$Credentials | New-PASSession -BaseURI "https://P_URI" -ErrorAction Stop} | Should throw

}

It "returns no output if authentication request fails" {

Mock Invoke-PASRestMethod -MockWith {Write-Error -Message "Some Error" -ErrorId 12345}
$Credentials | New-PASSession -BaseURI "https://P_URI" -ErrorAction SilentlyContinue | Should BeNullOrEmpty

}

}

}
Expand Down
14 changes: 14 additions & 0 deletions Tests/New-PASSharedSession.Tests.ps1
Expand Up @@ -152,6 +152,20 @@ Describe $FunctionName {

}

It "throws error if authentication request fails" {

Mock Invoke-PASRestMethod -MockWith {Write-Error -Message "Some Error" -ErrorId 12345}
{New-PASSharedSession -BaseURI "https://P_URI" -ErrorAction Stop} | Should throw

}

It "returns no output if authentication request fails" {

Mock Invoke-PASRestMethod -MockWith {Write-Error -Message "Some Error" -ErrorId 12345}
New-PASSharedSession -BaseURI "https://P_URI" -ErrorAction SilentlyContinue | Should BeNullOrEmpty

}

}

}
Expand Down

0 comments on commit c91dfa6

Please sign in to comment.