Пример #1
0
  def testAreEncryptionKeysAvailableWhenAvailable(self, cauliflowervest_reader):
    t = 'footype'
    mock_reader = mock.MagicMock()
    cauliflowervest_reader.return_value = mock_reader

    self.assertTrue(crypto.AreEncryptionKeysAvailable(key_type=t))

    mock_reader.LoadKeys.assert_called_once_with(t)
Пример #2
0
  def testAreEncryptionKeysAvailableWithLoadKeysError(self, cauliflowervest_reader):
    t = 'footype'
    mock_reader = mock.MagicMock()
    cauliflowervest_reader.return_value = mock_reader
    mock_reader.LoadKeys.side_effect = crypto.Error()

    self.assertFalse(crypto.AreEncryptionKeysAvailable(key_type=t))
    mock_reader.LoadKeys.assert_called_once_with(t)
Пример #3
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()