[Freeipa-devel] [PATCH] 0032 Fix error message for nonexistent members and add tests.

Tomas Babej tbabej at redhat.com
Fri Nov 21 15:23:40 UTC 2014


On 11/21/2014 04:11 PM, David Kupka wrote:
> https://fedorahosted.org/freeipa/ticket/4643
>
>
> _______________________________________________
> Freeipa-devel mailing list
> Freeipa-devel at redhat.com
> https://www.redhat.com/mailman/listinfo/freeipa-devel

-                obj.get_dn_if_exists(name)
+                try:
+                    obj.get_dn(name)
+                except errors.NotFound:
+                    obj.handle_not_found(*keys)

You switched from get_dn_if_exists to get_dn, why? The get_dn method
never raises the NotFound error, it just constructs the dn regardless of
the fact whether the actual entry at that dn exists.

You need to use get_dn_if_exists here. Some negative tests for this
would be welcome :).

Indeed, by testing the patch:

[tbabej at vm-218 ~]$ ipa automember_rebuild --users=doesnotexist
--------------------------------------------------------
Automember rebuild task finished. Processed (0) entries.
--------------------------------------------------------

Where the old behaviour was:

[tbabej at vm-218 ~]$ ipa automember_rebuild --users=test
ipa: ERROR: no such entry

-- 
Tomas Babej
Associate Software Engineer | Red Hat | Identity Management
RHCE | Brno Site | IRC: tbabej | freeipa.org 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/freeipa-devel/attachments/20141121/4a9d6ebc/attachment.htm>


More information about the Freeipa-devel mailing list