-
-
Notifications
You must be signed in to change notification settings - Fork 808
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
1 parent
0c39b6a
commit 915656a
Showing
16 changed files
with
251 additions
and
434 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
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 |
---|---|---|
@@ -1,60 +1,30 @@ | ||
param($ModuleName = 'dbatools') | ||
|
||
Describe "Add-DbaComputerCertificate" { | ||
BeforeAll { | ||
$CommandName = $MyInvocation.MyCommand.Name.Replace(".Tests.ps1", "") | ||
Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan | ||
. "$PSScriptRoot\constants.ps1" | ||
} | ||
$CommandName = $MyInvocation.MyCommand.Name.Replace(".Tests.ps1", "") | ||
Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan | ||
. "$PSScriptRoot\constants.ps1" | ||
|
||
Describe "$CommandName Unit Tests" -Tag 'UnitTests' { | ||
Context "Validate parameters" { | ||
BeforeAll { | ||
$CommandUnderTest = Get-Command Add-DbaComputerCertificate | ||
} | ||
It "Should have ComputerName as a parameter" { | ||
$CommandUnderTest | Should -HaveParameter ComputerName -Type DbaInstanceParameter[] | ||
} | ||
It "Should have Credential as a parameter" { | ||
$CommandUnderTest | Should -HaveParameter Credential -Type PSCredential | ||
} | ||
It "Should have SecurePassword as a parameter" { | ||
$CommandUnderTest | Should -HaveParameter SecurePassword -Type SecureString | ||
} | ||
It "Should have Certificate as a parameter" { | ||
$CommandUnderTest | Should -HaveParameter Certificate -Type X509Certificate2[] | ||
} | ||
It "Should have Path as a parameter" { | ||
$CommandUnderTest | Should -HaveParameter Path -Type String | ||
} | ||
It "Should have Store as a parameter" { | ||
$CommandUnderTest | Should -HaveParameter Store -Type String | ||
} | ||
It "Should have Folder as a parameter" { | ||
$CommandUnderTest | Should -HaveParameter Folder -Type String | ||
} | ||
It "Should have Flag as a parameter" { | ||
$CommandUnderTest | Should -HaveParameter Flag -Type String[] | ||
} | ||
It "Should have EnableException as a parameter" { | ||
$CommandUnderTest | Should -HaveParameter EnableException -Type SwitchParameter | ||
[object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} | ||
[object[]]$knownParameters = 'ComputerName', 'Credential', 'SecurePassword', 'Certificate', 'Path', 'Store', 'Folder', 'Flag', 'EnableException' | ||
$knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters | ||
It "Should only contain our specific parameters" { | ||
(@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 | ||
} | ||
} | ||
} | ||
|
||
Describe "$commandname Integration Tests" -Tags "IntegrationTests" { | ||
Context "Certificate is added properly" { | ||
BeforeAll { | ||
$results = Add-DbaComputerCertificate -Path $script:appveyorlabrepo\certificates\localhost.crt -Confirm:$false | ||
} | ||
$results = Add-DbaComputerCertificate -Path $script:appveyorlabrepo\certificates\localhost.crt -Confirm:$false | ||
|
||
It "Should show the proper thumbprint has been added" { | ||
$results.Thumbprint | Should -Be "29C469578D6C6211076A09CEE5C5797EEA0C2713" | ||
$results.Thumbprint | Should Be "29C469578D6C6211076A09CEE5C5797EEA0C2713" | ||
} | ||
|
||
It "Should be in LocalMachine\My Cert Store" { | ||
$results.PSParentPath | Should -Be "Microsoft.PowerShell.Security\Certificate::LocalMachine\My" | ||
$results.PSParentPath | Should Be "Microsoft.PowerShell.Security\Certificate::LocalMachine\My" | ||
} | ||
|
||
AfterAll { | ||
Remove-DbaComputerCertificate -Thumbprint 29C469578D6C6211076A09CEE5C5797EEA0C2713 -Confirm:$false | ||
} | ||
Remove-DbaComputerCertificate -Thumbprint 29C469578D6C6211076A09CEE5C5797EEA0C2713 -Confirm:$false | ||
} | ||
} | ||
} |
Oops, something went wrong.