forked from dataplat/dbatools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBackup-DbaComputerCertificate.Tests.ps1
50 lines (44 loc) · 1.75 KB
/
Backup-DbaComputerCertificate.Tests.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#Requires -Module @{ ModuleName="Pester"; ModuleVersion="5.0"}
param(
$ModuleName = "dbatools",
$PSDefaultParameterValues = ($TestConfig = Get-TestConfig).Defaults
)
Describe "Backup-DbaComputerCertificate" -Tag "UnitTests" {
Context "Parameter validation" {
BeforeAll {
$command = Get-Command Backup-DbaComputerCertificate
$expected = $TestConfig.CommonParameters
$expected += @(
"SecurePassword",
"InputObject",
"Path",
"FilePath",
"Type",
"EnableException"
)
}
It "Has parameter: <_>" -ForEach $expected {
$command | Should -HaveParameter $PSItem
}
It "Should have exactly the number of expected parameters ($($expected.Count))" {
$hasparms = $command.Parameters.Values.Name
Compare-Object -ReferenceObject $expected -DifferenceObject $hasparms | Should -BeNullOrEmpty
}
}
}
Describe "Backup-DbaComputerCertificate" -Tag "IntegrationTests" {
Context "Certificate is added and backed up properly" {
BeforeAll {
$null = Add-DbaComputerCertificate -Path "$($TestConfig.appveyorlabrepo)\certificates\localhost.crt" -Confirm:$false
$certThumbprint = "29C469578D6C6211076A09CEE5C5797EEA0C2713"
$backupPath = "C:\temp"
}
It "Returns the proper results" {
$result = Get-DbaComputerCertificate -Thumbprint $certThumbprint | Backup-DbaComputerCertificate -Path $backupPath
$result.Name | Should -Match "$certThumbprint.cer"
}
AfterAll {
$null = Remove-DbaComputerCertificate -Thumbprint $certThumbprint -Confirm:$false
}
}
}