Fix MsiPackage Integration Test Failures

This commit is contained in:
Mike Hendrickson
2019-04-22 17:03:47 -07:00
parent ced91beade
commit 7ddd4cecb0
4 changed files with 56 additions and 1 deletions
+3
View File
@@ -577,6 +577,9 @@ The following parameters will be the same for each process in the set:
### Unreleased
* Fixes issue where MsiPackage Integration tests fail to make an HTTPS
connection if Strong Crypto for .NET is not enabled.
[Issue #142](https://github.com/PowerShell/PSDscResources/issues/142)
* Fix Custom DSC Resource Kit PSSA Rule Failures
### 2.10.0.0
@@ -13,6 +13,14 @@ if ($PSVersionTable.PSVersion -lt [Version] '5.1')
return
}
$script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent
$testHelperFolderFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'TestHelpers'
$commonTestHelperFilePath = Join-Path -Path $testHelperFolderFilePath -ChildPath 'CommonTestHelper.psm1'
Import-Module -Name $script:commonTestHelperFilePath
# Make sure strong crypto is enabled in .NET for HTTPS tests
Enable-StrongCryptoForDotNetFour
Describe 'MsiPackage End to End Tests' {
BeforeAll {
# Import CommonTestHelper
@@ -17,6 +17,9 @@ $script:testEnvironment = Enter-DscResourceTestEnvironment `
-DscResourceName 'MSFT_MsiPackage' `
-TestType 'Unit'
# Make sure strong crypto is enabled in .NET for HTTPS tests
Enable-StrongCryptoForDotNetFour
try
{
InModuleScope 'MSFT_MsiPackage' {
+42 -1
View File
@@ -790,6 +790,46 @@ function Exit-DscResourceTestEnvironment
Restore-TestEnvironment -TestEnvironment $TestEnvironment
}
<#
.SYNOPSIS
Enables strong crypto for .NET v4.0.30319
#>
function Enable-StrongCryptoForDotNetFour
{
[OutputType([System.Boolean])]
[CmdletBinding()]
param()
$regBases = @(
'HKLM:\SOFTWARE\Microsoft'
'HKLM:\SOFTWARE\Wow6432Node'
)
$net4Suffix = 'Microsoft\.NetFramework\v4.0.30319'
foreach ($regBase in $regBases)
{
$regPath = Join-Path -Path $regBase -ChildPath $net4Suffix
if ($null -ne (Get-Item -Path $regPath -ErrorAction SilentlyContinue))
{
$useStrongCryptoProp = Get-ItemProperty -Path $regPath -Name 'SchUseStrongCrypto' -ErrorAction SilentlyContinue
if ($null -eq $useStrongCryptoProp -or $useStrongCryptoProp.SchUseStrongCrypto -ne 1)
{
Write-Verbose -Message "Setting property SchUseStrongCrypto at path '$regPath' to 1"
Set-ItemProperty -Path $regPath -Name 'SchUseStrongCrypto' -Value '1' -Type DWord -ErrorAction Stop
}
}
else
{
Write-Warning -Message "Failed to find registry key at path: $regPath. Skipping setting SchUseStrongCrypto to 1."
continue
}
}
}
Export-ModuleMember -Function @(
'Test-GetTargetResourceResult', `
'Wait-ScriptBlockReturnTrue', `
@@ -802,5 +842,6 @@ Export-ModuleMember -Function @(
'Invoke-SetTargetResourceUnitTest', `
'Invoke-TestTargetResourceUnitTest', `
'Invoke-ExpectedMocksAreCalledTest', `
'Invoke-GenericUnitTest'
'Invoke-GenericUnitTest',
'Enable-StrongCryptoForDotNetFour'
)