mirror of
https://github.com/PowerShell/PSDscResources
synced 2026-06-21 13:45:29 +00:00
Fix MsiPackage Integration Test Failures
This commit is contained in:
@@ -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' {
|
||||
|
||||
@@ -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'
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user