Esempio n. 1
0
    def testAreEncryptionKeysAvailableWithLoadKeysError(self):
        self.mox.StubOutWithMock(crypto, 'CauliflowerVestReader', True)
        self.mox.StubOutWithMock(crypto.CauliflowerVestReader, 'LoadKeys')

        t = 'footype'
        mock_reader = self.mox.CreateMockAnything()
        crypto.CauliflowerVestReader().AndReturn(mock_reader)
        mock_reader.LoadKeys(t).AndRaise(crypto.Error)

        self.mox.ReplayAll()
        self.assertFalse(crypto.AreEncryptionKeysAvailable(key_type=t))
        self.mox.VerifyAll()
Esempio n. 2
0
    def testEncrypt(self):
        self.mox.StubOutWithMock(crypto, 'CauliflowerVestReader', True)
        self.mox.StubOutWithMock(crypto.CauliflowerVestReader, 'LoadKeys')
        self.mox.StubOutWithMock(crypto.keyczar, 'Crypter', True)

        data = 'foodata'
        key_type = 'footype'

        mock_reader = self.mox.CreateMockAnything()
        mock_crypter = self.mox.CreateMockAnything()

        crypto.CauliflowerVestReader().AndReturn(mock_reader)
        mock_reader.LoadKeys(key_type).AndReturn(None)
        crypto.keyczar.Crypter(reader=mock_reader).AndReturn(mock_crypter)
        mock_crypter.Encrypt(data).AndReturn('result')

        self.mox.ReplayAll()
        r = crypto.Encrypt(data, encryption_key_type=key_type)
        self.assertEqual(r, 'result')
        self.mox.VerifyAll()
 def setUp(self):
   super(CauliflowerVestReaderTest, self).setUp()
   self.r = crypto.CauliflowerVestReader()
Esempio n. 4
0
 def setUp(self):
     mox.MoxTestBase.setUp(self)
     self.stubs = stubout.StubOutForTesting()
     self.r = crypto.CauliflowerVestReader()