diff options
author | Milan KubĂk <mkubik@redhat.com> | 2016-07-22 17:16:25 +0200 |
---|---|---|
committer | Martin Basti <mbasti@redhat.com> | 2016-07-29 09:04:42 +0200 |
commit | dde1240f5d71f3a8c50226a720af6f1000a35be1 (patch) | |
tree | 1f40f708e76f846563ef259654a5c6fb280ddad4 /ipatests/util.py | |
parent | 5582d1df3213a0727e313d543ee560a09d0cdff8 (diff) | |
download | freeipa-dde1240f5d71f3a8c50226a720af6f1000a35be1.tar.gz freeipa-dde1240f5d71f3a8c50226a720af6f1000a35be1.tar.xz freeipa-dde1240f5d71f3a8c50226a720af6f1000a35be1.zip |
ipatests: Extend the MockLDAP utility class
Added mod_entry method to allow modifying existing entries via the
ldap connection.
The commit also implements the context manager protocol for the class.
https://fedorahosted.org/freeipa/ticket/6142
Reviewed-By: Martin Babinsky <mbabinsk@redhat.com>
Diffstat (limited to 'ipatests/util.py')
-rw-r--r-- | ipatests/util.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/ipatests/util.py b/ipatests/util.py index 796f87cbb..27b939e25 100644 --- a/ipatests/util.py +++ b/ipatests/util.py @@ -652,6 +652,9 @@ class MockLDAP(object): except ldap.ALREADY_EXISTS: pass + def mod_entry(self, dn, mods): + self.connection.modify_s(dn, mods) + def del_entry(self, dn): try: self.connection.delete_s(dn) @@ -662,6 +665,13 @@ class MockLDAP(object): if self.connection is not None: self.connection.unbind_s() + # contextmanager protocol + def __enter__(self): + return self + + def __exit__(self, exc_type, exc_value, traceback): + self.unbind() + def prepare_config(template, values): with open(template) as f: |