mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Re-initialize NSS database after otptoken plugin tests
OTP token tests do not properly reinitialize the NSS db, thus making subsequent xmlrpc tests fail on SSL cert validation. Make sure NSS db is re-initalized in the teardown method. https://fedorahosted.org/freeipa/ticket/4748 Reviewed-By: Petr Viktorin <pviktori@redhat.com>
This commit is contained in:
parent
b3a6701e73
commit
792ff0c0c4
@ -89,6 +89,26 @@ def strip_header(pem):
|
||||
|
||||
return pem
|
||||
|
||||
def initialize_nss_database(dbdir=None):
|
||||
"""
|
||||
Initializes NSS database, if not initialized yet. Uses a proper database
|
||||
directory (.ipa/alias or HTTPD_ALIAS_DIR), depending on the value of
|
||||
api.env.in_tree.
|
||||
"""
|
||||
|
||||
if not nss.nss_is_initialized():
|
||||
if dbdir is None:
|
||||
if 'in_tree' in api.env:
|
||||
if api.env.in_tree:
|
||||
dbdir = api.env.dot_ipa + os.sep + 'alias'
|
||||
else:
|
||||
dbdir = paths.HTTPD_ALIAS_DIR
|
||||
nss.nss_init(dbdir)
|
||||
else:
|
||||
nss.nss_init_nodb()
|
||||
else:
|
||||
nss.nss_init(dbdir)
|
||||
|
||||
def load_certificate(data, datatype=PEM, dbdir=None):
|
||||
"""
|
||||
Given a base64-encoded certificate, with or without the
|
||||
@ -103,18 +123,7 @@ def load_certificate(data, datatype=PEM, dbdir=None):
|
||||
data = strip_header(data)
|
||||
data = base64.b64decode(data)
|
||||
|
||||
if not nss.nss_is_initialized():
|
||||
if dbdir is None:
|
||||
if 'in_tree' in api.env:
|
||||
if api.env.in_tree:
|
||||
dbdir = api.env.dot_ipa + os.sep + 'alias'
|
||||
else:
|
||||
dbdir = paths.HTTPD_ALIAS_DIR
|
||||
nss.nss_init(dbdir)
|
||||
else:
|
||||
nss.nss_init_nodb()
|
||||
else:
|
||||
nss.nss_init(dbdir)
|
||||
initialize_nss_database(dbdir=dbdir)
|
||||
|
||||
return nss.Certificate(buffer(data))
|
||||
|
||||
|
@ -21,12 +21,17 @@ import os
|
||||
import sys
|
||||
import nose
|
||||
from nss import nss
|
||||
from ipalib.x509 import initialize_nss_database
|
||||
|
||||
from ipaserver.install.ipa_otptoken_import import PSKCDocument, ValidationError
|
||||
|
||||
basename = os.path.join(os.path.dirname(__file__), "data")
|
||||
|
||||
class test_otptoken_import(object):
|
||||
|
||||
def teardown(self):
|
||||
initialize_nss_database()
|
||||
|
||||
def test_figure3(self):
|
||||
doc = PSKCDocument(os.path.join(basename, "pskc-figure3.xml"))
|
||||
assert doc.keyname is None
|
||||
|
Loading…
Reference in New Issue
Block a user