def testOutOfOrder(self): self.mox.StubOutWithMock(util, 'Exec') util.Exec(('/sbin/mount')).AndReturn( (0, MOUNT_OUTPUT_OUT_OF_ORDER, '')) self.mox.ReplayAll() self.assertEquals('/dev/disk0s2', util.GetRootDisk()) self.mox.VerifyAll()
def _GetCommand(self): return (self.PATH, util.GetRootDisk(), self._username, '-')
def testOutOfOrder(self, exec_mock): self.assertEquals('/dev/disk0s2', util.GetRootDisk()) exec_mock.assert_called_once_with('/sbin/mount')
class OptionError(Error): """Base class for all errors raised by options.""" def ApplyEncryption(fvclient, username, password): """Turn encryption on.""" # Supply entropy to the system before csfde uses /dev/random. try: entropy = util.RetrieveEntropy() util.SupplyEntropy(entropy) except util.EntropyError, e: raise Error('Entropy operations failed: %s' % str(e)) root_disk = util.GetRootDisk() try: csfde_plist = util.GetPlistFromExec( (CSFDE_PATH, root_disk, username, '-'), stdin=password) except util.ExecError, e: if e.returncode == CSFDE_RETURN_AUTH_FAIL: raise InputError( 'Authentication problem with local account. Drive NOT encrypted.' ) elif e.returncode != 0: logging.error('csfde failed with stderr:\n%s', e.stderr) raise Error('Problem running csfde (exit status = %d)' % e.returncode) else: logging.exception('Problem running csfde.') raise Error('Problem running csfde', e)