예제 #1
0
	def testBasics(self):
		'''Testing the basics of the interface with a super-simple db'''

		# Create new, empty database without file-storage
		db = supersimpledb.MurmeliDb()
		DbI.setDb(db)

		# Lists should be empty
		self.assertEqual(len(DbI.getMessageableProfiles()), 0, "Should be 0 messageables")
		self.assertEqual(len(DbI.getTrustedProfiles()), 0, "Should be 0 trusted")
		self.assertFalse(DbI.hasFriends(), "Shouldn't have any friends")

		# Store some profiles
		DbI.updateProfile("abc123", {"keyid":"ZYXW987", "status":"self", "name":"That's me"})
		DbI.updateProfile("def123", {"keyid":"JKLM987", "status":"trusted", "name":"Jimmy"})
		DbI.updateProfile("ghi123", {"keyid":"TUVWX987", "status":"untrusted", "name":"Dave"})

		# Get my ids
		self.assertEqual(DbI.getOwnTorid(), "abc123", "Should find correct tor id")
		self.assertEqual(DbI.getOwnKeyid(), "ZYXW987", "Should find correct key id")

		# Get all profiles
		self.assertEqual(len(DbI.getProfiles()), 3, "Should be three profiles in total")
		self.assertEqual(len(DbI.getMessageableProfiles()), 2, "Should be two messageables")
		self.assertEqual(len(DbI.getTrustedProfiles()), 1, "Should be one trusted")
		self.assertEqual(DbI.getTrustedProfiles()[0]['displayName'], "Jimmy", "Jimmy should be trusted")
		self.assertTrue(DbI.hasFriends(), "Should have friends")

		# Update an existing profile
		DbI.updateProfile("def123", {"displayName":"Slippin' Jimmy"})
		self.assertEqual(len(DbI.getTrustedProfiles()), 1, "Should still be one trusted")
		self.assertEqual(DbI.getTrustedProfiles()[0]['displayName'], "Slippin' Jimmy", "Slippin' Jimmy should be trusted")

		# Finished
		DbI.releaseDb()
예제 #2
0
파일: message.py 프로젝트: bellyfat/Murmeli
 def _createPayload(self, recipientKeyId):
     '''Create the encrypted output for the given recipient'''
     total = self._createUnencryptedPayload()
     # Encrypt and sign the result
     ownKeyId = DbI.getOwnKeyid()
     return CryptoClient.encryptAndSign(total, recipientKeyId, ownKeyId)
예제 #3
0
파일: message.py 프로젝트: bellyfat/Murmeli
 def _createPayload(self, recipientKeyId):
     '''Get the original message, and then sign it with our key'''
     if self.origParcel:
         ownKeyId = DbI.getOwnKeyid()
         return CryptoClient.signData(self.origParcel, ownKeyId)
예제 #4
0
 def _makeFingerprintChecker(self, userid):
     '''Use the given userid to make a FingerprintChecker between me and them'''
     person = DbI.getProfile(userid)
     ownFingerprint = CryptoClient.getFingerprint(DbI.getOwnKeyid())
     usrFingerprint = CryptoClient.getFingerprint(person['keyid'])
     return FingerprintChecker(ownFingerprint, usrFingerprint)