Don't try to convert LDAP attributes to boolean
Currently, in the ldap2py function, attribute values are attempted to be converted to python friendly types. It attempts to convert an attribute to boolean first, then fallback as string. Any attribute value that is equal to 'TRUE' or 'FALSE' are converted to boolean value. Only 'enabled' attribute require this type of handling, and it is already by enabled2py function. The additional handling on ldap2py function should be removed. Change-Id: Ifd1e91f98ae22a5e5f7b9b2ddbfddba156e16a6d Closes-Bug: #1411478
This commit is contained in:
@@ -484,3 +484,19 @@ class CommonLdapTestCase(tests.BaseTestCase):
|
||||
# flag should be 225, the 0 is dropped.
|
||||
self.assertEqual(expected_bitmask, py_result[0][1]['enabled'][0])
|
||||
self.assertEqual(user_id, py_result[0][1]['user_id'][0])
|
||||
|
||||
def test_user_id_and_user_name_with_boolean_string(self):
|
||||
boolean_strings = ['TRUE', 'FALSE', 'true', 'false', 'True', 'False',
|
||||
'TrUe' 'FaLse']
|
||||
for user_name in boolean_strings:
|
||||
user_id = uuid.uuid4().hex
|
||||
result = [(
|
||||
'cn=dummy,dc=example,dc=com',
|
||||
{
|
||||
'user_id': [user_id],
|
||||
'user_name': [user_name]
|
||||
}
|
||||
), ]
|
||||
py_result = ks_ldap.convert_ldap_result(result)
|
||||
# The user name should still be a string value.
|
||||
self.assertEqual(user_name, py_result[0][1]['user_name'][0])
|
||||
|
||||
Reference in New Issue
Block a user