Skip to content

Commit

Permalink
Disable-TssSecretEmail - added restricted params
Browse files Browse the repository at this point in the history
  • Loading branch information
wsmelton committed Mar 19, 2021
1 parent 9758aa8 commit be6dbe9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
26 changes: 24 additions & 2 deletions src/functions/secrets/Disable-SecretEmail.ps1
Expand Up @@ -47,11 +47,34 @@ function Disable-SecretEmail {

# Email when HB fails to true
[switch]
$WhenHeartbeatFails
$WhenHeartbeatFails,

# Comment to provide for restricted secret (Require Comment is enabled)
[Parameter(ParameterSetName = 'restricted')]
[string]
$Comment,

# Associated Ticket Number
[Parameter(ParameterSetName = 'restricted')]
[int]
$TicketNumber,

#Associated Ticket System ID
[Parameter(ParameterSetName = 'restricted')]
[int]
$TicketSystemId
)
begin {
$tssParams = $PSBoundParameters
$invokeParams = . $GetInvokeTssParams $TssSession

$restrictedParamSet = . $ParameterSetParams 'Enable-TssSecretEmail' 'restricted'
$restrictedParams = @()
foreach ($r in $restrictedParamSet) {
if ($tssParams.ContainsKey($r)) {
$restrictedParams += $r
}
}
}
process {
Write-Verbose "Provided command parameters: $(. $GetInvocation $PSCmdlet.MyInvocation)"
Expand Down Expand Up @@ -88,7 +111,6 @@ function Disable-SecretEmail {
$emailBody.data.Add('sendEmailWhenHeartbeatFails',$sendEmailWhenHeartbeatFails)
}


$invokeParams.Method = 'PATCH'
$invokeParams.Body = $emailBody | ConvertTo-Json -Depth 5

Expand Down
4 changes: 2 additions & 2 deletions tests/secrets/Disable-TssSecretEmail.Tests.ps1
Expand Up @@ -4,7 +4,7 @@ BeforeDiscovery {
}
Describe "$commandName verify parameters" {
BeforeDiscovery {
[object[]]$knownParameters = 'TssSession', 'Id', 'WhenHeartbeatFails', 'WhenViewed', 'WhenChanged'
[object[]]$knownParameters = 'TssSession', 'Id', 'WhenHeartbeatFails', 'WhenViewed', 'WhenChanged', 'Comment', '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
Expand Down Expand Up @@ -55,7 +55,7 @@ Describe "$commandName functions" {
$object = Disable-TssSecretEmail -TssSession $session -Id $secretId -WhenChanged
Assert-VerifiableMock
}
It "Should not be empty" {
It "Should be empty" {
$object | Should -BeNullOrEmpty
}
}
Expand Down

0 comments on commit be6dbe9

Please sign in to comment.