本文整理汇总了Python中test.config.add_user函数的典型用法代码示例。如果您正苦于以下问题:Python add_user函数的具体用法?Python add_user怎么用?Python add_user使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了add_user函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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'))
示例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)
示例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)
示例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
示例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'}))
示例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)
示例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)
示例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))
示例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')
示例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)
示例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))
示例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))
示例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))
示例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')
示例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')