On 05/03/2016 02:08 PM, Lenka Doudova wrote:


On 05/03/2016 12:15 PM, Martin Basti wrote:


On 03.05.2016 11:18, Lenka Doudova wrote:


On 05/03/2016 10:33 AM, Martin Basti wrote:
Hello I'm quite confused what is happening in that code, can you explain it more to me? I see duplicated code there.
Sorry, that was just an unnecessary leftover. Fixed patch attached.
The code is expected to remove any certificates that were added to the local host but not to try to remove the host itself.

Lenka


Martin^2

Looks better, please follow proper naming of patches according how to format patch guide. I propose following (Patch attached) changes. It looks weird to me to return self object

Martin

Ok, fixed patch attached.

Thanks,
Lenka


And one more small change.
Lenka
From 74f4d4782e2c4d468d2ac563c8cbd9e8e2b8ef91 Mon Sep 17 00:00:00 2001
From: Lenka Doudova <ldoud...@redhat.com>
Date: Mon, 2 May 2016 14:04:24 +0200
Subject: [PATCH] Test fix: Cleanup for host certificate

This fix provides means to remove certificates from host that were added during tests, but not removed.

Ticket: https://fedorahosted.org/freeipa/ticket/5839
---
 ipatests/test_xmlrpc/test_host_plugin.py    |  4 +++-
 ipatests/test_xmlrpc/tracker/host_plugin.py | 14 ++++++++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/ipatests/test_xmlrpc/test_host_plugin.py b/ipatests/test_xmlrpc/test_host_plugin.py
index ea8f49656b47b91950130f78375f1c4447157ecb..4d54dac4fec43e342ee3a8a732ad7527d84acc5a 100644
--- a/ipatests/test_xmlrpc/test_host_plugin.py
+++ b/ipatests/test_xmlrpc/test_host_plugin.py
@@ -130,8 +130,10 @@ def this_host(request):
     """Fixture for the current master"""
     tracker = HostTracker(name=api.env.host.partition('.')[0],
                           fqdn=api.env.host)
-    # This host is not created/deleted, so don't call make_fixture
     tracker.exists = True
+    # Finalizer ensures that any certificates added to this_host are removed
+    tracker.add_finalizer_certcleanup(request)
+    # This host is not created/deleted, so don't call make_fixture
     return tracker
 
 
diff --git a/ipatests/test_xmlrpc/tracker/host_plugin.py b/ipatests/test_xmlrpc/tracker/host_plugin.py
index 67faa1acf9eeb6174e8d09ca012ae20636fb0f51..d8b59b98907dff955f415b6edb0ce34d74e54f19 100644
--- a/ipatests/test_xmlrpc/tracker/host_plugin.py
+++ b/ipatests/test_xmlrpc/tracker/host_plugin.py
@@ -10,6 +10,7 @@ from ipatests.test_xmlrpc.tracker.base import Tracker
 from ipatests.test_xmlrpc.xmlrpc_test import fuzzy_uuid
 from ipatests.test_xmlrpc import objectclasses
 from ipatests.util import assert_deepequal
+from ipalib import errors
 
 
 class HostTracker(Tracker):
@@ -155,3 +156,16 @@ class HostTracker(Tracker):
             summary=u'Modified host "%s"' % self.fqdn,
             result=self.filter_attrs(self.update_keys | set(extra_keys))
         ), result)
+
+    def add_finalizer_certcleanup(self, request):
+        """ Fixture to cleanup certificate from local host """
+        cleanup_command = self.make_update_command(
+            updates={'usercertificate':''})
+
+        def cleanup():
+            try:
+                cleanup_command()
+            except errors.EmptyModlist:
+                pass
+
+        request.addfinalizer(cleanup)
-- 
2.5.5

-- 
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