class TestLockpick(unittest.TestCase): """ Units tests for the Lockpick Python client """ def setUp(self): self.lockpyck = Lockpyck(_TESTUSER, _TESTPASS, _TESTHOST) def test_version(self): self.assertTrue(self.lockpyck.version == '0.0.1') def test_kdm(self): kdm = self.lockpyck.kdm('daf5f223-5924-4a43-8f3b-e34a0b13f4b4') for k in kdm.keys(): self.assertTrue(k in ('id', 'text', 'subject', 'valid_from', 'valid_to', 'delivery', 'cpl_id', 'cpl_text', 'xml', 'status', 'user', 'signer',)) for k in kdm['subject'].keys(): self.assertTrue(k in ('thumbprint', 'name', 'org', 'unit', 'screen_number', 'facility_name', 'facility_id', 'circuit')) self.assertEqual(kdm['subject']['thumbprint'], 'dCxHtnikb+RSfBAuRkIVqPxaY4I=') def test_save_kdm(self): result = self.lockpyck.save_kdm(_TESTKDM) self.assertTrue(not 'errors' in result.keys()) self.assertEqual(result['message'], 'Saved KDM') kdm = self.lockpyck.kdm('4a8c103c-8d55-4cea-b665-b08d8053e576') self.assertEqual(kdm['xml'], _TESTKDM) def test_kdms_from_thumbprint(self): kdms = self.lockpyck.kdms_from_thumbprint('Gio9Szty8daEiFpFUVMv2uiackk=') self.assertTrue(len(kdms)) def test_kdm_bundle(self): # Add the test KDM self.lockpyck.save_kdm(_TESTKDM) # Retrieve the bundle filename, tarball = self.lockpyck.kdm_bundle('6b3f9ef8-f9c4-42b9-aff0-645cb0b11e06', '1a2a3d4b3b72f1d684885a4551532fdae89a7249') self.assertEqual(filename, 'KDMb-6b3f9ef8-f9c4-42b9-aff0-645cb0b11e06.tar') self.assertTrue(tarball.find('<AnnotationText language="en">Locksmith KDM Bundle</AnnotationText>') != -1)
def setUp(self): self.lockpyck = Lockpyck(_TESTUSER, _TESTPASS, _TESTHOST)