Esempio n. 1
0
	def _setupKeyring(self, keyNames):
		'''Set up the keyring using the specified public and private key names'''
		keyringPath = CryptoClient._getKeyringPath()
		# Delete the entire keyring
		shutil.rmtree(keyringPath, ignore_errors=True)
		os.makedirs(keyringPath)
		if keyNames:
			for k in keyNames:
				keyId = self._importKeyFromFile(k)
				print("key id for", k, "=", keyId)
Esempio n. 2
0
	def testClearKeyring(self):
		'''Test removing keyring and adding keys to it'''
		keyringPath = CryptoClient._getKeyringPath()
		# Delete the entire keyring
		shutil.rmtree(keyringPath, ignore_errors=True)
		os.makedirs(keyringPath)
		self.assertEqual(len(CryptoClient.getPrivateKeys()), 0, "Keyring should be empty")
		# Add a public key from file
		self.assertIsNotNone(self._importKeyFromFile("key1_public"), "Import of public key should work")
		self.assertEqual(len(CryptoClient.getPrivateKeys()), 0, "Keyring shouldn't have private keys")
		self.assertEqual(len(CryptoClient.getPublicKeys()), 1, "Keyring should have one public key")
		# Now add the corresponding private key
		ownKeyId = self._importKeyFromFile("key1_private")
		self.assertIsNotNone(ownKeyId, "Import of private key should work")
		self.assertEqual(len(CryptoClient.getPrivateKeys()), 1, "Keyring should have one private key")
		self.assertEqual(len(CryptoClient.getPublicKeys()), 1, "Keyring should have one public key")