-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1196 from SEKOIA-IO/adsearch_manage_dates
datetime management from ad results
- Loading branch information
Showing
4 changed files
with
17 additions
and
3 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
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 |
---|---|---|
|
@@ -2,7 +2,9 @@ | |
from microsoft_ad.search import SearchAction | ||
from unittest.mock import patch | ||
import pytest | ||
import json | ||
import orjson | ||
import datetime | ||
from ldap3.core.timezone import OffsetTzInfo | ||
|
||
|
||
def configured_action(action: MicrosoftADAction): | ||
|
@@ -89,6 +91,7 @@ def test_ldap_action_serialization(): | |
"attributes": { | ||
"cn": [b"John Doe"], | ||
"mail": [b"[email protected]"], | ||
"date": datetime.datetime(9999, 12, 31, 23, 59, 59, 999999, tzinfo=OffsetTzInfo(offset=0, name="UTC")), | ||
"objectGUID": b"\x12\x34\x56\x78\x90", | ||
"memberOf": [b"CN=Group1,DC=example,DC=com", b"CN=Group2,DC=example,DC=com"], | ||
}, | ||
|
@@ -98,13 +101,14 @@ def test_ldap_action_serialization(): | |
"attributes": { | ||
"cn": [b"Jane Smith"], | ||
"mail": [b"[email protected]"], | ||
"date": datetime.datetime(2024, 11, 21, 15, 16, 38, tzinfo=datetime.timezone.utc), | ||
"objectGUID": b"\x98\x76\x54\x32\x10", | ||
"memberOf": [b"CN=Group1,DC=example,DC=com", b"CN=Admins,DC=example,DC=com"], | ||
}, | ||
}, | ||
] | ||
results = action.transform_ldap_results(entries) | ||
try: | ||
json.dumps(results) | ||
orjson.dumps(results) | ||
except (TypeError, ValueError) as e: | ||
assert False, f"Serialization failed: {str(e)}" |