Example #1
0
    def testEncryption(self):
        a1 = Account('key', 'crypto')
        a1.setPassword('pass')

        # Check that the password is encrypted (or at least obscured)
        encrypted = a1.encryptedPassword()
        self.assertNotEqual(encrypted, None)
        self.assertNotEqual(encrypted, 'pass')

        # Make sure the password can be decrypted
        a2 = Account('key', 'crypto')
        a2.setEncryptedPassword(encrypted)
        self.assertEqual(a2.password(), 'pass')

        # Make sure the password can't be decrypted with the wrong key
        a3 = Account('key', 'wrong key')
        a3.setEncryptedPassword(encrypted)
        self.assertNotEqual(a3.password(), 'pass')