示例#1
0
    def testPowerShell(self, wpe):
        # WinPE
        wpe.return_value = True
        self.assertEqual(powershell._Powershell(),
                         powershell.constants.WINPE_POWERSHELL)

        # Host
        wpe.return_value = False
        self.assertEqual(powershell._Powershell(),
                         powershell.constants.SYS_POWERSHELL)
示例#2
0
 def testRunCommand(self, call):
     call.return_value = 0
     self.ps.RunCommand(['Get-ChildItem', '-Recurse'])
     cmd = [
         powershell._Powershell(), '-NoProfile', '-NoLogo', '-Command',
         'Get-ChildItem', '-Recurse'
     ]
     call.assert_called_with(cmd, shell=True)
     with self.assertRaises(powershell.PowerShellError):
         self.ps.RunCommand(['Get-ChildItem', '-Recurse'], ok_result=[100])
示例#3
0
  def testRunLocal(self, call):
    args = ['-Arg1', '-Arg2']
    call.return_value = 0
    with self.assertRaises(powershell.PowerShellError):
      self.ps.RunLocal('/resources/missing.ps1', args=args)

    self.ps.RunLocal('/resources/bin/script.ps1', args=args)
    cmd = [
        powershell._Powershell(), '-NoProfile', '-NoLogo', '-File',
        '/resources/bin/script.ps1', '-Arg1', '-Arg2'
    ]
    call.assert_called_with(cmd, shell=True)
    with self.assertRaises(powershell.PowerShellError):
      self.ps.RunLocal('/resources/bin/script.ps1', args=args, ok_result=[100])