Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
242 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
class TssSecretDetailState { | ||
[string[]] | ||
$Actions | ||
|
||
[string] | ||
$CheckedOutUserDisplayName | ||
|
||
[int] | ||
$CheckedOutUserId | ||
|
||
[int] | ||
$CheckOutIntervalMinutes | ||
|
||
[int] | ||
$CheckOutMinutesRemaining | ||
|
||
[int] | ||
$FolderId | ||
|
||
[string] | ||
$FolderName | ||
|
||
[int] | ||
$Id | ||
|
||
[boolean] | ||
$IsActive | ||
|
||
[boolean] | ||
$IsCheckedOut | ||
|
||
[boolean] | ||
$IsCheckedOutByCurrentUser | ||
|
||
[boolean] | ||
$PasswordChangePending | ||
|
||
[string] | ||
$Role | ||
|
||
[string] | ||
$SecretName | ||
|
||
[ValidateSet('None','RequiresApproval','RequiresCheckout','RequiresComment','RequiresDoubleLockPassword','CreateDoubleLockPassword','DoubleLockNoAccess','CannotView','RequiresUndelete','RequiresCheckoutPendingRPC','RequiresCheckoutAndComment')] | ||
[string] | ||
$SecretState | ||
|
||
[System.String[]] GetActions() { | ||
if ($this.Actions) { | ||
$sortedActions = $this.Actions | Sort-Object | ||
return $sortedActions | ||
} else { | ||
return "No Actions found" | ||
} | ||
} | ||
} |
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,67 @@ | ||
TOPIC | ||
This help topic describes the TssSecretDetailState class in the Thycotic.SecretServer module | ||
|
||
CLASS | ||
TssSecretDetailActionType | ||
|
||
INHERITANCE | ||
None | ||
|
||
DESCRIPTION | ||
The TssSecretDetailActionType class represents the SecretDetao;StateViewModel returned by Secret Server endpoint GET /secrets/{id}/state | ||
|
||
CONSTRUCTORS | ||
new() | ||
|
||
PROPERTIES | ||
Actions [TssSecretDetailActionType] | ||
Allowed actions for the current user | ||
|
||
CheckedOutUserDisplayName | ||
Display Name of User that has the secret checked out | ||
|
||
CheckedOutUserId | ||
User Secret is checked out to | ||
|
||
CheckOutIntervalMinutes | ||
Number of minutes before checkout | ||
|
||
CheckOutMinutesRemaining | ||
Minutes remaining in check out | ||
|
||
FolderId | ||
Folder Id | ||
|
||
FolderName | ||
Folder Name | ||
|
||
Id | ||
Secret Id | ||
|
||
IsActive | ||
Active | ||
|
||
IsCheckedOut | ||
Is the Secret checked out | ||
|
||
IsCheckedOutByCurrentUser | ||
Indicates whether the Secret is checked out by the current user | ||
|
||
PasswordChangePending | ||
Pending Password change on secret indicator | ||
|
||
Role | ||
Role that current user has on Secret | ||
|
||
SecretName | ||
Secret Name | ||
|
||
SecretState | ||
Current State of the Secret | ||
|
||
METHODS | ||
[System.String[]] GetActions() | ||
Returns the Actions, sorted | ||
|
||
RELATED LINKS: | ||
Get-TssSecretState |
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,67 @@ | ||
function Get-SecretState { | ||
<# | ||
.SYNOPSIS | ||
Get details on state of the Secret | ||
.DESCRIPTION | ||
Get details on state (requires checkout, restricted actions, etc) of the Secret | ||
.EXAMPLE | ||
$session = New-TssSession -SecretServer https://alpha -Credential $ssCred | ||
Get-TssSecretState -TssSession $session -Id 42 | ||
Add minimum example for each parameter | ||
.LINK | ||
https://thycotic-ps.github.io/thycotic.secretserver/commands/Get-TssSecretState | ||
.NOTES | ||
Requires TssSession object returned by New-TssSession | ||
#> | ||
[CmdletBinding()] | ||
[OutputType('TssSecretDetailState')] | ||
param ( | ||
# TssSession object created by New-TssSession for auth | ||
[Parameter(Mandatory,ValueFromPipeline,Position = 0)] | ||
[TssSession] | ||
$TssSession, | ||
|
||
# Short description for parameter | ||
[Parameter(Mandatory,ValueFromPipelineByPropertyName)] | ||
[Alias("SecretId")] | ||
[int[]] | ||
$Id | ||
) | ||
begin { | ||
$tssParams = $PSBoundParameters | ||
$invokeParams = . $GetInvokeTssParams $TssSession | ||
} | ||
|
||
process { | ||
Write-Verbose "Provided command parameters: $(. $GetInvocation $PSCmdlet.MyInvocation)" | ||
if ($tssParams.ContainsKey('TssSession') -and $TssSession.IsValidSession()) { | ||
. $CheckVersion $TssSession '10.9.000000' $PSCmdlet.MyInvocation | ||
foreach ($secret in $Id) { | ||
$restResponse = $null | ||
$uri = $TssSession.ApiUrl, 'secrets', $secret, 'state' -join '/' | ||
$invokeParams.Uri = $uri | ||
$invokeParams.Method = 'GET' | ||
|
||
Write-Verbose "Performing the operation $($invokeParams.Method) $uri" | ||
try { | ||
$restResponse = Invoke-TssRestApi @invokeParams | ||
} catch { | ||
Write-Warning "Issue getting state for secret [$secret]" | ||
$err = $_ | ||
. $ErrorHandling $err | ||
} | ||
|
||
if ($restResponse) { | ||
. $TssSecretDetailStateObject $restResponse | ||
} | ||
} | ||
} else { | ||
Write-Warning "No valid session found" | ||
} | ||
} | ||
} |
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 @@ | ||
<# | ||
.Synopsis | ||
Creates a TssSecretDetailState object | ||
#> | ||
param( | ||
[pscustomobject]$Object | ||
) | ||
|
||
begin { | ||
$Properties = $Object[0].PSObject.Properties.Name | ||
} | ||
|
||
process { | ||
$outObject = @() | ||
foreach ($p in $Object) { | ||
$currentObject = [TssSecretDetailState]::new() | ||
foreach ($pProp in $Properties) { | ||
if ($pProp -in $currentObject.PSObject.Properties.Name) { | ||
$currentObject.$pProp = $p.$pProp | ||
} else { | ||
Write-Warning "Property $pProp does not exist in the TssSecretDetailState class.thycotic-ps/thycotic.secretserver/issues/new/choose" | ||
} | ||
} | ||
$outObject += $currentObject | ||
} | ||
return $outObject | ||
} |
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,25 @@ | ||
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' | ||
[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 TssSecretDetailState" -TestCases $commandDetails { | ||
$_.OutputType.Name | Should -Be 'TssSecretDetailState' | ||
} | ||
} | ||
} |