本文整理汇总了Python中test.add_user函数的典型用法代码示例。如果您正苦于以下问题:Python add_user函数的具体用法?Python add_user怎么用?Python add_user使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了add_user函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: 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:cfelder,项目名称:ldap3,代码行数:29,代码来源:testCheckGroupMembership.py
示例2: setUp
def setUp(self):
self.connection = get_connection(check_names=True, get_info=ALL)
self.delete_at_teardown = []
if test_server_type == 'EDIR':
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'checked-attributes-1', attributes={'loginGraceLimit': 0}))
elif test_server_type == 'AD':
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'checked-attributes-1'))
else:
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'checked-attributes-1'))
开发者ID:TLoebner,项目名称:ldap3-debian,代码行数:9,代码来源:testCheckedAttributes.py
示例3: setUp
def setUp(self):
self.connection = get_connection(use_ssl=True)
self.delete_at_teardown = []
if test_server_type == "AD":
self.delete_at_teardown.append(
add_user(self.connection, testcase_id, "search-1", attributes={"givenName": "givenname-1"})
)
self.delete_at_teardown.append(
add_user(self.connection, testcase_id, "search-2", attributes={"givenName": "givenname-2"})
)
开发者ID:Vampouille,项目名称:ldap3,代码行数:10,代码来源:testMicrosoftAD.py
示例4: test_search_deleted_objects_ad
def test_search_deleted_objects_ad(self):
if test_server_type == "AD":
dn_to_delete, _ = add_user(
self.connection, testcase_id, "to-be-deleted-1", attributes={"givenName": "to-be-deleted-1"}
)
sleep(1)
self.connection.delete(dn_to_delete)
sleep(1)
result = self.connection.search(
search_base=test_root_partition,
search_filter="(&(isDeleted=TRUE)(cn=*" + testcase_id + "*deleted-1*))",
search_scope=SUBTREE,
attributes=[],
controls=[show_deleted_control(criticality=True)],
)
if not self.connection.strategy.sync:
response, result = self.connection.get_response(result)
else:
response = self.connection.response
result = self.connection.result
found = False
for entry in response:
if entry["type"] == "searchResEntry" and testcase_id in entry["dn"]:
found = True
break
self.assertTrue(found)
开发者ID:Vampouille,项目名称:ldap3,代码行数:27,代码来源:testMicrosoftAD.py
示例5: 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("givenName", "Given Name", post_query=reverse)
query_text = "Common Name:=" + testcase_id + "abs-*"
r = Reader(self.connection, o, query_text, test_base)
results = r.search()
self.assertEqual(len(results), 3)
开发者ID:sigmunau,项目名称:ldap3,代码行数:16,代码来源:testAbstractionSearch.py
示例6: test_modify_password_as_administrator
def test_modify_password_as_administrator(self):
if test_server_type == "AD":
self.delete_at_teardown.append(
add_user(
self.connection, testcase_id, "changed-password-1", attributes={"givenName": "changed-password-1"}
)
)
dn = self.delete_at_teardown[-1][0]
# test_connection = get_connection(bind=False, authentication=SIMPLE, simple_credentials=(dn, 'Rc1234abcd'))
# test_connection.bind()
# self.assertTrue(test_connection.bound)
# connected_user = test_connection.extend.standard.who_am_i()
# test_connection.unbind()
# self.assertTrue('changed-password-1' in connected_user)
new_password = "Rc5678efgh"
result = self.connection.extend.microsoft.modify_password(dn, new_password)
self.assertEqual(result, True)
# creates a second connection and tries to bind with the new password
test_connection = get_connection(bind=False, authentication=SIMPLE, simple_credentials=(dn, new_password))
test_connection.bind()
connected_user = test_connection.extend.standard.who_am_i()
test_connection.unbind()
self.assertTrue("changed-password-1" in connected_user)
开发者ID:Vampouille,项目名称:ldap3,代码行数:25,代码来源:testMicrosoftAD.py
示例7: test_modify_password_as_normal_user
def test_modify_password_as_normal_user(self):
if test_server_type == 'AD':
old_password = 'Ab1234cdef'
new_password = 'Gh5678ijkl'
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'changed-password-2', password=old_password, attributes={'givenName': 'changed-password-2'}))
dn = self.delete_at_teardown[-1][0]
# creates a second connection and tries to bind with the new password
test_connection = get_connection(bind=False, authentication=SIMPLE, simple_credentials=(dn, old_password))
test_connection.bind()
self.assertTrue(test_connection.bound)
connected_user = test_connection.extend.standard.who_am_i()
test_connection.unbind()
self.assertTrue('changed-password-2' in connected_user)
# changee the password
result = self.connection.extend.microsoft.modify_password(dn, new_password, old_password)
self.assertEqual(result, True)
# tries to bind with the new password
test_connection.password = new_password
test_connection.bind()
connected_user = test_connection.extend.standard.who_am_i()
test_connection.unbind()
self.assertTrue('changed-password-2' in connected_user)
开发者ID:Fist0urs,项目名称:ldap3,代码行数:25,代码来源:testMicrosoftAD.py
示例8: 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],
check=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],
check=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:Fist0urs,项目名称:ldap3,代码行数:60,代码来源:testRemoveMembersFromGroups.py
示例9: test_search_with_pre_query
def test_search_with_pre_query(self):
change = lambda attr, value: testcase_id + 'abstract-member-*'
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'abstract-member-7'))
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'abstract-member-8'))
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'abstract-member-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('givenName', 'Given Name')
ou += AttrDef('ACL')
qu = 'Common Name := bug'
ru = Reader(self.connection, ou, qu, test_base)
lu = ru.search()
self.assertEqual(len(lu), 3)
开发者ID:Fist0urs,项目名称:ldap3,代码行数:17,代码来源:testAbstractionSearch.py
示例10: 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, 'search-3', attributes={'givenName': 'givenname-3'}))
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'search-4', attributes={'givenName': 'givenname-4'}))
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'search-5', attributes={'givenName': 'givenname-5'}))
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'search-6', attributes={'givenName': 'givenname-6'}))
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'search-7', attributes={'givenName': 'givenname-7'}))
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'search-8', attributes={'givenName': 'givenname-8'}))
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'search-9', 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, 9)
开发者ID:Fist0urs,项目名称:ldap3,代码行数:34,代码来源:testSearchOperation.py
示例11: 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.assertEqual(result['description'], 'success')
self.delete_at_teardown[0] = (self.delete_at_teardown[0][0].replace('modify-dn-1', 'modified-dn-1'), self.delete_at_teardown[0][1])
开发者ID:Vampouille,项目名称:ldap3,代码行数:9,代码来源:testModifyDNOperation.py
示例12: setUp
def setUp(self):
self.connection = get_connection(check_names=True)
self.delete_at_teardown = []
self.delete_at_teardown.append(add_user(self.connection, testcase_id, "paged_search-1"))
self.delete_at_teardown.append(add_user(self.connection, testcase_id, "paged_search-2"))
self.delete_at_teardown.append(add_user(self.connection, testcase_id, "paged_search-3"))
self.delete_at_teardown.append(add_user(self.connection, testcase_id, "paged_search-4"))
self.delete_at_teardown.append(add_user(self.connection, testcase_id, "paged_search-5"))
self.delete_at_teardown.append(add_user(self.connection, testcase_id, "paged_search-6"))
self.delete_at_teardown.append(add_user(self.connection, testcase_id, "paged_search-7"))
self.delete_at_teardown.append(add_user(self.connection, testcase_id, "paged_search-8"))
开发者ID:Vampouille,项目名称:ldap3,代码行数:11,代码来源:testExtendedOperations.py
示例13: test_add_members_to_groups
def test_add_members_to_groups(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-2'))
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'user-3'))
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'user-4'))
self.delete_at_teardown.append(add_group(self.connection, testcase_id, 'group-2', self.delete_at_teardown))
self.delete_at_teardown.append(add_group(self.connection, testcase_id, 'group-3'))
self.delete_at_teardown.append(add_group(self.connection, testcase_id, 'group-4'))
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]],
[self.delete_at_teardown[3][0],
self.delete_at_teardown[4][0],
self.delete_at_teardown[5][0]],
fix=True,
transaction=False
)
for i in range(0, 2):
result = self.connection.search(self.delete_at_teardown[i][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:
for j in range(3, 5):
self.assertTrue(self.delete_at_teardown[j][0] in (response[0]['attributes']['securityEquals'] if 'securityEquals' in response[0]['attributes'] else []))
self.assertTrue(self.delete_at_teardown[j][0] in (response[0]['attributes']['groupMembership'] if 'groupMembership' in response[0]['attributes'] else []))
else:
self.assertFalse(True, self.delete_at_teardown[i][0] + ' not found')
for j in range(3, 5):
result = self.connection.search(self.delete_at_teardown[j][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:
for i in range(0, 2):
self.assertTrue(self.delete_at_teardown[i][0] in (response[0]['attributes']['member'] if 'member' in response[0]['attributes'] else []))
self.assertTrue(self.delete_at_teardown[i][0] in (response[0]['attributes']['equivalentToMe'] if 'equivalentToMe' in response[0]['attributes'] else []))
else:
self.assertFalse(True, self.delete_at_teardown[j][0] + ' not found')
开发者ID:cfelder,项目名称:ldap3,代码行数:44,代码来源:testAddMembersToGroups.py
示例14: test_search_with_None_default
def test_search_with_None_default(self):
self.delete_at_teardown.append(add_user(self.connection, testcase_id, "abstract-member-12"))
ou = ObjectDef("inetOrgPerson")
ou += AttrDef("cn", "CommonName")
ou += AttrDef("employeeType", key="Employee", default=None)
qu = "CommonName := " + testcase_id + "abstract-member-12"
ru = Reader(self.connection, ou, qu, test_base)
lu = ru.search()
self.assertEqual(lu[0].employee.value, None)
开发者ID:sigmunau,项目名称:ldap3,代码行数:10,代码来源:testAbstractionSearch.py
示例15: test_valid_attribute
def test_valid_attribute(self):
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'check-names-2', attributes={'givenName': 'given-name-2'}))
result = self.connection.search(search_base=test_base, search_filter='(' + test_name_attr + '=' + testcase_id + 'check-names-2)', attributes=[test_name_attr, 'givenName'])
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)
开发者ID:TLoebner,项目名称:ldap3-debian,代码行数:10,代码来源:testCheckNames.py
示例16: test_search_with_pre_query
def test_search_with_pre_query(self):
change = lambda attr, value: testcase_id + "abstract-member-*"
self.delete_at_teardown.append(add_user(self.connection, testcase_id, "abstract-member-7"))
self.delete_at_teardown.append(add_user(self.connection, testcase_id, "abstract-member-8"))
self.delete_at_teardown.append(add_user(self.connection, testcase_id, "abstract-member-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("givenName", "Given Name")
ou += AttrDef("ACL")
qu = "Common Name := bug"
ru = Reader(self.connection, ou, qu, test_base)
lu = ru.search()
self.assertEqual(len(lu), 3)
开发者ID:sigmunau,项目名称:ldap3,代码行数:19,代码来源:testAbstractionSearch.py
示例17: test_search_with_dereference
def test_search_with_dereference(self):
reverse = lambda a, e: e[::-1]
def raise_parentheses_rank(_, l):
up = {"(": "[", ")": "]", "[": "{", "]": "}", "{": "<", "}": ">"}
r = []
for e in l:
s = ""
for c in e:
s += up[c] if c in up else c
r.append(s)
return r
self.delete_at_teardown.append(add_user(self.connection, testcase_id, "abstract-member-4"))
self.delete_at_teardown.append(add_user(self.connection, testcase_id, "abstract-member-5"))
self.delete_at_teardown.append(add_user(self.connection, testcase_id, "abstract-member-6"))
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", post_query=reverse)
ou += AttrDef("sn", "Surname")
ou += AttrDef("givenName", "Given Name", post_query=raise_parentheses_rank)
ou += AttrDef("ACL")
qu = "Common Name: " + testcase_id + "abstract-member-*"
ru = Reader(self.connection, ou, qu, test_base)
lu = ru.search()
self.assertEqual(len(lu), 3)
og = ObjectDef("groupOfNames")
og += AttrDef("member", dereference_dn=ou)
og += "cn"
qg = "cn := " + testcase_id + "abstract-group"
rg = Reader(self.connection, og, qg, test_base)
lg = rg.search()
self.assertEqual(len(lg), 1)
eg = lg[0]
mg = eg.member
self.assertEqual(len(mg), 3)
ug = eg.member[0]
self.assertTrue(str(ug.surname) in ["abstract-member-4", "abstract-member-5", "abstract-member-6"])
开发者ID:sigmunau,项目名称:ldap3,代码行数:43,代码来源:testAbstractionSearch.py
示例18: test_search_exact_match_with_parentheses_in_filter
def test_search_exact_match_with_parentheses_in_filter(self):
self.delete_at_teardown.append(add_user(self.connection, testcase_id, '(search)-10', attributes={'givenName': 'givenname-10'}))
result = self.connection.search(search_base=test_base, search_filter='(' + test_name_attr + '=' + testcase_id + '*' + escape_bytes(')') + '*)', 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)
self.assertEqual(response[0]['attributes'][test_name_attr][0], testcase_id + '(search)-10')
开发者ID:TLoebner,项目名称:ldap3-debian,代码行数:11,代码来源:testSearchOperation.py
示例19: test_search_with_dereference
def test_search_with_dereference(self):
reverse = lambda a, e: e[::-1]
def raise_parentheses_rank(_, l):
up = {'(': '[', ')': ']', '[': '{', ']': '}', '{': '<', '}': '>'}
r = []
for e in l:
s = ''
for c in e:
s += up[c] if c in up else c
r.append(s)
return r
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'abstract-member-4'))
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'abstract-member-5'))
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'abstract-member-6'))
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', post_query=reverse)
ou += AttrDef('sn', 'Surname')
ou += AttrDef('givenName', 'Given Name', post_query=raise_parentheses_rank)
ou += AttrDef('ACL')
qu = 'Common Name: ' + testcase_id + 'abstract-member-*'
ru = Reader(self.connection, ou, qu, test_base)
lu = ru.search()
self.assertEqual(len(lu), 3)
og = ObjectDef('groupOfNames')
og += AttrDef('member', dereference_dn=ou)
og += 'cn'
qg = 'cn := ' + testcase_id + 'abstract-group'
rg = Reader(self.connection, og, qg, test_base)
lg = rg.search()
self.assertEqual(len(lg), 1)
eg = lg[0]
mg = eg.member
self.assertEqual(len(mg), 3)
ug = eg.member[0]
self.assertTrue(str(ug.surname) in ['abstract-member-4', 'abstract-member-5', 'abstract-member-6'])
开发者ID:Fist0urs,项目名称:ldap3,代码行数:41,代码来源:testAbstractionSearch.py
示例20: test_search_exact_match_with_parentheses_in_filter
def test_search_exact_match_with_parentheses_in_filter(self):
self.delete_at_teardown.append(add_user(self.connection, testcase_id, '(search)-3', attributes={'givenName': 'givenname-3'}))
result = self.connection.search(search_base=test_base, search_filter='(&(' + test_name_attr + '=' + testcase_id + '*)(' + test_name_attr + '=*' + escape_bytes(')') + '*))', attributes=[test_name_attr, 'sn'])
if not self.connection.strategy.sync:
response, _ = self.connection.get_response(result)
json_response = self.connection.response_to_json(search_result=response)
else:
json_response = self.connection.response_to_json()
json_entries = json.loads(json_response)['entries']
self.assertEqual(len(json_entries), 1)
self.assertEqual(json_entries[0]['attributes'][test_name_attr][0], testcase_id + '(search)-3')
开发者ID:vitan,项目名称:ldap3,代码行数:12,代码来源:testSearchOperationJSON.py
注:本文中的test.add_user函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论