本文整理汇总了Python中test.config.add_user函数的典型用法代码示例。如果您正苦于以下问题:Python add_user函数的具体用法?Python add_user怎么用?Python add_user使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了add_user函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: setUp
def setUp(self):
global testcase_id
testcase_id = random_id()
self.connection = get_connection()
self.delete_at_teardown = []
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'ldif-content-1'))
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'ldif-content-2'))
开发者ID:cannatag,项目名称:ldap3,代码行数:7,代码来源:testLDIF-content.py
示例2: test_search_and_delete_entry
def test_search_and_delete_entry(self):
add_user(self.connection, testcase_id, 'del1', attributes={'givenName': 'givenname-delete'})
read_only_entry = self.get_entry('del1')
self.assertEqual(read_only_entry.entry_status, STATUS_READ)
writable_entry = read_only_entry.entry_writable('inetorgperson')
self.assertEqual(writable_entry.entry_status, STATUS_WRITABLE)
writable_entry.entry_delete()
self.assertEqual(writable_entry.entry_status, STATUS_READY_FOR_DELETION)
result = writable_entry.entry_commit_changes()
self.assertEqual(writable_entry.entry_status, STATUS_DELETED)
self.assertTrue(result)
counter = 20
while counter > 0: # waits for at maximum 20 times - delete operation can take some time to complete
result = self.connection.search(search_base=test_base, search_filter='(' + test_name_attr + '=' + testcase_id + 'del1)', attributes=[test_name_attr, 'givenName'])
if not self.connection.strategy.sync:
response, result = self.connection.get_response(result)
entries = self.connection._get_entries(response)
else:
result = self.connection.result
entries = self.connection.entries
if len(entries) == 0:
break
sleep(3)
counter -= 1
self.assertEqual(result['description'], 'success')
self.assertEqual(len(entries), 0)
self.compare_entries(read_only_entry, writable_entry)
开发者ID:cannatag,项目名称:ldap3,代码行数:28,代码来源:testSearchAndModifyEntries.py
示例3: test_check_groups_memberships
def test_check_groups_memberships(self):
if test_server_type == 'EDIR' and not self.connection.strategy.pooled and not self.connection.strategy.no_real_dsa:
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'user-1'))
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'user-2'))
self.delete_at_teardown.append(add_group(self.connection, testcase_id, 'group-1'))
self.delete_at_teardown.append(add_group(self.connection, testcase_id, 'group-2'))
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'user-3'))
self.delete_at_teardown.append(add_group(self.connection, testcase_id, 'group-3'))
self.connection.extend.novell.add_members_to_groups((self.delete_at_teardown[0][0], self.delete_at_teardown[1][0]),
self.delete_at_teardown[2][0],
fix=True,
transaction=True)
self.connection.extend.novell.add_members_to_groups((self.delete_at_teardown[0][0], self.delete_at_teardown[1][0]),
self.delete_at_teardown[3][0],
fix=True,
transaction=True)
# valid users in valid groups
result = self.connection.extend.novell.check_groups_memberships((self.delete_at_teardown[0][0], self.delete_at_teardown[1][0]), (self.delete_at_teardown[2][0],self.delete_at_teardown[3][0]))
self.assertTrue(result)
# invalid users in valid groups
result = self.connection.extend.novell.check_groups_memberships((self.delete_at_teardown[0][0], self.delete_at_teardown[3][0]), (self.delete_at_teardown[2][0],self.delete_at_teardown[3][0]))
self.assertFalse(result)
# invalid users in invalid groups
result = self.connection.extend.novell.check_groups_memberships((self.delete_at_teardown[0][0], self.delete_at_teardown[4][0]), (self.delete_at_teardown[2][0], self.delete_at_teardown[5][0]))
self.assertFalse(result)
开发者ID:cannatag,项目名称:ldap3,代码行数:29,代码来源:testCheckGroupMembership.py
示例4: test_find_entry_with_text_index_match
def test_find_entry_with_text_index_match(self):
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'mat-1'))
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'mat-2'))
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'mat-3'))
o = ObjectDef('inetOrgPerson')
o += AttrDef('cn', 'Common Name')
o += AttrDef('sn', 'Surname')
o += AttrDef(test_multivalued_attribute, 'Given Name')
query_text = 'Common Name:=' + testcase_id + 'mat-*'
r = Reader(self.connection, o, test_base, query_text)
results = r.search()
self.assertEqual(len(results), 3)
try: # multiple matches
e = r['match']
except KeyError:
pass
e = r['-2'] # exact match
self.assertTrue('mat-2' in e.entry_dn)
try:
e = r['no-match'] # no match
except KeyError:
pass
开发者ID:cannatag,项目名称:ldap3,代码行数:26,代码来源:testAbstractionSearch.py
示例5: setUp
def setUp(self):
global testcase_id
testcase_id = random_id()
self.connection = get_connection()
self.delete_at_teardown = []
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'controls-1', attributes={'givenName': 'given name-1'}))
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'controls-2', attributes={'givenName': 'given name-2'}))
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'controls-3', attributes={'givenName': 'given name-3'}))
开发者ID:cannatag,项目名称:ldap3,代码行数:8,代码来源:testControls.py
示例6: test_paged_search_accumulator_with_schema
def test_paged_search_accumulator_with_schema(self):
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'mat-1'))
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'mat-2'))
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'mat-3'))
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'mat-4'))
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'mat-5'))
r = Reader(self.connection, 'inetorgperson', test_base, 'cn:=' + testcase_id + 'mat-*')
entries = r.search_paged(2, True, generator=False, attributes=['cn'])
self.assertEqual(len(entries), 5)
开发者ID:cannatag,项目名称:ldap3,代码行数:9,代码来源:testAbstractionSearch.py
示例7: test_match_in_single_attribute_with_schema
def test_match_in_single_attribute_with_schema(self):
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'mat-1', attributes={test_singlevalued_attribute: 'FALSE'}))
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'mat-2', attributes={test_singlevalued_attribute: 'FALSE'}))
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'mat-3', attributes={test_singlevalued_attribute: 'TRUE'}))
r = Reader(self.connection, 'inetorgperson', test_base, 'cn:=' + testcase_id + 'mat-*')
results = r.search()
self.assertEqual(len(results), 3)
e = r.match(test_singlevalued_attribute, 'FALSE')
self.assertEqual(len(e), 2)
e = r.match(test_singlevalued_attribute, 'fAlSe')
self.assertEqual(len(e), 2)
开发者ID:cannatag,项目名称:ldap3,代码行数:13,代码来源:testAbstractionSearch.py
示例8: test_modify_operation_from_bytearray_unicode_literal
def test_modify_operation_from_bytearray_unicode_literal(self):
single = make_bytearray(u'\u00e0\u00e8\u00ec\u00f2\u00f9', 'utf-8')
multi = [make_bytearray(u'\u00e0\u00e8\u00ec', 'utf-8'), make_bytearray(u'\u00f2\u00f9', 'utf-8')]
single_mod = make_bytearray(u'\u00f9\u00f2\u00ec\u00e8\u00e0', 'utf-8')
multi_mod = [make_bytearray(u'\u00ec\u00e8\u00e0', 'utf-8'), make_bytearray('\u00f9\u00f2', 'utf-8')]
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'byt-18', attributes={test_singlevalued_attribute: single, test_multivalued_attribute: multi}, test_bytes=True))
self.assertEqual('success', self.delete_at_teardown[0][1]['description'])
result = self.connection.search(self.delete_at_teardown[0][0], '(objectclass=*)', BASE, attributes=[test_singlevalued_attribute, test_multivalued_attribute])
if not self.connection.strategy.sync:
response, result = self.connection.get_response(result)
else:
response = self.connection.response
self.assertEqual(len(response), 1)
self.assertEqual(response[0]['raw_attributes'][test_singlevalued_attribute], [single])
self.assertEqual(sorted(response[0]['raw_attributes'][test_multivalued_attribute]), sorted(multi))
self.connection.modify(self.delete_at_teardown[0][0], {test_singlevalued_attribute: (MODIFY_REPLACE, single_mod), test_multivalued_attribute: (MODIFY_ADD, multi_mod)})
if not self.connection.strategy.sync:
sleep(2)
result = self.connection.search(self.delete_at_teardown[0][0], '(objectclass=*)', BASE, attributes=[test_singlevalued_attribute, test_multivalued_attribute])
if not self.connection.strategy.sync:
response, result = self.connection.get_response(result)
else:
response = self.connection.response
self.assertEqual(response[0]['raw_attributes'][test_singlevalued_attribute], [single_mod])
self.assertEqual(sorted(response[0]['raw_attributes'][test_multivalued_attribute]), sorted(multi + multi_mod))
开发者ID:cannatag,项目名称:ldap3,代码行数:25,代码来源:testBytesOperation.py
示例9: test_search_object
def test_search_object(self):
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'abstract-1'))
o = ObjectDef(['inetorgPerson', 'person'], self.connection)
r = Reader(self.connection, o, test_base, '(cn=' + testcase_id + 'abstract-1)')
r.search(attributes='cn') # AD returns operationError for reading some atributes
self.assertEqual(len(r), 1)
self.assertEqual(r.entries[0].cn, testcase_id + 'abstract-1')
开发者ID:cannatag,项目名称:ldap3,代码行数:7,代码来源:testAbstractionDefsFromSchema.py
示例10: test_search_filter_with_object_class
def test_search_filter_with_object_class(self):
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'abs-1'))
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'abs-2'))
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'abs-3'))
self.delete_at_teardown.append(add_group(self.connection, testcase_id, 'abs-grp', self.delete_at_teardown))
reverse = lambda a, e: e[::-1]
o = ObjectDef('inetOrgPerson')
o += AttrDef('cn', 'Common Name')
o += AttrDef('sn', 'Surname')
o += AttrDef(test_multivalued_attribute, 'Given Name', post_query=reverse)
query_text = 'Common Name:=' + testcase_id + 'abs-*'
r = Reader(self.connection, o, test_base, query_text)
results = r.search()
self.assertEqual(len(results), 3)
开发者ID:cannatag,项目名称:ldap3,代码行数:16,代码来源:testAbstractionSearch.py
示例11: test_modify_operation_from_bytearray_unicode_name
def test_modify_operation_from_bytearray_unicode_name(self):
if str is not bytes: # works only in python 3
single = make_bytearray(u'\N{LATIN SMALL LETTER A WITH GRAVE}\N{LATIN SMALL LETTER E WITH GRAVE}\N{LATIN SMALL LETTER I WITH GRAVE}\N{LATIN SMALL LETTER O WITH GRAVE}\N{LATIN SMALL LETTER U WITH GRAVE}', 'utf-8')
multi = [make_bytearray(u'\N{LATIN SMALL LETTER A WITH GRAVE}\N{LATIN SMALL LETTER E WITH GRAVE}\N{LATIN SMALL LETTER I WITH GRAVE}', 'utf-8'), make_bytearray('\N{LATIN SMALL LETTER O WITH GRAVE}\N{LATIN SMALL LETTER U WITH GRAVE}', 'utf-8')]
single_mod = make_bytearray('\N{LATIN SMALL LETTER U WITH GRAVE}\N{LATIN SMALL LETTER O WITH GRAVE}\N{LATIN SMALL LETTER I WITH GRAVE}\N{LATIN SMALL LETTER E WITH GRAVE}\N{LATIN SMALL LETTER A WITH GRAVE}', 'utf-8')
multi_mod = [make_bytearray('\N{LATIN SMALL LETTER I WITH GRAVE}\N{LATIN SMALL LETTER E WITH GRAVE}\N{LATIN SMALL LETTER A WITH GRAVE}', 'utf-8'), make_bytearray('\N{LATIN SMALL LETTER U WITH GRAVE}\N{LATIN SMALL LETTER O WITH GRAVE}', 'utf-8')]
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'byt-19', attributes={test_singlevalued_attribute: single, test_multivalued_attribute: multi}, test_bytes=True))
self.assertEqual('success', self.delete_at_teardown[0][1]['description'])
result = self.connection.search(self.delete_at_teardown[0][0], '(objectclass=*)', BASE, attributes=[test_singlevalued_attribute, test_multivalued_attribute])
if not self.connection.strategy.sync:
response, result = self.connection.get_response(result)
else:
response = self.connection.response
self.assertEqual(len(response), 1)
self.assertEqual(response[0]['raw_attributes'][test_singlevalued_attribute], [single])
self.assertEqual(sorted(response[0]['raw_attributes'][test_multivalued_attribute]), sorted(multi))
self.connection.modify(self.delete_at_teardown[0][0], {test_singlevalued_attribute: (MODIFY_REPLACE, single_mod), test_multivalued_attribute: (MODIFY_ADD, multi_mod)})
if not self.connection.strategy.sync:
sleep(2)
result = self.connection.search(self.delete_at_teardown[0][0], '(objectclass=*)', BASE, attributes=[test_singlevalued_attribute, test_multivalued_attribute])
if not self.connection.strategy.sync:
response, result = self.connection.get_response(result)
else:
response = self.connection.response
self.assertEqual(response[0]['raw_attributes'][test_singlevalued_attribute], [single_mod])
self.assertEqual(sorted(response[0]['raw_attributes'][test_multivalued_attribute]), sorted(multi + multi_mod))
开发者ID:cannatag,项目名称:ldap3,代码行数:26,代码来源:testBytesOperation.py
示例12: test_modify_operation_from_bytes_literal
def test_modify_operation_from_bytes_literal(self):
single = b'abc'
multi = [b'abc', b'def']
single_mod = b'cba'
multi_mod = [b'cba', b'fed']
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'byt-12', attributes={test_singlevalued_attribute: single, test_multivalued_attribute: multi}, test_bytes=True))
self.assertEqual('success', self.delete_at_teardown[0][1]['description'])
result = self.connection.search(self.delete_at_teardown[0][0], '(objectclass=*)', BASE, attributes=[test_singlevalued_attribute, test_multivalued_attribute])
if not self.connection.strategy.sync:
response, result = self.connection.get_response(result)
else:
response = self.connection.response
self.assertEqual(len(response), 1)
self.assertEqual(response[0]['raw_attributes'][test_singlevalued_attribute], [single])
self.assertEqual(sorted(response[0]['raw_attributes'][test_multivalued_attribute]), sorted(multi))
self.connection.modify(self.delete_at_teardown[0][0], {test_singlevalued_attribute: (MODIFY_REPLACE, single_mod), test_multivalued_attribute: (MODIFY_ADD, multi_mod)})
if not self.connection.strategy.sync:
sleep(2)
result = self.connection.search(self.delete_at_teardown[0][0], '(objectclass=*)', BASE, attributes=[test_singlevalued_attribute, test_multivalued_attribute])
if not self.connection.strategy.sync:
response, result = self.connection.get_response(result)
else:
response = self.connection.response
self.assertEqual(response[0]['raw_attributes'][test_singlevalued_attribute], [single_mod])
self.assertEqual(sorted(response[0]['raw_attributes'][test_multivalued_attribute]), sorted(multi + multi_mod))
开发者ID:cannatag,项目名称:ldap3,代码行数:25,代码来源:testBytesOperation.py
示例13: test_modify_operation_from_byte_values
def test_modify_operation_from_byte_values(self):
if str is not bytes: # integer list to bytes works only in Python 3
single = make_bytes([195, 160, 195, 168, 195, 172, 195, 178, 195, 185])
multi = [make_bytes([195, 160, 195, 168, 195, 172]), make_bytes([195, 178, 195, 185])]
single_mod = make_bytes([195, 185, 195, 178, 195, 172, 195, 168, 195, 160])
multi_mod = [make_bytes([195, 172, 195, 168, 195, 160]), make_bytes([195, 185, 195, 178])]
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'byt-13', attributes={test_singlevalued_attribute: single, test_multivalued_attribute: multi}, test_bytes=True))
self.assertEqual('success', self.delete_at_teardown[0][1]['description'])
result = self.connection.search(self.delete_at_teardown[0][0], '(objectclass=*)', BASE, attributes=[test_singlevalued_attribute, test_multivalued_attribute])
if not self.connection.strategy.sync:
response, result = self.connection.get_response(result)
else:
response = self.connection.response
self.assertEqual(len(response), 1)
self.assertEqual(response[0]['raw_attributes'][test_singlevalued_attribute], [single])
self.assertEqual(sorted(response[0]['raw_attributes'][test_multivalued_attribute]), sorted(multi))
self.connection.modify(self.delete_at_teardown[0][0], {test_singlevalued_attribute: (MODIFY_REPLACE, single_mod), test_multivalued_attribute: (MODIFY_ADD, multi_mod)})
if not self.connection.strategy.sync:
sleep(2)
result = self.connection.search(self.delete_at_teardown[0][0], '(objectclass=*)', BASE, attributes=[test_singlevalued_attribute, test_multivalued_attribute])
if not self.connection.strategy.sync:
response, result = self.connection.get_response(result)
else:
response = self.connection.response
self.assertEqual(response[0]['raw_attributes'][test_singlevalued_attribute], [single_mod])
self.assertEqual(sorted(response[0]['raw_attributes'][test_multivalued_attribute]), sorted(multi + multi_mod))
开发者ID:cannatag,项目名称:ldap3,代码行数:26,代码来源:testBytesOperation.py
示例14: test_search_string_guid
def test_search_string_guid(self):
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'sea-16', attributes={'givenName': testcase_id + 'givenname-16'}))
if test_server_type == 'EDIR':
result = self.connection.search(search_base=test_base, search_filter='(givenname=' + testcase_id + 'givenname-16)', attributes=[test_name_attr, 'sn', 'guid'])
elif test_server_type == 'AD': # not tested on AD yet
result = self.connection.search(search_base=test_base, search_filter='(givenname=' + testcase_id + 'givenname-16)', attributes=[test_name_attr, 'sn', 'objectGuid'])
else: # not tested on other kind of servers
return
if not self.connection.strategy.sync:
response, result = self.connection.get_response(result)
else:
response = self.connection.response
result = self.connection.result
self.assertEqual(result['description'], 'success')
self.assertEqual(len(response), 1)
if test_server_type == 'EDIR':
result = self.connection.search(search_base=test_base, search_filter='(guid=' + response[0]['attributes']['guid'] + ')', attributes=[test_name_attr, 'sn'])
elif test_server_type == 'AD': # not tested on AD yet
result = self.connection.search(search_base=test_base, search_filter='(objectguid=' + response[0]['attributes']['objectguid'] + ')', attributes=[test_name_attr, 'sn'])
if not self.connection.strategy.sync:
response, result = self.connection.get_response(result)
else:
response = self.connection.response
result = self.connection.result
self.assertEqual(result['description'], 'success')
self.assertEqual(len(response), 1)
if test_server_type == 'EDIR':
self.assertEqual(response[0]['attributes'][test_name_attr][0], testcase_id + 'sea-16')
elif test_server_type == 'AD':
self.assertEqual(response[0]['attributes'][test_name_attr], testcase_id + 'sea-16')
开发者ID:cannatag,项目名称:ldap3,代码行数:30,代码来源:testSearchOperation.py
示例15: test_remove_member_from_group_transactional
def test_remove_member_from_group_transactional(self):
if test_server_type == 'EDIR' and not self.connection.strategy.pooled and not self.connection.strategy.no_real_dsa:
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'user-5'))
self.delete_at_teardown.append(add_group(self.connection, testcase_id, 'group-5', self.delete_at_teardown))
self.connection.extend.novell.add_members_to_groups(self.delete_at_teardown[0][0],
self.delete_at_teardown[1][0],
fix=True,
transaction=True)
result = self.connection.search(self.delete_at_teardown[0][0], '(objectclass=*)', attributes=['securityEquals', 'groupMembership'])
if not self.connection.strategy.sync:
response, result = self.connection.get_response(result)
else:
response, result = self.connection.response, self.connection.result
if response:
self.assertTrue(self.delete_at_teardown[1][0] in (response[0]['attributes']['securityEquals'] if 'securityEquals' in response[0]['attributes'] else []))
self.assertTrue(self.delete_at_teardown[1][0] in (response[0]['attributes']['groupMembership'] if 'groupMembership' in response[0]['attributes'] else []))
else:
self.assertFalse(True, self.delete_at_teardown[1][0] + ' not found')
result = self.connection.search(self.delete_at_teardown[1][0], '(objectclass=*)', attributes=['member', 'equivalentToMe'])
if not self.connection.strategy.sync:
response, result = self.connection.get_response(result)
else:
response, result = self.connection.response, self.connection.result
if response:
self.assertTrue(self.delete_at_teardown[0][0] in (response[0]['attributes']['member'] if 'member' in response[0]['attributes'] else []))
self.assertTrue(self.delete_at_teardown[0][0] in (response[0]['attributes']['equivalentToMe'] if 'equivalentToMe' in response[0]['attributes'] else []))
else:
self.assertFalse(True, self.delete_at_teardown[0][0] + ' not found')
self.connection.extend.novell.remove_members_from_groups(self.delete_at_teardown[0][0],
self.delete_at_teardown[1][0],
fix=False,
transaction=False)
result = self.connection.search(self.delete_at_teardown[0][0], '(objectclass=*)', attributes=['securityEquals', 'groupMembership'])
if not self.connection.strategy.sync:
response, result = self.connection.get_response(result)
else:
response, result = self.connection.response, self.connection.result
if response:
self.assertTrue(self.delete_at_teardown[1][0] not in (response[0]['attributes']['securityEquals'] if 'securityEquals' in response[0]['attributes'] else []))
self.assertTrue(self.delete_at_teardown[1][0] not in (response[0]['attributes']['groupMembership'] if 'groupMembership' in response[0]['attributes'] else []))
else:
self.assertFalse(True, self.delete_at_teardown[1][0] + ' not found')
result = self.connection.search(self.delete_at_teardown[1][0], '(objectclass=*)', attributes=['member', 'equivalentToMe'])
if not self.connection.strategy.sync:
response, result = self.connection.get_response(result)
else:
response, result = self.connection.response, self.connection.result
if response:
self.assertTrue(self.delete_at_teardown[0][0] not in (response[0]['attributes']['member'] if 'member' in response[0]['attributes'] else []))
self.assertTrue(self.delete_at_teardown[0][0] not in (response[0]['attributes']['equivalentToMe'] if 'equivalentToMe' in response[0]['attributes'] else []))
else:
self.assertFalse(True, self.delete_at_teardown[0][0] + ' not found')
开发者ID:cannatag,项目名称:ldap3,代码行数:60,代码来源:testRemoveMembersFromGroups.py
示例16: test_add_binary
def test_add_binary(self):
bin1 = open('512b-rsa-example-cert.der','rb')
bin2 = open('1024b-rsa-example-cert.der','rb')
der_certificates = [bin1.read(), bin2.read()]
bin1.close()
bin2.close()
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'add-operation-4', attributes={'userCertificate;binary': der_certificates}))
self.assertEqual('success', self.delete_at_teardown[0][1]['description'])
开发者ID:cannatag,项目名称:ldap3,代码行数:8,代码来源:testAddOperation.py
示例17: test_paged_search_generator_with_schema_base_object
def test_paged_search_generator_with_schema_base_object(self):
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'mat-1'))
r = Reader(self.connection, 'inetorgperson', self.delete_at_teardown[0][0])
entries = r.search_paged(2, True, generator=True, attributes=['cn'])
cont = 0
for _ in entries:
cont += 1
self.assertEqual(cont, 1)
开发者ID:cannatag,项目名称:ldap3,代码行数:8,代码来源:testAbstractionSearch.py
示例18: test_search_with_pre_query
def test_search_with_pre_query(self):
change = lambda attr, value: testcase_id + 'abs-*'
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'abs-7'))
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'abs-8'))
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'abs-9'))
self.delete_at_teardown.append(add_group(self.connection, testcase_id, 'abstract-group', self.delete_at_teardown))
ou = ObjectDef('inetOrgPerson')
ou += AttrDef('cn', 'Common Name', pre_query=change)
ou += AttrDef('sn', 'Surname')
ou += AttrDef(test_multivalued_attribute, 'Given Name')
ou += AttrDef('ACL')
qu = 'Common Name := bug'
ru = Reader(self.connection, ou, test_base, qu)
lu = ru.search()
self.assertEqual(len(lu), 3)
开发者ID:cannatag,项目名称:ldap3,代码行数:17,代码来源:testAbstractionSearch.py
示例19: test_search_simple_paged
def test_search_simple_paged(self):
if not self.connection.strategy.pooled and not self.connection.strategy.no_real_dsa:
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'sea-5', attributes={'givenName': 'givenname-3'}))
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'sea-6', attributes={'givenName': 'givenname-4'}))
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'sea-7', attributes={'givenName': 'givenname-5'}))
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'sea-8', attributes={'givenName': 'givenname-6'}))
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'sea-9', attributes={'givenName': 'givenname-7'}))
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'sea-10', attributes={'givenName': 'givenname-8'}))
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'sea-11', attributes={'givenName': 'givenname-9'}))
paged_size = 4
total_entries = 0
result = self.connection.search(search_base=test_base, search_filter='(' + test_name_attr + '=' + testcase_id + '*)', search_scope=SUBTREE, attributes=[test_name_attr, 'givenName'], paged_size=paged_size)
if not self.connection.strategy.sync:
response, result = self.connection.get_response(result)
else:
response = self.connection.response
result = self.connection.result
self.assertEqual(result['description'], 'success')
self.assertEqual(len(response), paged_size)
total_entries += len(response)
cookie = result['controls']['1.2.840.113556.1.4.319']['value']['cookie']
while cookie:
result = self.connection.search(search_base=test_base, search_filter='(' + test_name_attr + '=' + testcase_id + '*)', search_scope=SUBTREE, attributes=[test_name_attr, 'givenName'], paged_size=paged_size, paged_cookie=cookie)
if not self.connection.strategy.sync:
response, result = self.connection.get_response(result)
else:
response = self.connection.response
result = self.connection.result
self.assertEqual(result['description'], 'success')
total_entries += len(response)
self.assertTrue(len(response) <= paged_size)
cookie = result['controls']['1.2.840.113556.1.4.319']['value']['cookie']
self.assertEqual(total_entries, 11)
开发者ID:cannatag,项目名称:ldap3,代码行数:34,代码来源:testSearchOperation.py
示例20: test_modify_dn_operation
def test_modify_dn_operation(self):
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'modify-dn-1'))
result = self.connection.modify_dn(self.delete_at_teardown[0][0], test_name_attr + '=' + testcase_id + 'modified-dn-1')
if not self.connection.strategy.sync:
_, result = self.connection.get_response(result)
else:
result = self.connection.result
self.delete_at_teardown[0] = (self.delete_at_teardown[0][0].replace('modify-dn-1', 'modified-dn-1'), self.delete_at_teardown[0][1])
self.assertEqual(result['description'], 'success')
开发者ID:cannatag,项目名称:ldap3,代码行数:9,代码来源:testModifyDNOperation.py
注:本文中的test.config.add_user函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论