| 1 |
""" |
| 2 |
""" |
| 3 |
|
| 4 |
# Created on 2013.08.05 |
| 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 ldap3 import Tls |
| 29 |
from test.config import test_server_context, random_id, get_connection, drop_connection, \ |
| 30 |
test_server_edir_name, test_server_type |
| 31 |
|
| 32 |
testcase_id = '' |
| 33 |
|
| 34 |
|
| 35 |
class Test(unittest.TestCase): |
| 36 |
def setUp(self): |
| 37 |
global testcase_id |
| 38 |
testcase_id = random_id() |
| 39 |
self.connection = get_connection() |
| 40 |
|
| 41 |
def tearDown(self): |
| 42 |
drop_connection(self.connection) |
| 43 |
self.assertFalse(self.connection.bound) |
| 44 |
|
| 45 |
def test_get_replica_list_extension(self): |
| 46 |
if test_server_type == 'EDIR' and not self.connection.strategy.no_real_dsa: |
| 47 |
result = self.connection.extended('2.16.840.1.113719.1.27.100.19', ('cn=' + test_server_edir_name + ',' + test_server_context)) |
| 48 |
|
| 49 |
if not self.connection.strategy.sync: |
| 50 |
_, result = self.connection.get_response(result) |
| 51 |
else: |
| 52 |
result = self.connection.result |
| 53 |
self.assertEqual(result['description'], 'success') |
| 54 |
|
| 55 |
def test_who_am_i_extension(self): |
| 56 |
if not test_server_type == 'EDIR' and not self.connection.strategy.no_real_dsa: |
| 57 |
result = self.connection.extended('1.3.6.1.4.1.4203.1.11.3') |
| 58 |
if not self.connection.strategy.sync: |
| 59 |
_, result = self.connection.get_response(result) |
| 60 |
else: |
| 61 |
result = self.connection.result |
| 62 |
self.assertEqual(result['description'], 'success') |
| 63 |
|
| 64 |
def test_get_bind_dn_extension(self): |
| 65 |
if test_server_type == 'EDIR' and not self.connection.strategy.no_real_dsa: |
| 66 |
result = self.connection.extended('2.16.840.1.113719.1.27.100.31') |
| 67 |
if not self.connection.strategy.sync: |
| 68 |
_, result = self.connection.get_response(result) |
| 69 |
else: |
| 70 |
result = self.connection.result |
| 71 |
self.assertEqual(result['description'], 'success') |
| 72 |
|
| 73 |
def test_start_tls_extension(self): |
| 74 |
if not self.connection.strategy.no_real_dsa: |
| 75 |
connection = get_connection(use_ssl=False) |
| 76 |
connection.server.tls = Tls() |
| 77 |
result = connection.start_tls() |
| 78 |
self.assertTrue(result) |
| 79 |
connection.unbind() |