Imported Upstream version 4.3.1

This commit is contained in:
Mario Fetka
2021-08-10 02:37:58 +02:00
parent a791de49a2
commit 2f177da8f2
2056 changed files with 421730 additions and 1668138 deletions

View File

@@ -26,15 +26,14 @@ import ldap
from ipapython.dn import DN
from ipapython import ipaldap
from ipalib import errors
from ipalib.frontend import Command
from ipaserver.plugins import baseldap
from ipalib.plugins import baseldap
from ipatests.util import assert_deepequal
import pytest
@pytest.mark.tier0
def test_exc_wrapper():
"""Test the BaseLDAPCommand._exc_wrapper helper method"""
"""Test the CallbackInterface._exc_wrapper helper method"""
handled_exceptions = []
class test_callback(baseldap.BaseLDAPCommand):
@@ -53,8 +52,7 @@ def test_exc_wrapper():
# Test with one callback first
@test_callback.register_exc_callback
def handle_exception( # pylint: disable=unused-variable
self, keys, options, e, call_func, *args, **kwargs):
def handle_exception(self, keys, options, e, call_func, *args, **kwargs):
assert args == (1, 2)
assert kwargs == dict(a=1, b=2)
handled_exceptions.append(type(e))
@@ -79,8 +77,8 @@ def test_exc_wrapper():
@pytest.mark.tier0
def test_callback_registration():
class callbacktest_base(Command):
callback_types = Command.callback_types + ('test',)
class callbacktest_base(baseldap.CallbackInterface):
_callback_registry = dict(test={})
def test_callback(self, param):
messages.append(('Base test_callback', param))
@@ -151,8 +149,7 @@ def test_exc_callback_registration():
pass
@callbacktest_subclass.register_exc_callback
def exc_callback( # pylint: disable=unused-variable
self, keys, options, exc, call_func, *args, **kwargs):
def exc_callback(self, keys, options, exc, call_func, *args, **kwargs):
"""Subclass's private exception callback"""
messages.append('Subclass registered callback')
raise exc
@@ -165,8 +162,7 @@ def test_exc_callback_registration():
@callbacktest_base.register_exc_callback
def exc_callback_2( # pylint: disable=unused-variable
self, keys, options, exc, call_func, *args, **kwargs):
def exc_callback_2(self, keys, options, exc, call_func, *args, **kwargs):
"""Callback on super class; doesn't affect the subclass"""
messages.append('Superclass registered callback')
raise exc
@@ -187,15 +183,13 @@ def test_entry_to_dict():
class FakeSchema(object):
def get_obj(self, type, name):
if type != ldap.schema.AttributeType:
return None
return
if name == 'binaryattr':
return FakeAttributeType(name, '1.3.6.1.4.1.1466.115.121.1.40')
elif name == 'textattr':
return FakeAttributeType(name, '1.3.6.1.4.1.1466.115.121.1.15')
elif name == 'dnattr':
return FakeAttributeType(name, '1.3.6.1.4.1.1466.115.121.1.12')
else:
return None
class FakeLDAPClient(ipaldap.LDAPClient):
def __init__(self):