mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2024-12-25 08:21:05 -06:00
Added Object.get_dn() method; added corresponding unit tests
This commit is contained in:
parent
22669f1fc2
commit
446037fd60
@ -23,6 +23,7 @@ Backend plugin for LDAP.
|
||||
This wraps the python-ldap bindings.
|
||||
"""
|
||||
|
||||
import ldap as _ldap
|
||||
from ipalib import api
|
||||
from ipalib.backend import Backend
|
||||
|
||||
@ -32,4 +33,6 @@ class ldap(Backend):
|
||||
LDAP backend plugin.
|
||||
"""
|
||||
|
||||
dn = _ldap.dn
|
||||
|
||||
api.register(ldap)
|
||||
|
@ -750,6 +750,7 @@ class Object(plugable.Plugin):
|
||||
'params',
|
||||
'primary_key',
|
||||
'params_minus_pk',
|
||||
'get_dn',
|
||||
))
|
||||
backend = None
|
||||
methods = None
|
||||
@ -790,6 +791,12 @@ class Object(plugable.Plugin):
|
||||
if 'Backend' in self.api and self.backend_name in self.api.Backend:
|
||||
self.backend = self.api.Backend[self.backend_name]
|
||||
|
||||
def get_dn(self, primary_key):
|
||||
"""
|
||||
Construct an LDAP DN from a primary_key.
|
||||
"""
|
||||
raise NotImplementedError('%s.get_dn()' % self.name)
|
||||
|
||||
def __get_attrs(self, name):
|
||||
if name not in self.api:
|
||||
return
|
||||
|
@ -963,6 +963,20 @@ class test_Object(ClassChecker):
|
||||
assert isinstance(b, ldap)
|
||||
assert b.whatever == 'It worked!'
|
||||
|
||||
def test_get_dn(self):
|
||||
"""
|
||||
Test the `ipalib.frontend.Object.get_dn` method.
|
||||
"""
|
||||
assert 'get_dn' in self.cls.__public__ # Public
|
||||
o = self.cls()
|
||||
e = raises(NotImplementedError, o.get_dn, 'primary key')
|
||||
assert str(e) == 'Object.get_dn()'
|
||||
class user(self.cls):
|
||||
pass
|
||||
o = user()
|
||||
e = raises(NotImplementedError, o.get_dn, 'primary key')
|
||||
assert str(e) == 'user.get_dn()'
|
||||
|
||||
|
||||
class test_Attribute(ClassChecker):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user