Skip to content

Commit f3b0354

Browse files
add data set "with empty login/name Attributes" use case
1 parent e56cd7d commit f3b0354

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

script/ldap.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,16 @@ def fetch_users_of_group(group_name):
8080
paged_size=5)
8181
for user_set in user_data:
8282
data_set = user_set["attributes"]
83+
login = clean_attribute(data_set[configuration.LDAP_USER_LOGIN_ATTRIBUTE])
84+
name = clean_attribute(data_set[configuration.LDAP_USER_NAME_ATTRIBUTE])
8385
mail = clean_attribute(data_set[configuration.LDAP_USER_MAIL_ATTRIBUTE])
86+
if not login or not name:
87+
continue
8488
if not mail:
8589
mail = clean_attribute(data_set[configuration.LDAP_USER_LOGIN_ATTRIBUTE])
8690
result.append({
87-
"login": clean_attribute(data_set[configuration.LDAP_USER_LOGIN_ATTRIBUTE]),
88-
"name": clean_attribute(data_set[configuration.LDAP_USER_NAME_ATTRIBUTE]),
91+
"login": login,
92+
"name": name,
8993
"email": mail
9094
})
9195
connection.unbind()

tests/test_ldap.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ def test_creates_connection(self, mock_configuration, mock_server, mock_connecti
4444
self.assertEqual(output, True)
4545
self.assertEqual(mock_server.call_count, 1)
4646
self.assertEqual(mock_connection.call_count, 1)
47-
mock_server.assert_called_with("my_url", get_info=ALL)
48-
mock_connection.assert_called_with(mock_server_object, user="my_url\\my_user", password="my_password",
47+
mock_server.assert_called_with("my_url", get_info=ALL, use_ssl=ANY, port=ANY)
48+
mock_connection.assert_called_with(mock_server_object, user="my_user", password="my_password",
4949
authentication=NTLM, read_only=True)
5050

5151

0 commit comments

Comments
 (0)