Skip to content

Commit 29cf271

Browse files
committed
Testing Get-DbaNetworkConfiguration - Certify the virtual name of a cluster instance
On a failover cluster instance the suitability check correctly compares the certificate against the virtual server name, but the test issued its certificate with plain -ComputerName, which New-DbaComputerCertificate resolves to the node the instance currently runs on. The test now reads VSName first and passes it as -ClusterInstanceName, the documented way to certify a cluster instance. Stand-alone instances are unchanged. (do Get-DbaNetworkConfiguration)
1 parent 0473789 commit 29cf271

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

tests/Get-DbaNetworkConfiguration.Tests.ps1

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,24 @@ Describe $CommandName -Tag IntegrationTests {
6464
Context "Command returns correct certificate information" {
6565
BeforeAll {
6666
$computerName = ([DbaInstanceParameter]$TestConfig.InstanceSingle).ComputerName
67-
$certificate = New-DbaComputerCertificate -ComputerName $computerName -SelfSigned -KeyLength 2048 -HashAlgorithm Sha256 -EnableException
67+
68+
# On a failover cluster instance the certificate must carry the virtual network name of the
69+
# instance, but New-DbaComputerCertificate resolves that name to the node it currently runs
70+
# on and would issue the certificate for the node. So read the virtual server name first and
71+
# pass it as ClusterInstanceName, which is the documented way to certify a cluster instance.
72+
# On a stand-alone instance VSName is empty and the certificate is issued for the node.
73+
$vsName = (Get-DbaNetworkConfiguration -SqlInstance $TestConfig.InstanceSingle -OutputType Certificate -EnableException).VSName
74+
$splatCertificate = @{
75+
ComputerName = $computerName
76+
SelfSigned = $true
77+
KeyLength = 2048
78+
HashAlgorithm = "Sha256"
79+
EnableException = $true
80+
}
81+
if ($vsName) {
82+
$splatCertificate.ClusterInstanceName = $vsName
83+
}
84+
$certificate = New-DbaComputerCertificate @splatCertificate
6885
$results = Get-DbaNetworkConfiguration -SqlInstance $TestConfig.InstanceSingle -EnableException
6986
}
7087

0 commit comments

Comments
 (0)