-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/mx 1660 ldap search endpoint (#294)
# PR Context <!-- Additional info for the reviewer --> - LDAP search endpoint in mex-backend - mex-backend has a new search endpoint returning ldap persons # Added <!-- New features and interfaces --> - extract ldap: get_persons methods and tests # Changes <!-- Changes in existing functionality --> # Deprecated <!-- Soon-to-be removed features --> # Removed <!-- Definitely removed features --> # Fixed <!-- Fixed bugs --> # Security <!-- Fixed vulnerabilities --> --------- Signed-off-by: vyvytranngoc <[email protected]> Co-authored-by: Nicolas Drebenstedt <[email protected]>
- Loading branch information
1 parent
a0181bf
commit d581817
Showing
3 changed files
with
76 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,13 +5,16 @@ | |
from mex.common.identity import get_provider | ||
from mex.common.ldap.extract import ( | ||
_get_merged_ids_by_attribute, | ||
get_count_of_found_persons_by_name, | ||
get_merged_ids_by_email, | ||
get_merged_ids_by_employee_ids, | ||
get_merged_ids_by_query_string, | ||
get_persons_by_name, | ||
) | ||
from mex.common.ldap.models.person import LDAPPerson, LDAPPersonWithQuery | ||
from mex.common.models import ExtractedPrimarySource | ||
from mex.common.types import Identifier | ||
from tests.ldap.conftest import SAMPLE_PERSON_ATTRS, LDAPMocker | ||
|
||
|
||
@pytest.fixture | ||
|
@@ -173,3 +176,35 @@ def test_get_merged_ids_by_query_string( | |
ldap_persons_with_query, ldap_primary_source | ||
) | ||
assert merged_ids_by_query_string == expected | ||
|
||
|
||
def test_get_persons_by_name_mocked(ldap_mocker: LDAPMocker) -> None: | ||
ldap_mocker([[SAMPLE_PERSON_ATTRS]]) | ||
persons = get_persons_by_name(surname="Sample", given_name="Sam") | ||
persons_list = list(persons) | ||
expected = { | ||
"company": "RKI", | ||
"department": "XY", | ||
"departmentNumber": "XY2", | ||
"displayName": "Sample, Sam", | ||
"employeeID": "1024", | ||
"givenName": ["Sam"], | ||
"mail": ["[email protected]"], | ||
"objectGUID": UUID("00000000-0000-4000-8000-000000000000"), | ||
"ou": ["XY"], | ||
"sAMAccountName": "SampleS", | ||
"sn": "Sample", | ||
} | ||
assert len(persons_list) == 1 | ||
assert ( | ||
persons_list[0].model_dump(exclude_none=True)["givenName"] | ||
== expected["givenName"] | ||
) | ||
|
||
|
||
def test_get_count_of_found_persons_by_name_mocked(ldap_mocker: LDAPMocker) -> None: | ||
ldap_mocker([[SAMPLE_PERSON_ATTRS]]) | ||
persons_count = get_count_of_found_persons_by_name( | ||
surname="Sample", given_name="Sam" | ||
) | ||
assert persons_count == 1 |