Imported Debian patch 4.7.2-3
This commit is contained in:
committed by
Mario Fetka
parent
27edeba051
commit
8bc559c5a1
@@ -23,6 +23,7 @@ from __future__ import print_function, absolute_import
|
||||
|
||||
import base64
|
||||
import os
|
||||
import unittest
|
||||
|
||||
import pytest
|
||||
import six
|
||||
@@ -56,7 +57,7 @@ def is_db_configured():
|
||||
|
||||
if (api.env.xmlrpc_uri == u'http://localhost:8888/ipa/xml' and
|
||||
not os.path.isfile(aliasdir)):
|
||||
pytest.skip('developer CA not configured in %s' % aliasdir)
|
||||
raise unittest.SkipTest('developer CA not configured in %s' % aliasdir)
|
||||
|
||||
# Test setup
|
||||
#
|
||||
@@ -77,22 +78,19 @@ def is_db_configured():
|
||||
class BaseCert(XMLRPC_test):
|
||||
host_fqdn = u'ipatestcert.%s' % api.env.domain
|
||||
service_princ = u'test/%s@%s' % (host_fqdn, api.env.realm)
|
||||
certfile = None
|
||||
nssdb = None
|
||||
reqfile = None
|
||||
subject = None
|
||||
|
||||
@pytest.fixture(autouse=True, scope="class")
|
||||
def basecert_setup(self, request, xmlrpc_setup):
|
||||
@classmethod
|
||||
def setup_class(cls):
|
||||
super(BaseCert, cls).setup_class()
|
||||
|
||||
if 'cert_request' not in api.Command:
|
||||
pytest.skip('cert_request not registered')
|
||||
raise unittest.SkipTest('cert_request not registered')
|
||||
if 'cert_show' not in api.Command:
|
||||
pytest.skip('cert_show not registered')
|
||||
raise unittest.SkipTest('cert_show not registered')
|
||||
|
||||
is_db_configured()
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def basecert_fsetup(self, request):
|
||||
def setup(self):
|
||||
self.nssdb = NSSDatabase()
|
||||
secdir = self.nssdb.secdir
|
||||
self.reqfile = os.path.join(secdir, "test.csr")
|
||||
@@ -101,9 +99,8 @@ class BaseCert(XMLRPC_test):
|
||||
self.nssdb.create_db()
|
||||
self.subject = DN(('CN', self.host_fqdn), subject_base())
|
||||
|
||||
def fin():
|
||||
self.nssdb.close()
|
||||
request.addfinalizer(fin)
|
||||
def teardown(self):
|
||||
self.nssdb.close() # remove tempdir
|
||||
|
||||
def generateCSR(self, subject):
|
||||
self.nssdb.run_certutil([
|
||||
@@ -118,6 +115,11 @@ class BaseCert(XMLRPC_test):
|
||||
|
||||
@pytest.mark.tier1
|
||||
class test_cert(BaseCert):
|
||||
|
||||
@classmethod
|
||||
def setup_class(cls):
|
||||
super(test_cert, cls).setup_class()
|
||||
|
||||
"""
|
||||
Test the `cert` plugin.
|
||||
"""
|
||||
@@ -240,19 +242,19 @@ class test_cert(BaseCert):
|
||||
from ipaserver.plugins.cert import _emails_are_valid
|
||||
email_addrs = [u'any@EmAiL.CoM']
|
||||
result = _emails_are_valid(email_addrs, [u'any@email.com'])
|
||||
assert result
|
||||
assert True == result, result
|
||||
|
||||
email_addrs = [u'any@EmAiL.CoM']
|
||||
result = _emails_are_valid(email_addrs, [u'any@email.com',
|
||||
u'another@email.com'])
|
||||
assert result
|
||||
assert True == result, result
|
||||
|
||||
result = _emails_are_valid([], [u'any@email.com'])
|
||||
assert result
|
||||
assert True == result, result
|
||||
|
||||
email_addrs = [u'invalidEmailAddress']
|
||||
result = _emails_are_valid(email_addrs, [])
|
||||
assert not result
|
||||
assert False == result, result
|
||||
|
||||
def test_99999_cleanup(self):
|
||||
"""
|
||||
@@ -268,19 +270,22 @@ class test_cert(BaseCert):
|
||||
|
||||
@pytest.mark.tier1
|
||||
class test_cert_find(XMLRPC_test):
|
||||
"""
|
||||
Test the `cert-find` command.
|
||||
"""
|
||||
@pytest.fixture(autouse=True, scope="class")
|
||||
def certfind_setup(self, request, xmlrpc_setup):
|
||||
|
||||
@classmethod
|
||||
def setup_class(cls):
|
||||
super(test_cert_find, cls).setup_class()
|
||||
|
||||
if 'cert_find' not in api.Command:
|
||||
pytest.skip('cert_find not registered')
|
||||
raise unittest.SkipTest('cert_find not registered')
|
||||
|
||||
if api.env.ra_plugin != 'dogtag':
|
||||
pytest.skip('cert_find for dogtag CA only')
|
||||
raise unittest.SkipTest('cert_find for dogtag CA only')
|
||||
|
||||
is_db_configured()
|
||||
|
||||
"""
|
||||
Test the `cert-find` command.
|
||||
"""
|
||||
short = api.env.host.split('.')[0]
|
||||
|
||||
def test_0001_find_all(self):
|
||||
@@ -451,6 +456,10 @@ class test_cert_find(XMLRPC_test):
|
||||
@pytest.mark.tier1
|
||||
class test_cert_revocation(BaseCert):
|
||||
|
||||
@classmethod
|
||||
def setup_class(cls):
|
||||
super(test_cert_revocation, cls).setup_class()
|
||||
|
||||
# create CSR, request cert, revoke cert, check cert attributes
|
||||
def revoke_cert(self, reason):
|
||||
# add host
|
||||
|
||||
Reference in New Issue
Block a user