On 10/27/2015 08:28 PM, Martin Basti wrote:


On 27.10.2015 14:46, Martin Basti wrote:


On 27.10.2015 13:00, Abhijeet Kasurde wrote:
Hi All,

This patch fixes bug - https://fedorahosted.org/freeipa/ticket/4811

Thanks,
Abhijeet Kasurde


[Tue Oct 27 14:44:51.328615 2015] [wsgi:error] [pid 5556] ipa: ERROR: non-public: AttributeError: 'dnszone' object has no attribute 'handle_obj_found' [Tue Oct 27 14:44:51.328654 2015] [wsgi:error] [pid 5556] Traceback (most recent call last): [Tue Oct 27 14:44:51.328659 2015] [wsgi:error] [pid 5556] File "/usr/lib/python2.7/site-packages/ipaserver/rpcserver.py", line 350, in wsgi_execute [Tue Oct 27 14:44:51.328664 2015] [wsgi:error] [pid 5556] result = self.Command[name](*args, **options) [Tue Oct 27 14:44:51.328669 2015] [wsgi:error] [pid 5556] File "/usr/lib/python2.7/site-packages/ipalib/frontend.py", line 447, in __call__ [Tue Oct 27 14:44:51.328674 2015] [wsgi:error] [pid 5556] ret = self.run(*args, **options) [Tue Oct 27 14:44:51.328678 2015] [wsgi:error] [pid 5556] File "/usr/lib/python2.7/site-packages/ipalib/frontend.py", line 764, in run [Tue Oct 27 14:44:51.328683 2015] [wsgi:error] [pid 5556] return self.execute(*args, **options) [Tue Oct 27 14:44:51.328687 2015] [wsgi:error] [pid 5556] File "/usr/lib/python2.7/site-packages/ipalib/plugins/dns.py", line 2935, in execute [Tue Oct 27 14:44:51.328692 2015] [wsgi:error] [pid 5556] result = super(dnszone_enable, self).execute(*keys, **options) [Tue Oct 27 14:44:51.328696 2015] [wsgi:error] [pid 5556] File "/usr/lib/python2.7/site-packages/ipalib/plugins/dns.py", line 2262, in execute [Tue Oct 27 14:44:51.328701 2015] [wsgi:error] [pid 5556] self.obj.handle_obj_found(*keys) [Tue Oct 27 14:44:51.328705 2015] [wsgi:error] [pid 5556] AttributeError: 'dnszone' object has no attribute 'handle_obj_found'



Thank you, ACK patch works as expected

However now 2 tests are failing because error message was changed, please fix tests too.

test_xmlrpc/test_dns_plugin.py <- test_xmlrpc/xmlrpc_test.py::test_forward_zones::test_command[0071: dnsforwardzone_disable: Try to disable non-existent forward zone] FAILED test_xmlrpc/test_dns_plugin.py <- test_xmlrpc/xmlrpc_test.py::test_forward_zones::test_command[0075: dnsforwardzone_enable: Try to enable non-existent forward zone] FAILED

E           AssertionError: assert_deepequal: expected != got.
E
E             expected = u'no such entry'
E got = u'non-existent.fwzone.test.: DNS forward zone not found'
E             path = ()

Updated patch with testcase
Martin

From f0123341f029622336c7ce3afecfab7035c92fd0 Mon Sep 17 00:00:00 2001
From: Abhijeet Kasurde <akasu...@redhat.com>
Date: Tue, 27 Oct 2015 17:21:17 +0530
Subject: [PATCH] Added user friendly error message for dnszone enable and
 disable

Added try-except block in dns plugin in order to provide user
friendly message to end user.

https://fedorahosted.org/freeipa/ticket/4811

Signed-off-by: Abhijeet Kasurde <akasu...@redhat.com>
---
 ipalib/plugins/dns.py                   | 12 ++++++++++--
 ipatests/test_xmlrpc/test_dns_plugin.py |  8 ++++++--
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/ipalib/plugins/dns.py b/ipalib/plugins/dns.py
index ef282c94609df0be0aa02ec14eb2b137e7ad9dbd..48d6f740ebea06e0ae9e8d68deafd607b5ae18d8 100644
--- a/ipalib/plugins/dns.py
+++ b/ipalib/plugins/dns.py
@@ -2231,7 +2231,11 @@ class DNSZoneBase_disable(LDAPQuery):
         ldap = self.obj.backend
 
         dn = self.obj.get_dn(*keys, **options)
-        entry = ldap.get_entry(dn, ['idnszoneactive', 'objectclass'])
+        try:
+            entry = ldap.get_entry(dn, ['idnszoneactive', 'objectclass'])
+        except errors.NotFound:
+            self.obj.handle_not_found(*keys)
+
         if not _check_entry_objectclass(entry, self.obj.object_class):
             self.obj.handle_not_found(*keys)
 
@@ -2252,7 +2256,11 @@ class DNSZoneBase_enable(LDAPQuery):
         ldap = self.obj.backend
 
         dn = self.obj.get_dn(*keys, **options)
-        entry = ldap.get_entry(dn, ['idnszoneactive', 'objectclass'])
+        try:
+            entry = ldap.get_entry(dn, ['idnszoneactive', 'objectclass'])
+        except errors.NotFound:
+            self.obj.handle_not_found(*keys)
+
         if not _check_entry_objectclass(entry, self.obj.object_class):
             self.obj.handle_not_found(*keys)
 
diff --git a/ipatests/test_xmlrpc/test_dns_plugin.py b/ipatests/test_xmlrpc/test_dns_plugin.py
index f0b8edaa14bdc05e103d2fd332033b97b64169b1..e5d1374d0e9f71fbdc907153a2fec05d6cb6fa3b 100644
--- a/ipatests/test_xmlrpc/test_dns_plugin.py
+++ b/ipatests/test_xmlrpc/test_dns_plugin.py
@@ -4319,7 +4319,9 @@ class test_forward_zones(Declarative):
         dict(
             desc='Try to disable non-existent forward zone',
             command=('dnsforwardzone_disable', [nonexistent_fwzone], {}),
-            expected=errors.NotFound(reason="no such entry")
+            expected=errors.NotFound(
+                reason=u'%s: DNS forward zone not found' % nonexistent_fwzone
+                )
         ),
 
 
@@ -4364,7 +4366,9 @@ class test_forward_zones(Declarative):
         dict(
             desc='Try to enable non-existent forward zone',
             command=('dnsforwardzone_enable', [nonexistent_fwzone], {}),
-            expected=errors.NotFound(reason="no such entry")
+            expected=errors.NotFound(
+                reason=u'%s: DNS forward zone not found' % nonexistent_fwzone
+                )
         ),
 
     ]
-- 
2.4.3

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to