Skip to content

Commit

Permalink
🔥 ♻️ 💥 Combine Logon Functions
Browse files Browse the repository at this point in the history
Combines all logon functions into `New-PASSession`.
Removed `New-PASSAMLSession` & `New-PASSharedSession`.
  • Loading branch information
pspete committed Jun 12, 2019
1 parent 0e823c9 commit 84f76c3
Show file tree
Hide file tree
Showing 9 changed files with 158 additions and 724 deletions.
4 changes: 0 additions & 4 deletions README.md
Expand Up @@ -136,9 +136,7 @@ requires version 9.8+).
-----------------------------------------------------------------------------------------|--------------------|:----------------
[`New-PASSession`][New-PASSession] |**9.0** |Authenticates a user to </br>CyberArk Vault
[`Close-PASSession`][Close-PASSession] |**9.0** |Logoff from CyberArk Vault.
[`New-PASSAMLSession`][New-PASSAMLSession] |**9.7** |Authenticates a user to </br>CyberArk Vault using SAML
[`Close-PASSAMLSession`][Close-PASSAMLSession] |**9.7** |Logoff from CyberArk </br>Vault SAML Session.
[`New-PASSharedSession`][New-PASSharedSession] |**9.7** |Authenticates a user to </br>CyberArk Vault.
[`Close-PASSharedSession`][Close-PASSharedSession] |**9.7** |Logoff from CyberArk </br>Vault shared user.
[`Add-PASPublicSSHKey`][Add-PASPublicSSHKey] |**9.6** |Adds an authorised </br>public SSH key for a </br>specific user in the </br>Vault.
[`Get-PASPublicSSHKey`][Get-PASPublicSSHKey] |**9.6** |Retrieves a user's </br>SSH Keys.
Expand Down Expand Up @@ -239,9 +237,7 @@ requires version 9.8+).

[New-PASSession]:/psPAS/Functions/Authentication/New-PASSession.ps1
[Close-PASSession]:/psPAS/Functions/Authentication/Close-PASSession.ps1
[New-PASSAMLSession]:/psPAS/Functions/Authentication/New-PASSAMLSession.ps1
[Close-PASSAMLSession]:/psPAS/Functions/Authentication/Close-PASSAMLSession.ps1
[New-PASSharedSession]:/psPAS/Functions/Authentication/New-PASSharedSession.ps1
[Close-PASSharedSession]:/psPAS/Functions/Authentication/Close-PASSharedSession.ps1
[Add-PASPublicSSHKey]:/psPAS/Functions/Authentication/Add-PASPublicSSHKey.ps1
[Get-PASPublicSSHKey]:/psPAS/Functions/Authentication/Get-PASPublicSSHKey.ps1
Expand Down
231 changes: 0 additions & 231 deletions Tests/New-PASSAMLSession.Tests.ps1

This file was deleted.

47 changes: 41 additions & 6 deletions Tests/New-PASSession.Tests.ps1
Expand Up @@ -80,13 +80,13 @@ Describe $FunctionName {
}

It "sends request" {
$Credentials | New-PASSession -BaseURI "https://P_URI" -PVWAAppName "SomeApp" -newPassword $NewPass -UseV9API
$Credentials | New-PASSession -BaseURI "https://P_URI" -PVWAAppName "SomeApp" -newPassword $NewPass -UseClassicAPI
Assert-MockCalled Invoke-PASRestMethod -Times 1 -Exactly -Scope It

}

It "sends request to expected endpoint" {
$Credentials | New-PASSession -BaseURI "https://P_URI" -PVWAAppName "SomeApp" -newPassword $NewPass -UseV9API
$Credentials | New-PASSession -BaseURI "https://P_URI" -PVWAAppName "SomeApp" -newPassword $NewPass -UseClassicAPI
Assert-MockCalled Invoke-PASRestMethod -ParameterFilter {

$URI -eq "https://P_URI/SomeApp/WebServices/auth/Cyberark/CyberArkAuthenticationService.svc/Logon"
Expand All @@ -96,13 +96,13 @@ Describe $FunctionName {
}

It "uses expected method" {
$Credentials | New-PASSession -BaseURI "https://P_URI" -PVWAAppName "SomeApp" -newPassword $NewPass -UseV9API
$Credentials | New-PASSession -BaseURI "https://P_URI" -PVWAAppName "SomeApp" -newPassword $NewPass -UseClassicAPI
Assert-MockCalled Invoke-PASRestMethod -ParameterFilter { $Method -match 'POST' } -Times 1 -Exactly -Scope It

}

It "sends request with expected body" {
$Credentials | New-PASSession -BaseURI "https://P_URI" -PVWAAppName "SomeApp" -newPassword $NewPass -UseV9API
$Credentials | New-PASSession -BaseURI "https://P_URI" -PVWAAppName "SomeApp" -newPassword $NewPass -UseClassicAPI
Assert-MockCalled Invoke-PASRestMethod -ParameterFilter {

$Script:RequestBody = $Body | ConvertFrom-Json
Expand Down Expand Up @@ -192,10 +192,47 @@ Describe $FunctionName {

}

It "sends request to expected URL for SAML Authentication" {

New-PASSession -BaseURI "https://P_URI" -SAMLToken "SomeSAMLToken"

Assert-MockCalled Invoke-PASRestMethod -ParameterFilter {

$URI -eq "https://P_URI/PasswordVault/WebServices/auth/SAML/SAMLAuthenticationService.svc/Logon"

} -Times 1 -Exactly -Scope It

}

It "sends expected header for SAML Authentication" {

New-PASSession -BaseURI "https://P_URI" -SAMLToken "SomeSAMLToken"

Assert-MockCalled Invoke-PASRestMethod -ParameterFilter {

$Headers["Authorization"] -eq "SomeSAMLToken"

} -Times 1 -Exactly -Scope It

}

It "sends request to expected URL for Shared Authentication" {

New-PASSession -BaseURI "https://P_URI" -UseSharedAuthentication

Assert-MockCalled Invoke-PASRestMethod -ParameterFilter {

$URI -eq "https://P_URI/PasswordVault/WebServices/auth/Shared/RestfulAuthenticationService.svc/Logon"

} -Times 1 -Exactly -Scope It

}

It "`$Script:ExternalVersion has expected value on Get-PASServer error" {
Mock Get-PASServer -MockWith {
throw "Some Error"
}

$Credentials | New-PASSession -BaseURI "https://P_URI" -PVWAAppName "SomeApp" -WarningAction SilentlyContinue
$Script:ExternalVersion | Should be "0.0"

Expand All @@ -215,8 +252,6 @@ Describe $FunctionName {

}



}

Context "Output" {
Expand Down

0 comments on commit 84f76c3

Please sign in to comment.