Beispiel #1
0
 def test_user_id_attribute_is_uuid_in_byte_form(self):
     results = [('cn=alice,dc=example,dc=com', {
         'cn': [b'cn=alice'],
         'objectGUID': [b'\xdd\xd8Rt\xee]bA\x8e(\xe39\x0b\xe1\xf8\xe8'],
         'email': [uuid.uuid4().hex],
         'sn': [uuid.uuid4().hex]
     })]
     py_result = common_ldap.convert_ldap_result(results)
     exp_object_guid = '7452d8dd-5dee-4162-8e28-e3390be1f8e8'
     self.assertEqual(exp_object_guid, py_result[0][1]['objectGUID'][0])
Beispiel #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 = common_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])
Beispiel #3
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': [b'\x00\xFF\x00\xFF']
         }),
     ]
     py_result = common_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])
Beispiel #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 = common_ldap.convert_ldap_result(result)
     # The user id should be 0123456, and the enabled
     # flag should be True
     self.assertIs(True, py_result[0][1]['enabled'][0])
     self.assertEqual(user_id, py_result[0][1]['user_id'][0])
Beispiel #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': [b'\x00\xFF\x00\xFF']
         }
     ), ]
     py_result = common_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])
Beispiel #6
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 = common_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])
Beispiel #7
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 = common_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])
Beispiel #8
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 = common_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])