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
Reviewed-By: Martin Basti <mbasti@redhat.com>
This commit is contained in:
Lenka Doudova 2016-05-02 14:04:24 +02:00 committed by Martin Basti
parent 8a2afcafee
commit 847c950408
2 changed files with 17 additions and 1 deletions

View File

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

View File

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