-
-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Release 5.6
- Loading branch information
Showing
56 changed files
with
5,825 additions
and
387 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
Describe $($PSCommandPath -Replace '.Tests.ps1') { | ||
|
||
BeforeAll { | ||
#Get Current Directory | ||
$Here = Split-Path -Parent $PSCommandPath | ||
|
||
#Assume ModuleName from Repository Root folder | ||
$ModuleName = Split-Path (Split-Path $Here -Parent) -Leaf | ||
|
||
#Resolve Path to Module Directory | ||
$ModulePath = Resolve-Path "$Here\..\$ModuleName" | ||
|
||
#Define Path to Module Manifest | ||
$ManifestPath = Join-Path "$ModulePath" "$ModuleName.psd1" | ||
|
||
if ( -not (Get-Module -Name $ModuleName -All)) { | ||
|
||
Import-Module -Name "$ManifestPath" -ArgumentList $true -Force -ErrorAction Stop | ||
|
||
} | ||
|
||
$Script:RequestBody = $null | ||
$Script:BaseURI = 'https://SomeURL/SomeApp' | ||
$Script:ExternalVersion = '0.0' | ||
$Script:WebSession = New-Object Microsoft.PowerShell.Commands.WebRequestSession | ||
|
||
} | ||
|
||
|
||
AfterAll { | ||
|
||
$Script:RequestBody = $null | ||
|
||
} | ||
|
||
InModuleScope $(Split-Path (Split-Path (Split-Path -Parent $PSCommandPath) -Parent) -Leaf ) { | ||
|
||
Context 'General' { | ||
|
||
BeforeEach { | ||
|
||
|
||
$InputObj = @{ | ||
'reason' = 'some reason' | ||
'fromDate' = 5 | ||
} | ||
|
||
} | ||
|
||
It 'does not throw' { | ||
|
||
{ ConvertTo-BulkFilterItem } | Should -Not -Throw | ||
|
||
} | ||
|
||
It 'produces expected output if given no input' { | ||
|
||
$output = ConvertTo-BulkFilterItem | ||
$output['Reason'] | Should -BeNullOrEmpty | ||
$output['TicketingSystemName'] | Should -BeNullOrEmpty | ||
$output['TicketID'] | Should -BeNullOrEmpty | ||
$output['AdditionalInfo'] | Should -BeNullOrEmpty | ||
$output['multipleAccessRequired'] | Should -Be $false | ||
$output['fromDate'] | Should -Be 0 | ||
$output['toDate'] | Should -Be 0 | ||
|
||
} | ||
|
||
It 'outputs expected values' { | ||
|
||
$output = $InputObj | ConvertTo-BulkFilterItem | ||
$output['Reason'] | Should -Be 'some reason' | ||
$output['TicketingSystemName'] | Should -BeNullOrEmpty | ||
$output['TicketID'] | Should -BeNullOrEmpty | ||
$output['AdditionalInfo'] | Should -BeNullOrEmpty | ||
$output['multipleAccessRequired'] | Should -Be $false | ||
$output['fromDate'] | Should -Be 5 | ||
$output['toDate'] | Should -Be 0 | ||
|
||
} | ||
|
||
} | ||
|
||
} | ||
|
||
} |
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,128 @@ | ||
Describe $($PSCommandPath -Replace '.Tests.ps1') { | ||
|
||
BeforeAll { | ||
#Get Current Directory | ||
$Here = Split-Path -Parent $PSCommandPath | ||
|
||
#Assume ModuleName from Repository Root folder | ||
$ModuleName = Split-Path (Split-Path $Here -Parent) -Leaf | ||
|
||
#Resolve Path to Module Directory | ||
$ModulePath = Resolve-Path "$Here\..\$ModuleName" | ||
|
||
#Define Path to Module Manifest | ||
$ManifestPath = Join-Path "$ModulePath" "$ModuleName.psd1" | ||
|
||
if ( -not (Get-Module -Name $ModuleName -All)) { | ||
|
||
Import-Module -Name "$ManifestPath" -ArgumentList $true -Force -ErrorAction Stop | ||
|
||
} | ||
|
||
$Script:RequestBody = $null | ||
$Script:BaseURI = 'https://SomeURL/SomeApp' | ||
$Script:ExternalVersion = '0.0' | ||
$Script:WebSession = New-Object Microsoft.PowerShell.Commands.WebRequestSession | ||
|
||
} | ||
|
||
|
||
AfterAll { | ||
|
||
$Script:RequestBody = $null | ||
|
||
} | ||
|
||
InModuleScope $(Split-Path (Split-Path (Split-Path -Parent $PSCommandPath) -Parent) -Leaf ) { | ||
|
||
Context 'Input' { | ||
|
||
BeforeEach { | ||
|
||
Mock Invoke-PASRestMethod -MockWith { | ||
[PSCustomObject]@{'addsaferesult' = [PSCustomObject]@{'Prop1' = 'Val1'; 'Prop2' = 'Val2' } } | ||
} | ||
|
||
$Script:BaseURI = 'https://SomeURL/SomeApp' | ||
$Script:ExternalVersion = '0.0' | ||
$Script:WebSession = New-Object Microsoft.PowerShell.Commands.WebRequestSession | ||
|
||
} | ||
|
||
It 'sends request' { | ||
Get-PASPTARiskEvent | ||
Assert-MockCalled Invoke-PASRestMethod -Times 1 -Exactly -Scope It | ||
|
||
} | ||
|
||
It 'sends request to expected endpoint' { | ||
Get-PASPTARiskEvent | ||
Assert-MockCalled Invoke-PASRestMethod -ParameterFilter { | ||
|
||
$URI -match "$($Script:BaseURI)/API/pta/API/Risks/RisksEvents/" | ||
|
||
} -Times 1 -Exactly -Scope It | ||
|
||
} | ||
|
||
It 'uses expected method' { | ||
Get-PASPTARiskEvent | ||
Assert-MockCalled Invoke-PASRestMethod -ParameterFilter { $Method -match 'GET' } -Times 1 -Exactly -Scope It | ||
|
||
} | ||
|
||
It 'sends request with no body' { | ||
Get-PASPTARiskEvent | ||
Assert-MockCalled Invoke-PASRestMethod -ParameterFilter { | ||
|
||
$Body -eq $null | ||
|
||
} -Times 1 -Exactly -Scope It | ||
|
||
} | ||
|
||
It 'throws error if version requirement not met' { | ||
$Script:ExternalVersion = '1.0' | ||
{ Get-PASPTARiskEvent } | Should -Throw | ||
$Script:ExternalVersion = '0.0' | ||
} | ||
|
||
} | ||
|
||
Context 'Output' { | ||
BeforeEach { | ||
|
||
Mock Invoke-PASRestMethod -MockWith { | ||
[PSCustomObject]@{'addsaferesult' = [PSCustomObject]@{'Prop1' = 'Val1'; 'Prop2' = 'Val2' } } | ||
} | ||
|
||
$Script:BaseURI = 'https://SomeURL/SomeApp' | ||
$Script:ExternalVersion = '0.0' | ||
$Script:WebSession = New-Object Microsoft.PowerShell.Commands.WebRequestSession | ||
|
||
} | ||
It 'provides output' { | ||
|
||
Get-PASPTARiskEvent | Should -Not -BeNullOrEmpty | ||
|
||
} | ||
|
||
It 'has output with expected number of properties' { | ||
|
||
(Get-PASPTARiskEvent | Get-Member -MemberType NoteProperty).length | Should -Be 1 | ||
|
||
} | ||
|
||
It 'outputs object with expected typename' { | ||
|
||
Get-PASPTARiskEvent | Get-Member | Select-Object -ExpandProperty typename -Unique | Should -Be psPAS.CyberArk.Vault.PTA.Event.Risk | ||
|
||
} | ||
|
||
|
||
|
||
} | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.