mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-08 22:30:04 -07:00
Ansible.ModuleUtils.SID - allow SID as an input to allow people to specify well know SIDs instead of the name (#39400)
This commit is contained in:
parent
d90c36e320
commit
0d1daf4de8
6 changed files with 53 additions and 81 deletions
|
@ -3,6 +3,9 @@
|
|||
#Requires -Module Ansible.ModuleUtils.Legacy
|
||||
#Requires -Module Ansible.ModuleUtils.SID
|
||||
|
||||
$params = Parse-Args $args
|
||||
$sid_account = Get-AnsibleParam -obj $params -name "sid_account" -type "str" -failifempty $true
|
||||
|
||||
Function Assert-Equals($actual, $expected) {
|
||||
if ($actual -ne $expected) {
|
||||
Fail-Json @{} "actual != expected`nActual: $actual`nExpected: $expected"
|
||||
|
@ -76,4 +79,15 @@ foreach ($test in $tests) {
|
|||
}
|
||||
}
|
||||
|
||||
# the account to SID test is run outside of the normal run as we can't test it
|
||||
# in the normal test suite
|
||||
# Calling Convert-ToSID with a string like a SID should return that SID back
|
||||
$actual = Convert-ToSID -account_name $sid_account
|
||||
Assert-Equals -actual $actual -expected $sid_account
|
||||
|
||||
# Calling COnvert-ToSID with a string prefixed with .\ should return the SID
|
||||
# for a user that is called that SID and not the SID passed in
|
||||
$actual = Convert-ToSID -account_name ".\$sid_account"
|
||||
Assert-Equals -actual ($actual -ne $sid_account) -expected $true
|
||||
|
||||
Exit-Json @{ data = "success" }
|
||||
|
|
|
@ -56,9 +56,23 @@
|
|||
that:
|
||||
- camel_conversion.data == 'success'
|
||||
|
||||
- name: call module with SID tests
|
||||
sid_utils_test:
|
||||
register: sid_test
|
||||
- block:
|
||||
- name: create test user with well know SID as the name
|
||||
win_user:
|
||||
name: S-1-0-0
|
||||
password: AbcDef123!@#
|
||||
state: present
|
||||
|
||||
- name: call module with SID tests
|
||||
sid_utils_test:
|
||||
sid_account: S-1-0-0
|
||||
register: sid_test
|
||||
|
||||
always:
|
||||
- name: remove test SID user
|
||||
win_user:
|
||||
name: S-1-0-0
|
||||
state: absent
|
||||
|
||||
- assert:
|
||||
that:
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
name: '{{test_win_user_right_name}}'
|
||||
users: FakeUser
|
||||
register: fail_invalid_user
|
||||
failed_when: "'Account Name: FakeUser is not a valid account, cannot get SID' not in fail_invalid_user.msg"
|
||||
failed_when: "'account_name FakeUser is not a valid account, cannot get SID' not in fail_invalid_user.msg"
|
||||
|
||||
- name: remove from empty right check
|
||||
win_user_right:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue