Added a check while removing 'cert_dir'. The teardown method is called even if all the tests are skipped since the required PKI version is not present. The teardown is trying to remove a non-existent directory.

Currently the cert_dir attribute is only present if IPA installation was
done. If IPA was not installed the attribute does not exist.
In order that the uninstall code finds the attribute a class attribute
is added.

Pagure Issue: https://pagure.io/freeipa/issue/9179

Signed-off-by: Sumedh Sidhaye <ssidhaye@redhat.com>
Reviewed-By: Florence Blanc-Renaud <flo@redhat.com>
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
This commit is contained in:
Sumedh Sidhaye 2022-06-13 13:49:08 +05:30 committed by Florence Blanc-Renaud
parent 22d1392a8a
commit 2e11247cde
2 changed files with 17 additions and 1 deletions

View File

@ -122,6 +122,15 @@ def replica_install_teardown(func):
class CALessBase(IntegrationTest):
# The teardown method is called even if all the tests are skipped
# since the required PKI version is not present.
# The teardown is trying to remove a non-existent directory.
# Currently the cert_dir attribute is only present if IPA installation was
# done. If IPA was not installed the attribute does not exist.
# In order that the uninstall code finds the attribute a class attribute
# is added.
cert_dir = None
@classmethod
def install(cls, mh):
cls.cert_dir = tempfile.mkdtemp(prefix="ipatest-")
@ -164,7 +173,8 @@ class CALessBase(IntegrationTest):
@classmethod
def uninstall(cls, mh):
# Remove the NSS database
shutil.rmtree(cls.cert_dir)
if cls.cert_dir:
shutil.rmtree(cls.cert_dir)
super(CALessBase, cls).uninstall(mh)
@classmethod

View File

@ -64,3 +64,9 @@ class TestServerCALessToExternalCA_RSN(TestServerCALessToExternalCA):
if not pki_supports_RSNv3(mh.master):
raise pytest.skip("RNSv3 not supported")
super(TestServerCALessToExternalCA_RSN, cls).install(mh)
@classmethod
def uninstall(cls, mh):
if not pki_supports_RSNv3(mh.master):
raise pytest.skip("RSNv3 not supported")
super(TestServerCALessToExternalCA_RSN, cls).uninstall(mh)