def testGetRecoveryPartitionWhenDiskutilFail(self): self.mox.StubOutWithMock(util, 'GetPlistFromExec') util.GetPlistFromExec(mox.In(DISKUTIL)).AndRaise( corestorage.util.ExecError) self.mox.ReplayAll() self.assertEquals(corestorage.GetRecoveryPartition(), None) self.mox.VerifyAll()
def testGetRecoveryPartition(self): self.mox.StubOutWithMock(util, 'GetPlistFromExec') pl = plistlib.readPlistFromString(DISKUTIL_LIST_PLIST) util.GetPlistFromExec(mox.In(DISKUTIL)).AndReturn(pl) self.mox.ReplayAll() self.assertEquals(corestorage.GetRecoveryPartition(), '/dev/disk0s3') self.mox.VerifyAll()
def testGetRecoveryPartition(self, get_plist_from_exec_mock): pl = plistlib.readPlistFromString(DISKUTIL_LIST_PLIST) get_plist_from_exec_mock.return_value = pl self.assertEquals(corestorage.GetRecoveryPartition(), '/dev/disk0s3') get_plist_from_exec_mock.assert_called_once()
def CheckEncryptionPreconditions(): # FileVault2 depends on the presence of a Recovery Partition to # enable encryption. if not corestorage.GetRecoveryPartition(): raise OptionError('Recovery partition must exist.') # We can't get a recovery passphrase if a keychain is in place. if os.path.exists('/Library/Keychains/FileVaultMaster.keychain'): raise OptionError( 'This tool cannot operate with a FileVaultMaster keychain in place.')
def CheckEncryptionPreconditions(): # As far as our current understanding, we can't apply encryption if no # recovery partition is on the disk. If we attempt to do so csfde fails # inside Apple's code when it calls -[DADisk description] on a null pointer, # presumably the recovery partition it expected to find. if not corestorage.GetRecoveryPartition(): raise OptionError('Recovery partition must exist.') # We can't get a recovery passphrase if a keychain is in place. if os.path.exists('/Library/Keychains/FileVaultMaster.keychain'): raise OptionError( 'This tool cannot operate with a FileVaultMaster keychain in place.')
def testGetRecoveryPartitionWhenDiskutilFail(self, _): self.assertEquals(corestorage.GetRecoveryPartition(), None)