Пример #1
0
 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)
Пример #2
0
 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
     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)
Пример #3
0
 def test_wrong_object_class_add(self):
     if not self.connection.strategy.pooled:
         self.assertRaises(
             LDAPObjectClassError, 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'
                         })
Пример #4
0
 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
     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)
Пример #5
0
 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)
Пример #6
0
 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
     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])
Пример #7
0
 def test_move_dn_request_to_ldif(self):
     result = self.connection.modify_dn(generate_dn(test_base, testcase_id, 'ldif-change-5'), test_name_attr + '=' + testcase_id + 'ldif-change-5', delete_old_dn=False, new_superior=test_moved)
     if isinstance(result, int):
         self.connection.get_response(result)
     response = self.connection.response
     self.assertTrue('version: 1' in response)
     self.assertTrue('dn: ' + test_name_attr + '=' + testcase_id + 'ldif-change-5,' + test_base in response)
     self.assertTrue('changetype: modrdn' in response)
     self.assertTrue('newrdn: ' + test_name_attr + '=' + testcase_id + 'ldif-change-5' in response)
     self.assertTrue('deleteoldrdn: 0' in response)
     self.assertTrue('newsuperior: ' + test_moved in response)
Пример #8
0
 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])
Пример #9
0
 def test_modify_delete_to_ldif(self):
     result = self.connection.modify(
         generate_dn(test_base, testcase_id, 'ldif-change-8'),
         {'givenName': (MODIFY_DELETE, ['givenname-8-deleted'])})
     if isinstance(result, int):
         self.connection.get_response(result)
     response = self.connection.response
     self.assertTrue('version: 1' in response)
     self.assertTrue('dn: ' + test_name_attr + '=' + testcase_id +
                     'ldif-change-8,' + test_base in response)
     self.assertTrue('changetype: modify' in response)
     self.assertTrue('delete: givenName' in response)
     self.assertTrue('givenName: givenname-8-deleted' in response)
     self.assertEqual('-', response[-1])
Пример #10
0
 def test_move_dn_request_to_ldif(self):
     result = self.connection.modify_dn(
         generate_dn(test_base, testcase_id, 'ldif-change-5'),
         test_name_attr + '=' + testcase_id + 'ldif-change-5',
         delete_old_dn=False,
         new_superior=test_moved)
     if isinstance(result, int):
         self.connection.get_response(result)
     response = self.connection.response
     self.assertTrue('version: 1' in response)
     self.assertTrue('dn: ' + test_name_attr + '=' + testcase_id +
                     'ldif-change-5,' + test_base in response)
     self.assertTrue('changetype: modrdn' in response)
     self.assertTrue('newrdn: ' + test_name_attr + '=' + testcase_id +
                     'ldif-change-5' in response)
     self.assertTrue('deleteoldrdn: 0' in response)
     self.assertTrue('newsuperior: ' + test_moved in response)
Пример #11
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 compatability
     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'}, 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)
Пример #12
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 compatability
     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'}, 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)
Пример #13
0
 def test_wrong_object_class_add(self):
     if not self.connection.strategy.pooled:
         self.assertRaises(LDAPObjectClassError, 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'})