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
10 changed files
with
292 additions
and
4 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
28 changes: 28 additions & 0 deletions
28
docs/collections/_abouttopics/about_tssfolderauditsummary.md
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,28 @@ | ||
--- | ||
category: folders | ||
title: "TssFolderAuditSummary" | ||
last_modified_at: 2021-02-11T00:00:00-00:00 | ||
--- | ||
|
||
# TOPIC | ||
This help topic describes the TssFolderAuditSummary class in the Thycotic.SecretServer module | ||
|
||
# CLASS | ||
TssFolderAuditSummary | ||
|
||
# INHERITANCE | ||
None | ||
|
||
# DESCRIPTION | ||
The TssFolderAuditSummary class represents the FolderAuditSummary object returned by Secret Server endpoint /folders/{id}/audit | ||
|
||
# CONSTRUCTORS | ||
new() | ||
|
||
# PROPERTIES | ||
Documented in the REST API doc for Secret Server, see FolderAuditSummary definition | ||
|
||
# METHODS | ||
|
||
# RELATED LINKS: | ||
Get-TssFolderAudit |
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,77 @@ | ||
--- | ||
category: folders | ||
external help file: Thycotic.SecretServer-help.xml | ||
Module Name: Thycotic.SecretServer | ||
online version: | ||
schema: 2.0.0 | ||
title: Get-TssFolderAudit | ||
--- | ||
|
||
# Get-TssFolderAudit | ||
|
||
## SYNOPSIS | ||
Get a list of audits | ||
|
||
## SYNTAX | ||
|
||
``` | ||
Get-TssFolderAudit [-TssSession] <TssSession> -Id <Int32[]> [<CommonParameters>] | ||
``` | ||
|
||
## DESCRIPTION | ||
Get a list of audit for Folder ID | ||
|
||
## EXAMPLES | ||
|
||
### EXAMPLE 1 | ||
``` | ||
$session = New-TssSession -SecretServer https://alpha -Credential $ssCred | ||
PS> Get-TssFolderAudit -TssSession $session -Id 42 | ||
``` | ||
|
||
Gets the audit entries for Folder ID | ||
|
||
## PARAMETERS | ||
|
||
### -TssSession | ||
TssSession object created by New-TssSession for auth | ||
|
||
```yaml | ||
Type: TssSession | ||
Parameter Sets: (All) | ||
Aliases: | ||
|
||
Required: True | ||
Position: 1 | ||
Default value: None | ||
Accept pipeline input: True (ByValue) | ||
Accept wildcard characters: False | ||
``` | ||
|
||
### -Id | ||
Short description for parameter | ||
|
||
```yaml | ||
Type: Int32[] | ||
Parameter Sets: (All) | ||
Aliases: FolderAuditId | ||
|
||
Required: True | ||
Position: Named | ||
Default value: None | ||
Accept pipeline input: True (ByPropertyName) | ||
Accept wildcard characters: False | ||
``` | ||
|
||
### CommonParameters | ||
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). | ||
|
||
## INPUTS | ||
|
||
## OUTPUTS | ||
|
||
### TssFolderAuditSummary | ||
## NOTES | ||
Requires TssSession object returned by New-TssSession | ||
|
||
## RELATED LINKS |
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,12 @@ | ||
class TssFolderAuditSummary { | ||
# Action | ||
[string]$Action | ||
# Audit Folder Id | ||
[int]$AuditFolderId | ||
# Data recorded | ||
[datetime]$DateRecorded | ||
# Display Name | ||
[string]$DisplayName | ||
# Notes | ||
[string]$Notes | ||
} |
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,22 @@ | ||
TOPIC | ||
This help topic describes the TssFolderAuditSummary class in the Thycotic.SecretServer module | ||
|
||
CLASS | ||
TssFolderAuditSummary | ||
|
||
INHERITANCE | ||
None | ||
|
||
DESCRIPTION | ||
The TssFolderAuditSummary class represents the FolderAuditSummary object returned by Secret Server endpoint /folders/{id}/audit | ||
|
||
CONSTRUCTORS | ||
new() | ||
|
||
PROPERTIES | ||
Documented in the REST API doc for Secret Server, see FolderAuditSummary definition | ||
|
||
METHODS | ||
|
||
RELATED LINKS: | ||
Get-TssFolderAudit |
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,65 @@ | ||
function Get-FolderAudit { | ||
<# | ||
.SYNOPSIS | ||
Get a list of audits | ||
.DESCRIPTION | ||
Get a list of audit for Folder ID | ||
.EXAMPLE | ||
PS> $session = New-TssSession -SecretServer https://alpha -Credential $ssCred | ||
PS> Get-TssFolderAudit -TssSession $session -Id 42 | ||
Gets the audit entries for Folder ID | ||
.NOTES | ||
Requires TssSession object returned by New-TssSession | ||
#> | ||
[CmdletBinding()] | ||
[OutputType('TssFolderAuditSummary')] | ||
param ( | ||
# TssSession object created by New-TssSession for auth | ||
[Parameter(Mandatory, | ||
ValueFromPipeline, | ||
Position = 0)] | ||
[TssSession]$TssSession, | ||
|
||
# Short description for parameter | ||
[Parameter(Mandatory,ValueFromPipelineByPropertyName)] | ||
[Alias("FolderAuditId")] | ||
[int[]] | ||
$Id | ||
) | ||
begin { | ||
$tssParams = $PSBoundParameters | ||
$invokeParams = @{ } | ||
} | ||
|
||
process { | ||
Write-Verbose "Provided command parameters: $(. $GetInvocation $PSCmdlet.MyInvocation)" | ||
if ($tssParams.ContainsKey('TssSession') -and $TssSession.IsValidSession()) { | ||
foreach ($folder in $Id) { | ||
$restResponse = $null | ||
$uri = $TssSession.ApiUrl, 'folders', $folder, 'audit' -join '/' | ||
$invokeParams.Uri = $uri | ||
$invokeParams.Method = 'GET' | ||
|
||
$invokeParams.PersonalAccessToken = $TssSession.AccessToken | ||
Write-Verbose "$($invokeParams.Method) $uri" | ||
try { | ||
$restResponse = Invoke-TssRestApi @invokeParams | ||
} catch { | ||
Write-Warning "Issue getting folder [$folder]" | ||
$err = $_ | ||
. $ErrorHandling $err | ||
} | ||
|
||
if ($restResponse) { | ||
. $TssFolderAuditSummaryObject $restResponse.records | ||
} | ||
} | ||
} 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 TssFolderAuditSummary object to output the FolderAuditSummary object | ||
#> | ||
param( | ||
[pscustomobject]$Object | ||
) | ||
|
||
begin { | ||
$Properties = $Object[0].PSObject.Properties.Name | ||
} | ||
|
||
process { | ||
$outObject = @() | ||
foreach ($f in $Object) { | ||
$currentObject = [TssFolderAuditSummary]::new() | ||
foreach ($sProp in $Properties) { | ||
if ($sProp -in $currentObject.PSObject.Properties.Name) { | ||
$currentObject.$sProp = $f.$sProp | ||
} else { | ||
Write-Warning "Property $sProp does not exist in the TssFolderAuditSummary class. Please create a bug report at https://github.com/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,50 @@ | ||
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 parmaeters" -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 TssFolderAuditSummary" -TestCases $commandDetails { | ||
$_.OutputType.Name | Should -Be 'TssFolderAuditSummary' | ||
} | ||
} | ||
} | ||
Describe "$commandName works" { | ||
BeforeDiscovery { | ||
$session = New-TssSession -SecretServer $ss -Credential $ssCred | ||
$invokeParams = @{ | ||
Uri = "$ss/api/v1/folders?take=$($session.take)" | ||
ExpandProperty = 'records' | ||
PersonalAccessToken = $session.AccessToken | ||
} | ||
$getFolders = Invoke-TssRestApi @invokeParams | ||
$tssSecretFolder = $getFolders.Where({$_.folderPath -match 'tss_module_testing'}) | ||
|
||
$object = Get-TssFolderAudit -TssSession $session -Id $tssSecretFolder.id | ||
|
||
$session.SessionExpire() | ||
$props = 'Action', 'AuditFolderId', 'Notes' | ||
} | ||
Context "Checking" -Foreach @{object = $object} { | ||
It "Should not be empty" { | ||
$object | Should -Not -BeNullOrEmpty | ||
} | ||
It "Should output <_> property" -TestCases $props { | ||
$object[0].PSObject.Properties.Name | Should -Contain $_ | ||
} | ||
} | ||
} |