diff options
author | Jan Cholasta <jcholast@redhat.com> | 2011-11-01 08:58:05 -0400 |
---|---|---|
committer | Alexander Bokovoy <abokovoy@redhat.com> | 2012-01-02 11:51:26 +0300 |
commit | 9beb467d98cb16e09fcda5ebbeb27056dfff3a2d (patch) | |
tree | d374273454f5fa5627eb1fe83782c437cdbddde2 /ipaserver | |
parent | 46d3abc450db20c3e4c0854dbf9e711f59db3bff (diff) | |
download | freeipa-9beb467d98cb16e09fcda5ebbeb27056dfff3a2d.tar.gz freeipa-9beb467d98cb16e09fcda5ebbeb27056dfff3a2d.tar.xz freeipa-9beb467d98cb16e09fcda5ebbeb27056dfff3a2d.zip |
Fix attempted write to attribute of read-only object.
Add new class "cachedproperty" for creating property-like attributes
that cache the return value of a method call.
Also fix few issues in the unit tests to enable them to succeed.
ticket 1959
Diffstat (limited to 'ipaserver')
-rw-r--r-- | ipaserver/install/ldapupdate.py | 4 | ||||
-rw-r--r-- | ipaserver/ipaldap.py | 2 | ||||
-rw-r--r-- | ipaserver/plugins/dogtag.py | 10 | ||||
-rw-r--r-- | ipaserver/plugins/ldap2.py | 2 |
4 files changed, 7 insertions, 11 deletions
diff --git a/ipaserver/install/ldapupdate.py b/ipaserver/install/ldapupdate.py index 91d3d83cf..8fbfeaf55 100644 --- a/ipaserver/install/ldapupdate.py +++ b/ipaserver/install/ldapupdate.py @@ -700,7 +700,7 @@ class LDAPUpdate: self.conn.deleteEntry(dn) self.modified = True except errors.NotFound, e: - root_logger.info("%s did not exist:%s", (dn, e)) + root_logger.info("%s did not exist:%s", dn, e) self.modified = True except errors.DatabaseError, e: root_logger.error("Delete failed: %s", e) @@ -717,7 +717,7 @@ class LDAPUpdate: self.conn.deleteEntry(dn) self.modified = True except errors.NotFound, e: - root_logger.info("%s did not exist:%s", (dn, e)) + root_logger.info("%s did not exist:%s", dn, e) self.modified = True except errors.DatabaseError, e: root_logger.error("Delete failed: %s", e) diff --git a/ipaserver/ipaldap.py b/ipaserver/ipaldap.py index ae36dd239..4dca60464 100644 --- a/ipaserver/ipaldap.py +++ b/ipaserver/ipaldap.py @@ -314,7 +314,7 @@ class IPAdmin(IPAEntryLDAPObject): raise errors.DuplicateEntry() except ldap.CONSTRAINT_VIOLATION, e: # This error gets thrown by the uniqueness plugin - if info == 'Another entry with the same attribute value already exists': + if info.startswith('Another entry with the same attribute value already exists'): raise errors.DuplicateEntry() else: raise errors.DatabaseError(desc=desc,info=info) diff --git a/ipaserver/plugins/dogtag.py b/ipaserver/plugins/dogtag.py index 23d06abc1..b31058c14 100644 --- a/ipaserver/plugins/dogtag.py +++ b/ipaserver/plugins/dogtag.py @@ -1200,6 +1200,7 @@ import os, random, ldap from ipaserver.plugins import rabase from ipalib.errors import NetworkError, CertificateOperationError from ipalib.constants import TYPE_ERROR +from ipalib.util import cachedproperty from ipapython import dogtag from ipalib import _ @@ -1218,7 +1219,6 @@ class ra(rabase.rabase): self.ipa_key_size = "2048" self.ipa_certificate_nickname = "ipaCert" self.ca_certificate_nickname = "caCert" - self.ca_host = None try: f = open(self.pwd_file, "r") self.password = f.readline().strip() @@ -1266,7 +1266,8 @@ class ra(rabase.rabase): pass return None - def _select_ca(self): + @cachedproperty + def ca_host(self): """ :return: host as str @@ -1293,8 +1294,6 @@ class ra(rabase.rabase): Perform an HTTP request. """ - if self.ca_host == None: - self.ca_host = self._select_ca() return dogtag.http_request(self.ca_host, port, url, **kw) def _sslget(self, url, port, **kw): @@ -1306,9 +1305,6 @@ class ra(rabase.rabase): Perform an HTTPS request """ - - if self.ca_host == None: - self.ca_host = self._select_ca() return dogtag.https_request(self.ca_host, port, url, self.sec_dir, self.password, self.ipa_certificate_nickname, **kw) def get_parse_result_xml(self, xml_text, parse_func): diff --git a/ipaserver/plugins/ldap2.py b/ipaserver/plugins/ldap2.py index 4bfc849d8..069803459 100644 --- a/ipaserver/plugins/ldap2.py +++ b/ipaserver/plugins/ldap2.py @@ -210,7 +210,7 @@ def _handle_errors(e, **kw): raise errors.DuplicateEntry() except _ldap.CONSTRAINT_VIOLATION: # This error gets thrown by the uniqueness plugin - if info == 'Another entry with the same attribute value already exists': + if info.startswith('Another entry with the same attribute value already exists'): raise errors.DuplicateEntry() else: raise errors.DatabaseError(desc=desc, info=info) |