Skip to content

Commit

Permalink
Initialize-TssSdkClient - add more help info and test
Browse files Browse the repository at this point in the history
  • Loading branch information
wsmelton committed Feb 18, 2021
1 parent f678697 commit 922200b
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 25 deletions.
53 changes: 30 additions & 23 deletions docs/collections/_commands/Initialize-TssSdkClient.md
Expand Up @@ -10,7 +10,7 @@ title: Initialize-TssSdkClient
# Initialize-TssSdkClient

## SYNOPSIS
{{ Fill in the Synopsis }}
Initialize SDK Client for the module

## SYNTAX

Expand All @@ -20,21 +20,29 @@ Initialize-TssSdkClient -SecretServer <String> -RuleName <String> [-OnboardingKe
```

## DESCRIPTION
{{ Fill in the Description }}
Initialize SDK Client for the module to utilize token request using machine authentication via SDK Client Management feature in Secret Server (see notes section)
See help for New-TssSession using the associated UseSdkClient/ConfigPath parameters

## EXAMPLES

### Example 1
```powershell
PS C:\> {{ Add example code here }}
### EXAMPLE 1
```
Initialize-TssSdkClient -SecretServer 'http://alpha.local/SecretServer' -RuleName tssmodule -ConfigPath $env:HOME
```

On Ubuntu 20.04 client, initialize SDK Client saving the configuration files in the user's HOME path

### EXAMPLE 2
```
Initialize-TssSdkClient -SecretServer 'http://alpha.local/SecretServer' -RuleName tssmodule -ConfigPath c:\thycotic -Force
```

{{ Add example description here }}
Initializes SDK Client saving the configuration files to c:\thycotic, with Force provided configuration will drop current configs (if exist) and recreate

## PARAMETERS

### -ConfigPath
{{ Fill ConfigPath Description }}
### -SecretServer
Secret Server

```yaml
Type: String
Expand All @@ -48,23 +56,23 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -Force
{{ Fill Force Description }}
### -RuleName
SDK Client Management rule name

```yaml
Type: SwitchParameter
Type: String
Parameter Sets: (All)
Aliases:

Required: False
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -OnboardingKey
{{ Fill OnboardingKey Description }}
SDK Client Management rule onboarding key

```yaml
Type: String
Expand All @@ -78,8 +86,8 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -RuleName
{{ Fill RuleName Description }}
### -ConfigPath
Config path for the key/config files

```yaml
Type: String
Expand All @@ -93,17 +101,17 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -SecretServer
{{ Fill SecretServer Description }}
### -Force
Overwrite configuration (drop and create a new)

```yaml
Type: String
Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: True
Required: False
Position: Named
Default value: None
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```
Expand All @@ -113,11 +121,10 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable

## INPUTS

### None

## OUTPUTS

### System.Object
## NOTES
Secret Server docs cover configuring Application Account and SDK Client rule
https://docs.thycotic.com/ss/10.9.0/api-scripting/sdk-cli/index.md#task_1__configuring_secret_server

## RELATED LINKS
10 changes: 9 additions & 1 deletion docs/collections/_commands/New-TssSession.md
Expand Up @@ -84,6 +84,14 @@ $session = nts https://ssvault.com/SecretServer -UseWindowsAuth
Create a session object utilizing Windows Integrated Authentication (IWA)
Use the alias nts to create a session object

### EXAMPLE 6
```
$session = New-TssSession -SecretServer https://vault.secretservercloud.com -UseSdkClient -ConfigPath c:\thycotic
```

Create a session object utilizing SDK Client configuration, assumes Initialize-TssSdkClient was run with config path of C:\thycotic
Token request performed via SDK Client meaning that token is good for life of the configuration

## PARAMETERS

### -SecretServer
Expand Down Expand Up @@ -214,7 +222,7 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable

## OUTPUTS

### TssSession.
### TssSession
## NOTES

## RELATED LINKS
Expand Down
22 changes: 22 additions & 0 deletions src/functions/Initialize-SdkClient.ps1
@@ -1,4 +1,26 @@
function Initialize-SdkClient {
<#
.SYNOPSIS
Initialize SDK Client for the module
.DESCRIPTION
Initialize SDK Client for the module to utilize token request using machine authentication via SDK Client Management feature in Secret Server (see notes section)
See help for New-TssSession using the associated UseSdkClient/ConfigPath parameters
.EXAMPLE
Initialize-TssSdkClient -SecretServer 'http://alpha.local/SecretServer' -RuleName tssmodule -ConfigPath $env:HOME
On Ubuntu 20.04 client, initialize SDK Client saving the configuration files in the user's HOME path
.EXAMPLE
Initialize-TssSdkClient -SecretServer 'http://alpha.local/SecretServer' -RuleName tssmodule -ConfigPath c:\thycotic -Force
Initializes SDK Client saving the configuration files to c:\thycotic, with Force provided configuration will drop current configs (if exist) and recreate
.NOTES
Secret Server docs cover configuring Application Account and SDK Client rule
https://docs.thycotic.com/ss/10.9.0/api-scripting/sdk-cli/index.md#task_1__configuring_secret_server
#>
[cmdletbinding()]
param(
# Secret Server
Expand Down
8 changes: 7 additions & 1 deletion src/functions/New-Session.ps1
Expand Up @@ -38,11 +38,17 @@
Create a session object utilizing Windows Integrated Authentication (IWA)
Use the alias nts to create a session object
.EXAMPLE
$session = New-TssSession -SecretServer https://vault.secretservercloud.com -UseSdkClient -ConfigPath c:\thycotic
Create a session object utilizing SDK Client configuration, assumes Initialize-TssSdkClient was run with config path of C:\thycotic
Token request performed via SDK Client meaning that token is good for life of the configuration
.LINK
https://thycotic-ps.github.io/thycotic.secretserver/commands/New-TssSession
.OUTPUTS
TssSession.
TssSession
#>
[cmdletbinding(SupportsShouldProcess)]
[OutputType('TssSession')]
Expand Down
25 changes: 25 additions & 0 deletions tests/functions/Initialize-TssSdkClient.Tests.ps1
@@ -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 = 'SecretServer', 'RuleName', 'OnboardingKey', 'ConfigPath', 'Force'
[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 TssClassName" -TestCases $commandDetails {
$_.OutputType.Name | Should -Be 'TssClassName'
}
}
}

0 comments on commit 922200b

Please sign in to comment.