aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--unit-tests.py20
1 files changed, 18 insertions, 2 deletions
diff --git a/unit-tests.py b/unit-tests.py
index 2cdc663..10aa810 100644
--- a/unit-tests.py
+++ b/unit-tests.py
@@ -563,11 +563,19 @@ class TestPKeyMatch(TestCaseLoggedIn):
exportable = HAL_KEY_FLAG_EXPORTABLE)
return ", ".join(sorted(k for k, v in names.iteritems() if (flags & v) != 0))
+ @staticmethod
+ def cleanup_key(uuid):
+ try:
+ with hsm.pkey_open(uuid) as pkey:
+ pkey.delete()
+ except Exception as e:
+ logger.debug("Problem deleting key %s: %s", uuid, e)
+
def load_keys(self, flags):
uuids = set()
for obj in PreloadedKey.db.itervalues():
with hsm.pkey_load(obj.der, flags) as k:
- self.addCleanup(lambda uuid: hsm.pkey_open(uuid).delete(), k.uuid)
+ self.addCleanup(self.cleanup_key, k.uuid)
uuids.add(k.uuid)
#print k.uuid, k.key_type, k.key_curve, self.key_flag_names(k.key_flags)
k.set_attributes(dict((i, a) for i, a in enumerate((str(obj.keytype), str(obj.fn2)))))
@@ -637,13 +645,21 @@ class TestPKeyAttribute(TestCaseLoggedIn):
Attribute creation/lookup/deletion tests.
"""
+ @staticmethod
+ def cleanup_key(uuid):
+ try:
+ with hsm.pkey_open(uuid) as pkey:
+ pkey.delete()
+ except:
+ logger.debug("Problem deleting key %s: %s", uuid, e)
+
def load_and_fill(self, flags, n_keys = 1, n_attrs = 2, n_fill = 0):
pinwheel = Pinwheel()
for i in xrange(n_keys):
for obj in PreloadedKey.db.itervalues():
with hsm.pkey_load(obj.der, flags) as k:
pinwheel()
- self.addCleanup(lambda uuid: hsm.pkey_open(uuid).delete(), k.uuid)
+ self.addCleanup(self.cleanup_key, k.uuid)
k.set_attributes(dict((j, "Attribute {}{}".format(j, "*" * n_fill))
for j in xrange(n_attrs)))
pinwheel()