Exemplo n.º 1
0
 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))
Exemplo n.º 2
0
 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)
Exemplo n.º 3
0
 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)
Exemplo n.º 4
0
 def testFailure(self):
     bit = bitlocker.Bitlocker(mode='unsupported')
     self.assertRaises(bitlocker.BitlockerError, bit.Enable)