| 1 |
""" |
| 2 |
""" |
| 3 |
|
| 4 |
# Created on 2013.07.31 |
| 5 |
# |
| 6 |
# Author: Giovanni Cannata |
| 7 |
# |
| 8 |
# Copyright 2013 - 2020 Giovanni Cannata |
| 9 |
# |
| 10 |
# This file is part of ldap3. |
| 11 |
# |
| 12 |
# ldap3 is free software: you can redistribute it and/or modify |
| 13 |
# it under the terms of the GNU Lesser General Public License as published |
| 14 |
# by the Free Software Foundation, either version 3 of the License, or |
| 15 |
# (at your option) any later version. |
| 16 |
# |
| 17 |
# ldap3 is distributed in the hope that it will be useful, |
| 18 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 |
# GNU Lesser General Public License for more details. |
| 21 |
# |
| 22 |
# You should have received a copy of the GNU Lesser General Public License |
| 23 |
# along with ldap3 in the COPYING and COPYING.LESSER files. |
| 24 |
# If not, see <http://www.gnu.org/licenses/>. |
| 25 |
|
| 26 |
import unittest |
| 27 |
|
| 28 |
from test.config import test_base, random_id, get_connection, drop_connection, add_user, test_server_type, test_name_attr |
| 29 |
|
| 30 |
testcase_id = '' |
| 31 |
|
| 32 |
|
| 33 |
class Test(unittest.TestCase): |
| 34 |
def setUp(self): |
| 35 |
global testcase_id |
| 36 |
testcase_id = random_id() |
| 37 |
self.connection = get_connection() |
| 38 |
self.delete_at_teardown = [] |
| 39 |
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'controls-1', attributes={'givenName': 'given name-1'})) |
| 40 |
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'controls-2', attributes={'givenName': 'given name-2'})) |
| 41 |
self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'controls-3', attributes={'givenName': 'given name-3'})) |
| 42 |
|
| 43 |
def tearDown(self): |
| 44 |
drop_connection(self.connection, self.delete_at_teardown) |
| 45 |
self.assertFalse(self.connection.bound) |
| 46 |
|
| 47 |
def test_search_with_controls(self): |
| 48 |
if test_server_type == 'EDIR': |
| 49 |
controls = list() |
| 50 |
controls.append(('2.16.840.1.113719.1.27.103.7', True, 'sn')) # grouping [Novell] |
| 51 |
result = self.connection.search(test_base, '(' + test_name_attr + '=' + testcase_id + 'controls-*)', attributes=['sn', 'givenName'], controls=controls) |
| 52 |
if not self.connection.strategy.sync: |
| 53 |
_, result = self.connection.get_response(result) |
| 54 |
else: |
| 55 |
result = self.connection.result |
| 56 |
|
| 57 |
self.assertTrue(result['description'] in ['success', 'operationsError']) |