idviews: correctly handle modification of non-existent view

the pre-callback in `idview-mod` did not correctly handle non-existent
object during objectclass check. It will now correctly report that the
object was not found instead on generic 'no such entry'.

https://pagure.io/freeipa/issue/6372

Reviewed-By: Martin Basti <mbasti@redhat.com>
This commit is contained in:
Martin Babinsky
2017-03-15 08:18:39 +01:00
committed by Martin Basti
parent 7ef4e9eb81
commit 1cdd5dee00

View File

@@ -145,8 +145,11 @@ class idview(LDAPObject):
},
}
def ensure_possible_objectclasses(self, ldap, dn, entry_attrs):
orig_entry_attrs = ldap.get_entry(dn, ['objectclass'])
def ensure_possible_objectclasses(self, ldap, dn, entry_attrs, *keys):
try:
orig_entry_attrs = ldap.get_entry(dn, ['objectclass'])
except errors.NotFound:
self.handle_not_found(*keys)
orig_objectclasses = {
o.lower() for o in orig_entry_attrs.get('objectclass', [])}
@@ -193,7 +196,7 @@ class idview_mod(LDAPUpdate):
raise protected_default_trust_view_error
self.api.Object.config.validate_domain_resolution_order(entry_attrs)
self.obj.ensure_possible_objectclasses(ldap, dn, entry_attrs)
self.obj.ensure_possible_objectclasses(ldap, dn, entry_attrs, *keys)
return dn