1+ # Requires -Module @ { ModuleName = " Pester" ; ModuleVersion = " 5.0" }
2+ param (
3+ $ModuleName = " dbatools" ,
4+ $CommandName = " Get-DbaNetworkEncryption" ,
5+ $PSDefaultParameterValues = $TestConfig.Defaults
6+ )
7+
8+ Describe $CommandName - Tag UnitTests {
9+ Context " Parameter validation" {
10+ It " Should have the expected parameters" {
11+ $hasParameters = (Get-Command $CommandName ).Parameters.Values.Name | Where-Object { $PSItem -notin (" WhatIf" , " Confirm" ) }
12+ $expectedParameters = $TestConfig.CommonParameters
13+ $expectedParameters += @ (
14+ " SqlInstance" ,
15+ " SqlCredential" ,
16+ " EnableException"
17+ )
18+ Compare-Object - ReferenceObject $expectedParameters - DifferenceObject $hasParameters | Should - BeNullOrEmpty
19+ }
20+ }
21+ }
22+
23+ Describe $CommandName - Tag IntegrationTests {
24+ BeforeAll {
25+ $PSDefaultParameterValues [" *-Dba*:EnableException" ] = $true
26+ $PSDefaultParameterValues.Remove (" *-Dba*:EnableException" )
27+ }
28+
29+ Context " Certificate retrieval" {
30+ BeforeAll {
31+ # Attempt to retrieve the certificate - not all environments have TLS configured
32+ $result = Get-DbaNetworkEncryption - SqlInstance $TestConfig.InstanceSingle - WarningAction SilentlyContinue
33+ }
34+
35+ It " Should return certificate with expected properties when TLS is configured" {
36+ if ($null -eq $result ) {
37+ Set-ItResult - Skipped - Because " No TLS certificate is configured on this SQL Server instance"
38+ }
39+ $result.SqlInstance | Should -Not - BeNullOrEmpty
40+ $result.Subject | Should -Not - BeNullOrEmpty
41+ $result.Thumbprint | Should -Not - BeNullOrEmpty
42+ $result.Expires | Should - BeOfType [datetime ]
43+ $result.NotBefore | Should - BeOfType [datetime ]
44+ }
45+ }
46+ }
0 commit comments