def testKeyczarCrypterEncryptDecryptHandlesEmptyNone(self): location = 'castle://aargh' kz_crypter = keyczar.Crypter(location) self.assertEqual('', kz_crypter.encrypt('')) self.assertEqual('', kz_crypter.encrypt(None)) self.assertEqual('', kz_crypter.decrypt('')) self.assertEqual('', kz_crypter.decrypt(None))
def testKeyczarCrypterWithUnencryptedReader(self): """""" location = 'bar://baz' kz_crypter = keyczar.Crypter(location) self.assertEqual(location, kz_crypter.keyset_location) self.assertIsNone(kz_crypter.encrypting_keyset_location) self.assertIsInstance(kz_crypter.crypter, mocks.MockKeyczarCrypter) self.assertIsInstance(kz_crypter.crypter.reader, mocks.MockKeyczarReader) self.assertEqual(location, kz_crypter.crypter.reader.location)
def testKeyczarCrypterWithEncryptedReader(self): """""" location = 'foo://baz' encrypting_location = 'castle://aaargh' kz_crypter = keyczar.Crypter(location, encrypting_location) self.assertEqual(location, kz_crypter.keyset_location) self.assertEqual(encrypting_location, kz_crypter.encrypting_keyset_location) self.assertIsInstance(kz_crypter.crypter, mocks.MockKeyczarCrypter) self.assertIsInstance(kz_crypter.crypter.reader, mocks.MockKeyczarEncryptedReader) self.assertEqual(location, kz_crypter.crypter.reader._reader.location) self.assertEqual(encrypting_location, kz_crypter.crypter.reader._crypter.reader.location)