win_credential - fix wildcard name (#67549)
This commit is contained in:
parent
650c3c5df3
commit
d7059881a2
3 changed files with 53 additions and 3 deletions
2
changelogs/fragments/win_credential-wildcard.yaml
Normal file
2
changelogs/fragments/win_credential-wildcard.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- win_credential - Fix issue that errors when trying to add a ``name`` with wildcards.
|
|
@ -378,8 +378,10 @@ namespace Ansible.CredentialManager
|
|||
using (SafeMemoryBuffer attributes = new SafeMemoryBuffer(attributeBytes.Length))
|
||||
{
|
||||
if (attributeBytes.Length != 0)
|
||||
{
|
||||
Marshal.Copy(attributeBytes, 0, attributes.DangerousGetHandle(), attributeBytes.Length);
|
||||
credential.Attributes = attributes.DangerousGetHandle();
|
||||
credential.Attributes = attributes.DangerousGetHandle();
|
||||
}
|
||||
|
||||
NativeHelpers.CredentialCreateFlags createFlags = 0;
|
||||
if (preserveExisting)
|
||||
|
@ -588,10 +590,10 @@ if ($state -eq "absent") {
|
|||
$new_credential = New-Object -TypeName Ansible.CredentialManager.Credential
|
||||
$new_credential.Type = $type
|
||||
$new_credential.TargetName = $name
|
||||
$new_credential.Comment = $comment
|
||||
$new_credential.Comment = if ($comment) { $comment } else { [NullString]::Value }
|
||||
$new_credential.Secret = $secret
|
||||
$new_credential.Persist = $persistence
|
||||
$new_credential.TargetAlias = $alias
|
||||
$new_credential.TargetAlias = if ($alias) { $alias } else { [NullString]::Value }
|
||||
$new_credential.UserName = $username
|
||||
|
||||
if ($null -ne $attributes) {
|
||||
|
|
|
@ -366,6 +366,52 @@
|
|||
that:
|
||||
- not remove_cred_again is changed
|
||||
|
||||
# https://github.com/ansible/ansible/issues/67278
|
||||
- name: create credential with wildcard
|
||||
win_credential:
|
||||
name: '*.{{ test_hostname }}'
|
||||
type: domain_password
|
||||
username: DOMAIN\username
|
||||
secret: password
|
||||
state: present
|
||||
persistence: enterprise
|
||||
register: wildcard_cred
|
||||
vars: *become_vars
|
||||
|
||||
- name: get result of create credential with wildcard
|
||||
test_cred_facts:
|
||||
name: '*.{{ test_hostname }}'
|
||||
type: domain_password
|
||||
register: wildcard_cred_actual
|
||||
vars: *become_vars
|
||||
|
||||
- name: assert create credential with wildcard
|
||||
assert:
|
||||
that:
|
||||
- wildcard_cred is changed
|
||||
- wildcard_cred_actual.name == '*.' ~ test_hostname
|
||||
|
||||
- name: remove credential with wildcard
|
||||
win_credential:
|
||||
name: '*.{{ test_hostname }}'
|
||||
type: domain_password
|
||||
state: absent
|
||||
register: wildcard_remove
|
||||
vars: *become_vars
|
||||
|
||||
- name: get result of remove credential with wildcard
|
||||
test_cred_facts:
|
||||
name: '*.{{ test_hostname }}'
|
||||
type: domain_password
|
||||
register: wildcard_remove_actual
|
||||
vars: *become_vars
|
||||
|
||||
- name: assert remove credential with wildcard
|
||||
assert:
|
||||
that:
|
||||
- wildcard_remove is changed
|
||||
- not wildcard_remove_actual.exists
|
||||
|
||||
- name: create generic password (check mode)
|
||||
win_credential:
|
||||
name: '{{ test_hostname }}'
|
||||
|
|
Loading…
Reference in a new issue