示例#1
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])
示例#2
0
 def test_user_id_begins_with_0(self):
     user_id = "0123456"
     result = [("cn=dummy,dc=example,dc=com", {"user_id": [user_id], "enabled": ["TRUE"]})]
     py_result = ks_ldap.convert_ldap_result(result)
     # The user id should be 0123456, and the enabled
     # flag should be True
     self.assertIs(py_result[0][1]["enabled"][0], True)
     self.assertEqual(user_id, py_result[0][1]["user_id"][0])
示例#3
0
 def test_user_id_and_bitmask_begins_with_0(self):
     user_id = "0123456"
     bitmask = "0225"
     expected_bitmask = 225
     result = [("cn=dummy,dc=example,dc=com", {"user_id": [user_id], "enabled": [bitmask]})]
     py_result = ks_ldap.convert_ldap_result(result)
     # The user id should be 0123456, and the enabled
     # 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])
示例#4
0
 def test_user_id_begins_with_0(self):
     user_id = '0123456'
     result = [
         ('cn=dummy,dc=example,dc=com', {
             'user_id': [user_id],
             'enabled': ['TRUE']
         }),
     ]
     py_result = ks_ldap.convert_ldap_result(result)
     # The user id should be 0123456, and the enabled
     # flag should be True
     self.assertIs(py_result[0][1]['enabled'][0], True)
     self.assertEqual(user_id, py_result[0][1]['user_id'][0])
示例#5
0
 def test_binary_attribute_values(self):
     result = [
         ('cn=junk,dc=example,dc=com', {
             'cn': ['junk'],
             'sn': [uuid.uuid4().hex],
             'mail': [uuid.uuid4().hex],
             'binary_attr': ['\x00\xFF\x00\xFF']
         }),
     ]
     py_result = ks_ldap.convert_ldap_result(result)
     # The attribute containing the binary value should
     # not be present in the converted result.
     self.assertNotIn('binary_attr', py_result[0][1])
示例#6
0
 def test_user_id_begins_with_0(self):
     user_id = '0123456'
     result = [(
         'cn=dummy,dc=example,dc=com',
         {
             'user_id': [user_id],
             'enabled': ['TRUE']
         }
     ), ]
     py_result = ks_ldap.convert_ldap_result(result)
     # The user id should be 0123456, and the enabled
     # flag should be True
     self.assertIs(py_result[0][1]['enabled'][0], True)
     self.assertEqual(user_id, py_result[0][1]['user_id'][0])
示例#7
0
 def test_binary_attribute_values(self):
     result = [(
         'cn=junk,dc=example,dc=com',
         {
             'cn': ['junk'],
             'sn': [uuid.uuid4().hex],
             'mail': [uuid.uuid4().hex],
             'binary_attr': ['\x00\xFF\x00\xFF']
         }
     ), ]
     py_result = ks_ldap.convert_ldap_result(result)
     # The attribute containing the binary value should
     # not be present in the converted result.
     self.assertNotIn('binary_attr', py_result[0][1])
示例#8
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])
示例#9
0
 def test_user_id_and_bitmask_begins_with_0(self):
     user_id = '0123456'
     bitmask = '0225'
     expected_bitmask = 225
     result = [
         ('cn=dummy,dc=example,dc=com', {
             'user_id': [user_id],
             'enabled': [bitmask]
         }),
     ]
     py_result = ks_ldap.convert_ldap_result(result)
     # The user id should be 0123456, and the enabled
     # 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])
示例#10
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])
示例#11
0
 def test_user_id_and_bitmask_begins_with_0(self):
     user_id = '0123456'
     bitmask = '0225'
     expected_bitmask = 225
     result = [(
         'cn=dummy,dc=example,dc=com',
         {
             'user_id': [user_id],
             'enabled': [bitmask]
         }
     ), ]
     py_result = ks_ldap.convert_ldap_result(result)
     # The user id should be 0123456, and the enabled
     # 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])
示例#12
0
 def test_binary_attribute_values(self):
     result = [
         (
             "cn=junk,dc=example,dc=com",
             {
                 "cn": ["junk"],
                 "sn": [uuid.uuid4().hex],
                 "mail": [uuid.uuid4().hex],
                 "binary_attr": ["\x00\xFF\x00\xFF"],
             },
         )
     ]
     py_result = ks_ldap.convert_ldap_result(result)
     # The attribute containing the binary value should
     # not be present in the converted result.
     self.assertNotIn("binary_attr", py_result[0][1])