def Run(self): mode = str(self._args[0]) try: bl = bitlocker.Bitlocker(mode) bl.Enable() except bitlocker.BitlockerError as e: raise ActionError('Failure enabling Bitlocker. (%s)' % str(e))
def testManageBde(self, call): bit = bitlocker.Bitlocker(mode='bde_tpm') call.return_value = 0 cmdline = ('C:\\Windows\\System32\\cmd.exe /c ' 'C:\\Windows\\System32\\manage-bde.exe -on c: -rp >NUL') bit.Enable() call.assert_called_with(cmdline, shell=True) call.return_value = 1 self.assertRaises(bitlocker.BitlockerError, bit.Enable)
def testPowershell(self, ps): bit = bitlocker.Bitlocker(mode='ps_tpm') bit.Enable() ps.assert_has_calls([ mock.call(mock.ANY, [ "$ErrorActionPreference='Stop'", ';', 'Enable-BitLocker', 'C:', '-TpmProtector', '-UsedSpaceOnly', '-SkipHardwareTest ', '>>', '%s\\enable-bitlocker.txt' % bitlocker.constants.SYS_LOGS_PATH ]), mock.call(mock.ANY, [ "$ErrorActionPreference='Stop'", ';', 'Add-BitLockerKeyProtector', 'C:', '-RecoveryPasswordProtector', '>NUL' ]) ]) ps.side_effect = bitlocker.powershell.PowerShellError self.assertRaises(bitlocker.BitlockerError, bit.Enable)
def testFailure(self): bit = bitlocker.Bitlocker(mode='unsupported') self.assertRaises(bitlocker.BitlockerError, bit.Enable)