-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GetUserData - adding an 'attributes' parameter (#37908)
* add AD attributes to the GetUserData.py script when running 'ad-get-user' command * RN * add UT * Update Packs/CommonScripts/Scripts/GetUserData/GetUserData.yml Co-authored-by: JudithB <[email protected]> * Update Packs/CommonScripts/ReleaseNotes/1_19_1.md Co-authored-by: JudithB <[email protected]> * CR --------- Co-authored-by: JudithB <[email protected]>
- Loading branch information
1 parent
6718704
commit 95e613f
Showing
5 changed files
with
65 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
#### Scripts | ||
|
||
##### get-user-data | ||
|
||
- Added the **attributes** parameter to the ***ad-get-user*** command in this script to retrieve additional user information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1104,6 +1104,60 @@ def test_ad_get_user(self, mocker: MockerFixture): | |
assert result[1] == expected_account | ||
assert result[2] == "CN=Manager,OU=Users,DC=example,DC=com" | ||
|
||
def test_ad_get_user_attributes(self, mocker: MockerFixture): | ||
""" | ||
Given: | ||
A Command object for ad_get_user. | ||
When: | ||
The function is called with the Command object and attributes. | ||
Then: | ||
It returns the expected tuple of readable outputs, account output, and manager DN. | ||
""" | ||
command = Command( | ||
"Active Directory Query v2", "ad-get-user", {"username": "ad_user", "attributes": "whenCreated"} | ||
) | ||
mock_outputs = { | ||
"sAMAccountName": "ad_user", | ||
"displayName": "AD User", | ||
"mail": "[email protected]", | ||
"memberOf": ["Group1"], | ||
"userAccountControlFields": {"ACCOUNTDISABLE": False}, | ||
"manager": ["CN=Manager,OU=Users,DC=example,DC=com"], | ||
"whenCreated": ["2024-11-05 09:11:18+00:00"] | ||
} | ||
expected_account = { | ||
"username": {"Value": "ad_user", "Source": "Active Directory Query v2"}, | ||
"display_name": {"Value": "AD User", "Source": "Active Directory Query v2"}, | ||
"email_address": { | ||
"Value": "[email protected]", | ||
"Source": "Active Directory Query v2", | ||
}, | ||
"groups": {"Value": "Group1", "Source": "Active Directory Query v2"}, | ||
"is_enabled": {"Value": True, "Source": "Active Directory Query v2"}, | ||
"whenCreated": {'Source': 'Active Directory Query v2', | ||
'Value': '2024-11-05 09:11:18+00:00'} | ||
} | ||
|
||
mocker.patch( | ||
"GetUserData.run_execute_command", | ||
return_value=([mock_outputs], "Human readable output", []), | ||
) | ||
mocker.patch("GetUserData.get_output_key", return_value="ActiveDirectory.Users") | ||
mocker.patch("GetUserData.get_outputs", return_value=mock_outputs) | ||
mocker.patch("GetUserData.prepare_human_readable", return_value=[]) | ||
|
||
result = ad_get_user(command) | ||
|
||
assert isinstance(result, tuple) | ||
assert len(result) == 3 | ||
assert isinstance(result[0], list) | ||
assert isinstance(result[1], dict) | ||
assert isinstance(result[2], str) | ||
assert result[1] == expected_account | ||
assert result[2] == "CN=Manager,OU=Users,DC=example,DC=com" | ||
assert len(result[1]) | ||
assert "whenCreated" in result[1] | ||
|
||
def test_ad_get_user_manager(self, mocker: MockerFixture): | ||
""" | ||
Given: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters