From 6f0b4ca521b26e20c4557bde7d7c810463a988ed Mon Sep 17 00:00:00 2001 From: Lukas Sassl Date: Tue, 8 Mar 2022 16:27:56 +0100 Subject: [PATCH] Improved certificate unit test --- .../Tests/Get-ExchangeServerCertificates.Tests.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Diagnostics/HealthChecker/DataCollection/ExchangeInformation/Tests/Get-ExchangeServerCertificates.Tests.ps1 b/Diagnostics/HealthChecker/DataCollection/ExchangeInformation/Tests/Get-ExchangeServerCertificates.Tests.ps1 index 5eab35493e..5e12275ebb 100644 --- a/Diagnostics/HealthChecker/DataCollection/ExchangeInformation/Tests/Get-ExchangeServerCertificates.Tests.ps1 +++ b/Diagnostics/HealthChecker/DataCollection/ExchangeInformation/Tests/Get-ExchangeServerCertificates.Tests.ps1 @@ -28,6 +28,7 @@ Describe "Testing Get-ExchangeServerCertificates.ps1" { BeforeAll { Mock Get-AuthConfig -MockWith { return Import-Clixml $Script:parentPath\Tests\GetAuthConfig.xml } Mock Get-ExchangeCertificate -MockWith { return Import-Clixml $Script:parentPath\Tests\GetExchangeCertificate.xml } + Mock Get-Date -MockWith { return ([System.Convert]::ToDateTime("01/01/2022", [System.Globalization.DateTimeFormatInfo]::InvariantInfo)) } } Context "Valid Exchange Server Certificates Detected" { @@ -43,6 +44,7 @@ Describe "Testing Get-ExchangeServerCertificates.ps1" { $results[0].SignatureHashAlgorithm | Should -Be "sha1" $results[0].SignatureHashAlgorithmSecure | Should -Be 1 $results[0].IsSanCertificate | Should -Be $false + $results[0].LifetimeInDays | Should -Be 1652 $results[0].PublicKeySize | Should -Be 2048 } @@ -55,6 +57,7 @@ Describe "Testing Get-ExchangeServerCertificates.ps1" { $results[1].SignatureHashAlgorithmSecure | Should -Be 1 $results[1].IsSanCertificate | Should -Be $true ($results[1].Namespaces).Count | Should -Be 2 + $results[1].LifetimeInDays | Should -Be 1678 $results[1].PublicKeySize | Should -Be 2048 }