tests/SslCert.tests.ps1
Describe 'SslCert' { BeforeAll { $sslcert = Get-SslCert -IpPort 0.0.0.0:99 -ErrorAction SilentlyContinue if ($null -ne $sslcert) { Remove-SslCert -IpPort 0.0.0.0:99 -Confirm:$false } Get-ChildItem cert:\localmachine\my | Where-Object FriendlyName -eq 'PowerShell NetshUtils.SslCert.tests' | Remove-Item $script:cert = New-SelfSignedCertificate -Subject localhost -FriendlyName "PowerShell NetshUtils.SslCert.tests" -CertStoreLocation Cert:\LocalMachine\My\ } AfterAll { $sslcert = Get-SslCert -IpPort 0.0.0.0:99 -ErrorAction SilentlyContinue if ($null -ne $sslcert) { Remove-SslCert -IpPort 0.0.0.0:99 -Confirm:$false } Get-ChildItem cert:\localmachine\my | Where-Object FriendlyName -eq 'PowerShell NetshUtils.SslCert.tests' | Remove-Item } It 'can add new sslcert binding' { { $ConfirmPreference = "None" Add-SslCert -IpPort 0.0.0.0:99 -CertHash $cert.Thumbprint -AppId (New-Guid).Guid -ErrorAction Stop } | Should -Not -Throw } It 'can get a single sslcert binding' { $sslcert = Get-SslCert -IpPort 0.0.0.0:99 $null -ne $sslcert | Should -BeTrue } It 'fails when getting an sslcert that doesn''t exist' { { Get-SslCert -IpPort 0.0.0.0:100 -ErrorAction Stop } | Should -Throw } It 'can remove an sslcert binding' { { Remove-SslCert -IpPort 0.0.0.0:99 -ErrorAction Stop -Confirm:$false } | Should -Not -Throw { Get-SslCert -IpPort 0.0.0.0:99 -ErrorAction Stop } | Should -Throw } } |