-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Get-Secret - Add Path support fixes #174
- Loading branch information
Showing
5 changed files
with
126 additions
and
88 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,61 @@ | ||
[cmdletbinding()] | ||
param( | ||
[Parameter(Mandatory,Position = 0)] | ||
[TssSession] | ||
$TssSession, | ||
|
||
[Parameter(Mandatory,Position = 1)] | ||
[int] | ||
$FolderId, | ||
|
||
[Parameter(Mandatory,Position = 2)] | ||
[string] | ||
$SearchText | ||
) | ||
begin { | ||
$invokeParams = . $GetInvokeTssParams $TssSession | ||
} | ||
process { | ||
. $CheckVersion $TssSession '10.9.000000' $PSCmdlet.MyInvocation | ||
$uri = $TssSession.ApiUrl, 'secrets' -join '/' | ||
$uri += "?take=$($TssSession.Take)" | ||
$uri += "&filter.includeRestricted=true&filter.isExactmatch=true" | ||
|
||
$filters = @() | ||
$filters += "filter.searchText=$SearchText" | ||
$filters += "filter.folderId=$FolderId" | ||
|
||
if ($filters) { | ||
$uriFilter = $filters -join '&' | ||
Write-Verbose "Filters: $uriFilter" | ||
$uri = $uri, $uriFilter -join '&' | ||
} | ||
|
||
$invokeParams.Uri = $uri | ||
|
||
$invokeParams.Method = 'GET' | ||
Write-Verbose "$($invokeParams.Method) $uri" | ||
try { | ||
$restResponse = . $InvokeApi @invokeParams | ||
} catch { | ||
Write-Warning "Issue on search request" | ||
$err = $_ | ||
. $ErrorHandling $err | ||
} | ||
|
||
if ($restResponse.records) { | ||
foreach ($secret in $restResponse.records) { | ||
if (-not $restResponse.lastPasswordChangeAttempt) { | ||
$secret.lastPasswordChangeAttempt = [datetime]::MinValue | ||
} | ||
if (-not $restResponse.lastAccessed) { | ||
$secret.lastAccessed = [datetime]::MinValue | ||
} | ||
if (-not $restResponse.createDate) { | ||
$secret.createDate = [datetime]::MinValue | ||
} | ||
|
||
[TssSecretSummary]$secret | ||
} | ||
} | ||
} |
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,27 @@ | ||
BeforeDiscovery { | ||
$commandName = Split-Path ($PSCommandPath.Replace('.Tests.ps1','')) -Leaf | ||
. ([IO.Path]::Combine([string]$PSScriptRoot, '..', 'constants.ps1')) | ||
} | ||
Describe "$commandName verify parameters" { | ||
BeforeDiscovery { | ||
[object[]]$knownParameters = 'TssSession', 'Id', 'Path' | ||
# restricted | ||
'Comment', 'DoublelockPassword', 'ForceCheckIn', 'IncludeInactive', 'TicketNumber', 'TicketSystemId' | ||
[object[]]$currentParams = ([Management.Automation.CommandMetaData]$ExecutionContext.SessionState.InvokeCommand.GetCommand($commandName, 'Function')).Parameters.Keys | ||
[object[]]$commandDetails = [System.Management.Automation.CommandInfo]$ExecutionContext.SessionState.InvokeCommand.GetCommand($commandName,'Function') | ||
$unknownParameters = Compare-Object -ReferenceObject $knownParameters -DifferenceObject $currentParams -PassThru | ||
} | ||
Context "Verify parameters" -Foreach @{currentParams = $currentParams} { | ||
It "$commandName should contain <_> parameter" -TestCases $knownParameters { | ||
$_ -in $currentParams | Should -Be $true | ||
} | ||
It "$commandName should not contain parameter: <_>" -TestCases $unknownParameters { | ||
$_ | Should -BeNullOrEmpty | ||
} | ||
} | ||
Context "Command specific details" { | ||
It "$commandName should set OutputType to TssSecret" -TestCases $commandDetails { | ||
$_.OutputType.Name | Should -Be 'TssSecret' | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.