Esempio n. 1
0
 def testBadMetadata(self, mock_fvc, mock_bc, mock_getpass):
     action = 'display'
     volume = 'fakevolume'
     mock_getpass.return_value = 'password'
     # Must unmock the MetadataError class:
     mock_bc.MetadataError = base_client.MetadataError
     (mock_fvc.return_value.GetAndValidateMetadata.side_effect
      ) = base_client.MetadataError('Required metadata is not found')
     ret = self.cmd.Execute(action, volume)
     self.assertEqual(commandline.RET_MACHINE_METADATA_ERROR, ret)
Esempio n. 2
0
 def testAuthenticateFailBadMetadata(self):
     with mock.patch.object(base_client, 'GetOauthCredentials') as _:
         mock_fvc = mock.MagicMock(client.FileVaultClient)
         mock_fvc.GetAndValidateMetadata.side_effect = base_client.MetadataError(
             'missing data')
         with mock.patch.object(client, 'FileVaultClient') as mock_fvc_cls:
             mock_fvc_cls.return_value = mock_fvc
             cb = mock.Mock()
             cb.return_value = None
             _NoGuiOauth()._Authenticate(cb)
             self.assertEqual(1, cb.call_count)
             self.assertEqual('missing data', cb.call_args[0][0])