Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Rover_Lookup/lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,11 @@ def github_username_to_emails(

# Construct the LDAP filter to match the GitHub "Professional Social Media" URL.
# The rhatSocialURL field contains values like "Github->https://github.com/username".
# However, 5% of the entries include a trailing slash (which GitHub accepts),
# so look for those, too.
github_url = f"https://github.com/{github_username}"
ldap_filter = f"(rhatSocialURL=Github->{github_url})"
filter_clause = f"rhatSocialURL=Github->{github_url}"
ldap_filter = f"(|({filter_clause})({filter_clause}/))"

# Attributes to retrieve (email fields)
attributes = ["rhatPrimaryMail", "mail", "rhatPreferredAlias"]
Expand Down
7 changes: 3 additions & 4 deletions Rover_Lookup/tests/test_lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,9 @@ def test_successful_lookup_single_record(self, mock_connection_class, caplog):
# Verify LDAP query was called correctly
mock_conn.search.assert_called_once()
search_args = mock_conn.search.call_args
assert (
search_args[1]["search_filter"]
== "(rhatSocialURL=Github->https://github.com/test-user)"
)
filter_part = "rhatSocialURL=Github->https://github.com/test-user"
expected_filter = f"(|({filter_part})({filter_part}/))"
assert search_args[1]["search_filter"] == expected_filter
assert "rhatPrimaryMail" in search_args[1]["attributes"]
assert "mail" in search_args[1]["attributes"]
assert "rhatPreferredAlias" in search_args[1]["attributes"]
Expand Down