mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 05:10:22 -07:00
Fix the integration test to comply recent changes
This commit is contained in:
parent
4c7715a4e5
commit
0e80ba1867
2 changed files with 8 additions and 10 deletions
|
@ -51,11 +51,6 @@ if (-not ($path -match "^HK(CC|CR|CU|LM|U):\\")) {
|
||||||
Fail-Json $result "path: $path is not a valid powershell path, see module documentation for examples."
|
Fail-Json $result "path: $path is not a valid powershell path, see module documentation for examples."
|
||||||
}
|
}
|
||||||
|
|
||||||
# Allow empty values as the "(default)" value
|
|
||||||
if ($name -eq "") {
|
|
||||||
$name = "(default)"
|
|
||||||
}
|
|
||||||
|
|
||||||
Function Test-ValueData {
|
Function Test-ValueData {
|
||||||
Param (
|
Param (
|
||||||
[parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] $Path,
|
[parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] $Path,
|
||||||
|
@ -145,21 +140,24 @@ if (-not (Test-Path HKCC:\)) {
|
||||||
New-PSDrive -Name HKCC -PSProvider Registry -Root HKEY_CURRENT_CONFIG
|
New-PSDrive -Name HKCC -PSProvider Registry -Root HKEY_CURRENT_CONFIG
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Convert HEX string to binary if type binary
|
# Convert HEX string to binary if type binary
|
||||||
if ($type -eq "binary" -and $data -ne $null -and $data -is [String]) {
|
if ($type -eq "binary" -and $data -ne $null -and $data -is [String]) {
|
||||||
$data = Convert-RegExportHexStringToByteArray($data)
|
$data = Convert-RegExportHexStringToByteArray($data)
|
||||||
}
|
}
|
||||||
|
|
||||||
# Special case handling for the path's default property.
|
# Special case handling for the path's default property.
|
||||||
if ($name.ToLower() -eq "(default)") {
|
if ($name -eq "" -or ($name -ne $null -and $name.ToLower() -eq "(default)")) {
|
||||||
|
# Apparently, "(default)" cannot be of type expandstring, do it ourselves
|
||||||
if ($type -eq "expandstring" -and $data -ne $null -and $data -is [String]) {
|
if ($type -eq "expandstring" -and $data -ne $null -and $data -is [String]) {
|
||||||
$data = Expand-Environment($data)
|
$data = Expand-Environment($data)
|
||||||
}
|
}
|
||||||
|
$name = "(default)"
|
||||||
$type = "string"
|
$type = "string"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Support REG_NONE with empty value
|
# Support REG_NONE with empty value
|
||||||
# FIXME: REG_NONE support is not idempotent
|
# FIXME: REG_NONE support is not idempotent yet
|
||||||
if ($type -eq "none" -or $data -eq $null) {
|
if ($type -eq "none" -or $data -eq $null) {
|
||||||
$data = New-Object byte[] 0
|
$data = New-Object byte[] 0
|
||||||
# $data = ([byte[]] @())
|
# $data = ([byte[]] @())
|
||||||
|
@ -174,7 +172,7 @@ if ($state -eq "present") {
|
||||||
# Handle binary data
|
# Handle binary data
|
||||||
$old_data = (Get-ItemProperty -Path $path | Select-Object -ExpandProperty $name)
|
$old_data = (Get-ItemProperty -Path $path | Select-Object -ExpandProperty $name)
|
||||||
|
|
||||||
if ($name.ToLower() -eq "(default)") {
|
if ($name -eq "(default)") {
|
||||||
# Special case handling for the path's default property.
|
# Special case handling for the path's default property.
|
||||||
# Because .GetValueKind() doesn't work for the (default) path property
|
# Because .GetValueKind() doesn't work for the (default) path property
|
||||||
$old_type = "String".ToLower()
|
$old_type = "String".ToLower()
|
||||||
|
@ -291,7 +289,7 @@ if ($state -eq "present") {
|
||||||
-"$name" = "$type`:$data"
|
-"$name" = "$type`:$data"
|
||||||
"@
|
"@
|
||||||
|
|
||||||
} elseif (Test-ValueData -Path $path -Value $name) {
|
} elseif (Test-ValueData -Path $path -Name $name) {
|
||||||
|
|
||||||
if (-not $check_mode) {
|
if (-not $check_mode) {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "check00_result.failed == true"
|
- "check00_result.failed == true"
|
||||||
- "check00_result.msg == 'key: HKCU\\Software is not a valid powershell path, see module documentation for examples.'"
|
- "check00_result.msg == 'path: HKCU\\Software is not a valid powershell path, see module documentation for examples.'"
|
||||||
|
|
||||||
- name: remove setting
|
- name: remove setting
|
||||||
win_regedit:
|
win_regedit:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue