def testIsBootVolumeEncryptedWhenNotCoreStorage(self): self.mox.StubOutWithMock(util, 'GetPlistFromExec') corestorage.util.GetPlistFromExec(mox.In(DISKUTIL)).AndRaise( util.ExecError) self.mox.ReplayAll() self.assertEquals(False, corestorage.IsBootVolumeEncrypted()) self.mox.VerifyAll()
def testIsBootVolumeEncryptedWhenNoLVFInfo(self): self.mox.StubOutWithMock(util, 'GetPlistFromExec') lvf_uuid = 'bad uuid' corestorage.util.GetPlistFromExec(mox.In(DISKUTIL)).AndReturn( {'MemberOfCoreStorageLogicalVolumeFamily': lvf_uuid}) corestorage.util.GetPlistFromExec((DISKUTIL, 'cs', 'info', '-plist', lvf_uuid)).AndRaise(util.ExecError) self.mox.ReplayAll() self.assertEquals(False, corestorage.IsBootVolumeEncrypted()) self.mox.VerifyAll()
def testIsBootVolumeEncryptedWhenEncrypted(self): self.mox.StubOutWithMock(util, 'GetPlistFromExec') lvf_uuid = 'bad uuid' corestorage.util.GetPlistFromExec(mox.In(DISKUTIL)).AndReturn( {'MemberOfCoreStorageLogicalVolumeFamily': lvf_uuid}) corestorage.util.GetPlistFromExec( (DISKUTIL, 'cs', 'info', '-plist', lvf_uuid)).AndReturn( {'CoreStorageLogicalVolumeFamilyEncryptionType': 'AES-XTS'}) self.mox.ReplayAll() self.assertEquals(True, corestorage.IsBootVolumeEncrypted()) self.mox.VerifyAll()
def testIsBootVolumeEncryptedWhenNoLVFInfo(self, get_plist_from_exec_mock): lvf_uuid = 'bad uuid' get_plist_from_exec_mock.side_effect = [{ 'MemberOfCoreStorageLogicalVolumeFamily': lvf_uuid }, util.ExecError] self.assertEquals(False, corestorage.IsBootVolumeEncrypted()) get_plist_from_exec_mock.assert_has_calls([ mock.call(('/usr/sbin/diskutil', 'cs', 'info', '-plist', '/')), mock.call(('/usr/sbin/diskutil', 'cs', 'info', '-plist', lvf_uuid)) ])
def testIsBootVolumeEncryptedWhenEncrypted(self, get_plist_from_exec_mock): lvf_uuid = 'bad uuid' get_plist_from_exec_mock.side_effect = [ { 'MemberOfCoreStorageLogicalVolumeFamily': lvf_uuid }, { 'CoreStorageLogicalVolumeFamilyEncryptionType': 'AES-XTS' }, ] self.assertEquals(True, corestorage.IsBootVolumeEncrypted()) get_plist_from_exec_mock.assert_has_calls([ mock.call(('/usr/sbin/diskutil', 'cs', 'info', '-plist', '/')), mock.call(('/usr/sbin/diskutil', 'cs', 'info', '-plist', lvf_uuid)) ])
def testIsBootVolumeEncryptedWhenNotCoreStorage(self, _): self.assertEquals(False, corestorage.IsBootVolumeEncrypted())