freeipa/ipatests/test_integration/test_random_serial_numbers.py
Sumedh Sidhaye 2e11247cde 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>
2022-07-02 18:34:16 +02:00

73 lines
2.1 KiB
Python

#
# Copyright (C) 2022 FreeIPA Contributors see COPYING for license
#
import pytest
from ipatests.test_integration.test_installation import (
TestInstallWithCA_DNS1,
TestInstallWithCA_KRA1,
)
from ipatests.test_integration.test_caless import TestServerCALessToExternalCA
from ipatests.test_integration.test_commands import TestIPACommand
def pki_supports_RSNv3(host):
"""
Return whether the host supports RNSv3 based on the pki version
"""
script = ("from ipaserver.install.ca import "
"random_serial_numbers_version; "
"print(random_serial_numbers_version(True))")
result = host.run_command(['python3', '-c', script])
if 'true' in result.stdout_text.strip().lower():
return True
return False
class TestInstallWithCA_DNS1_RSN(TestInstallWithCA_DNS1):
random_serial = True
@classmethod
def install(cls, mh):
if not pki_supports_RSNv3(mh.master):
raise pytest.skip("RNSv3 not supported")
super(TestInstallWithCA_DNS1_RSN, cls).install(mh)
class TestInstallWithCA_KRA1_RSN(TestInstallWithCA_KRA1):
random_serial = True
@classmethod
def install(cls, mh):
if not pki_supports_RSNv3(mh.master):
raise pytest.skip("RNSv3 not supported")
super(TestInstallWithCA_KRA1_RSN, cls).install(mh)
class TestIPACommand_RSN(TestIPACommand):
random_serial = True
@classmethod
def install(cls, mh):
if not pki_supports_RSNv3(mh.master):
raise pytest.skip("RNSv3 not supported")
super(TestIPACommand_RSN, cls).install(mh)
class TestServerCALessToExternalCA_RSN(TestServerCALessToExternalCA):
random_serial = True
@classmethod
def install(cls, mh):
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)