def test_delete_request_to_ldif(self):
     self.connection.strategy.order = dict(delRequest=['dn:', 'changetype', 'vers'])
     self.connection.delete(generate_dn(test_base, testcase_id, 'ldif-change-2'))
     response = self.connection.response.replace('\r\n', '').replace(' ', '')
     self.assertTrue('version:1' in response)
     self.assertTrue('dn:' + test_name_attr + '=' + testcase_id + 'ldif-change-2,' + test_base in response)
     self.assertTrue('changetype:delete' in response)
Exemple #2
0
 def test_unmodified_attributes_dict(self):
     attributes = get_add_user_attributes(testcase_id, 'add-operation-3', test_user_password)
     object_class = attributes.pop('objectClass')
     copy_of_attributes = deepcopy(attributes)
     dn = generate_dn(test_base, testcase_id, 'add-operation-3')
     self.connection.add(dn, object_class, attributes)
     self.connection.delete(dn)
     self.assertDictEqual(copy_of_attributes, attributes)
Exemple #3
0
 def test_unmodified_attributes_dict(self):
     attributes = get_add_user_attributes(testcase_id, 'add-operation-3',
                                          test_user_password)
     object_class = attributes.pop('objectClass')
     copy_of_attributes = deepcopy(attributes)
     dn = generate_dn(test_base, testcase_id, 'add-operation-3')
     self.connection.add(dn, object_class, attributes)
     self.connection.delete(dn)
     self.assertDictEqual(copy_of_attributes, attributes)
 def test_wrong_object_class_add(self):
     if not self.connection.strategy.pooled:
         self.connection.add(
             generate_dn(test_base, testcase_id,
                         'test-add-operation-wrong'), 'inetOrgPerson', {
                             'objectClass': ['inetOrgPerson', 'xxx'],
                             'sn': 'test-add',
                             test_name_attr: 'test-add-operation'
                         })
 def test_modify_dn_request_to_ldif(self):
     result = self.connection.modify_dn(generate_dn(test_base, testcase_id, 'ldif-change-3'), test_name_attr + '=' + testcase_id + 'ldif-change-4,' + test_base)
     if isinstance(result, int):
         self.connection.get_response(result)
     response = self.connection.response.replace('\r\n', '').replace(' ', '')
     self.assertTrue('version:1' in response)
     self.assertTrue('dn:' + test_name_attr + '=' + testcase_id + 'ldif-change-3,' + test_base in response)
     self.assertTrue('changetype:moddn' in response)
     self.assertTrue('newrdn:' + test_name_attr + '=' + testcase_id + 'ldif-change-4,' + test_base in response)
     self.assertTrue('deleteoldrdn:1' in response)
 def test_modify_add_to_ldif(self):
     result = self.connection.modify(generate_dn(test_base, testcase_id, 'ldif-change-6'), {'givenName': (MODIFY_ADD, ['givenname-6-modified'])})
     if isinstance(result, int):
         self.connection.get_response(result)
     response = self.connection.response.replace('\r\n', '').replace(' ', '')
     self.assertTrue('version:1' in response)
     self.assertTrue('dn:' + test_name_attr + '=' + testcase_id + 'ldif-change-6,' + test_base in response)
     self.assertTrue('changetype:modify' in response)
     self.assertTrue('add:givenName' in response)
     self.assertTrue('givenName:givenname-6-modified' in response)
     self.assertEqual('-', response[-1])
Exemple #7
0
 def test_add_request_to_ldif(self):
     controls = list()
     controls.append(('2.16.840.1.113719.1.27.103.7', True, 'givenName'))
     controls.append(('2.16.840.1.113719.1.27.103.7', False, 'sn'))
     if str != bytes:  # python3
         controls.append(('2.16.840.1.113719.1.27.103.7', False,
                          bytearray('\u00e0\u00e0', encoding='UTF-8')))
     else:
         controls.append(
             ('2.16.840.1.113719.1.27.103.7', False,
              bytearray(unicode('\xe0\xe0', encoding='latin1'),
                        encoding='UTF-8')))  # for python2 compatibility
     controls.append(
         ('2.16.840.1.113719.1.27.103.7', False, 'trailingspace '))
     self.connection.add(generate_dn(test_base, testcase_id,
                                     'ldif-change-1'),
                         'inetOrgPerson', {
                             'objectClass': 'inetOrgPerson',
                             'sn': 'ldif-change-1',
                             test_name_attr: 'ldif-change-1',
                             'loginEnabled': True
                         },
                         controls=controls)
     response = self.connection.response
     self.assertTrue('version: 1' in response)
     self.assertTrue('dn: ' + test_name_attr + '=' + testcase_id +
                     'ldif-change-1,' + test_base in response)
     self.assertTrue('control: 2.16.840.1.113719.1.27.103.7 true: givenName'
                     in response)
     self.assertTrue(
         'control: 2.16.840.1.113719.1.27.103.7 false: sn' in response)
     self.assertTrue(
         'control: 2.16.840.1.113719.1.27.103.7 false:: w6DDoA==' in
         response)
     self.assertTrue(
         'control: 2.16.840.1.113719.1.27.103.7 false:: dHJhaWxpbmdzcGFjZSA='
         in response)
     self.assertTrue('changetype: add' in response)
     self.assertTrue('objectClass: inetOrgPerson' in response)
     self.assertTrue('sn: ldif-change-1' in response)
     self.assertTrue(test_name_attr + ': ldif-change-1' in response)
Exemple #8
0
 def test_add_request_to_ldif(self):
     controls = list()
     controls.append(('2.16.840.1.113719.1.27.103.7', True, 'givenName'))
     controls.append(('2.16.840.1.113719.1.27.103.7', False, 'sn'))
     if str != bytes:  # python3
         controls.append(('2.16.840.1.113719.1.27.103.7', False, bytearray('\u00e0\u00e0', encoding='UTF-8')))
     else:
         controls.append(('2.16.840.1.113719.1.27.103.7', False, bytearray(unicode('\xe0\xe0', encoding='latin1'), encoding='UTF-8')))  # for python2 compatibility
     controls.append(('2.16.840.1.113719.1.27.103.7', False, 'trailingspace '))
     self.connection.add(generate_dn(test_base, testcase_id, 'ldif-change-1'), 'inetOrgPerson', {'objectClass': 'inetOrgPerson', 'sn': 'ldif-change-1', test_name_attr: 'ldif-change-1', 'loginEnabled': True}, controls=controls)
     response = self.connection.response
     self.assertTrue('version: 1' in response)
     self.assertTrue('dn: ' + test_name_attr + '=' + testcase_id + 'ldif-change-1,' + test_base in response)
     self.assertTrue('control: 2.16.840.1.113719.1.27.103.7 true: givenName' in response)
     self.assertTrue('control: 2.16.840.1.113719.1.27.103.7 false: sn' in response)
     self.assertTrue('control: 2.16.840.1.113719.1.27.103.7 false:: w6DDoA==' in response)
     self.assertTrue('control: 2.16.840.1.113719.1.27.103.7 false:: dHJhaWxpbmdzcGFjZSA=' in response)
     self.assertTrue('changetype: add' in response)
     self.assertTrue('objectClass: inetOrgPerson' in response)
     self.assertTrue('sn: ldif-change-1' in response)
     self.assertTrue(test_name_attr + ': ldif-change-1' in response)
 def test_wrong_object_class_add(self):
     if not self.connection.strategy.pooled:
         self.connection.add(generate_dn(test_base, testcase_id, 'test-add-operation-wrong'), 'inetOrgPerson', {'objectClass': ['inetOrgPerson', 'xxx'], 'sn': 'test-add', test_name_attr: 'test-add-operation'})