mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 14:22:46 +00:00
win_credential - fix encoding for text based secrets (#54695)
* win_credential - fix encoding for text based secrets * Fix py2 encoding issues
This commit is contained in:
@@ -555,7 +555,7 @@ if ($null -ne $secret) {
|
|||||||
if ($secret_format -eq "base64") {
|
if ($secret_format -eq "base64") {
|
||||||
$secret = [System.Convert]::FromBase64String($secret)
|
$secret = [System.Convert]::FromBase64String($secret)
|
||||||
} else {
|
} else {
|
||||||
$secret = [System.Text.Encoding]::UTF8.GetBytes($secret)
|
$secret = [System.Text.Encoding]::Unicode.GetBytes($secret)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,8 @@ options:
|
|||||||
data_format:
|
data_format:
|
||||||
description:
|
description:
|
||||||
- Controls the input type for I(data).
|
- Controls the input type for I(data).
|
||||||
- If C(text), I(data) is a text string that is UTF-8 encoded to bytes.
|
- If C(text), I(data) is a text string that is UTF-16LE encoded to
|
||||||
|
bytes.
|
||||||
- If C(base64), I(data) is a base64 string that is base64 decoded to
|
- If C(base64), I(data) is a base64 string that is base64 decoded to
|
||||||
bytes.
|
bytes.
|
||||||
type: str
|
type: str
|
||||||
@@ -88,7 +89,7 @@ options:
|
|||||||
secret_format:
|
secret_format:
|
||||||
description:
|
description:
|
||||||
- Controls the input type for I(secret).
|
- Controls the input type for I(secret).
|
||||||
- If C(text), I(secret) is a text string that is UTF-8 encoded to bytes.
|
- If C(text), I(secret) is a text string that is UTF-16LE encoded to bytes.
|
||||||
- If C(base64), I(secret) is a base64 string that is base64 decoded to
|
- If C(base64), I(secret) is a base64 string that is base64 decoded to
|
||||||
bytes.
|
bytes.
|
||||||
type: str
|
type: str
|
||||||
|
|||||||
@@ -409,6 +409,10 @@
|
|||||||
register: generic_password_actual
|
register: generic_password_actual
|
||||||
vars: *become_vars
|
vars: *become_vars
|
||||||
|
|
||||||
|
- name: set encoded password result
|
||||||
|
set_fact:
|
||||||
|
encoded_pass: '{{ "genericpass" | string | b64encode(encoding="utf-16-le") }}'
|
||||||
|
|
||||||
- name: assert create generic password
|
- name: assert create generic password
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
@@ -419,7 +423,7 @@
|
|||||||
- generic_password_actual.comment == None
|
- generic_password_actual.comment == None
|
||||||
- generic_password_actual.name == test_hostname
|
- generic_password_actual.name == test_hostname
|
||||||
- generic_password_actual.persistence == "Enterprise"
|
- generic_password_actual.persistence == "Enterprise"
|
||||||
- generic_password_actual.secret == "genericpass"|b64encode
|
- generic_password_actual.secret == encoded_pass
|
||||||
- generic_password_actual.type == "Generic"
|
- generic_password_actual.type == "Generic"
|
||||||
- generic_password_actual.username == "genericuser"
|
- generic_password_actual.username == "genericuser"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user