Exemple #1
0
    def testTskPathType(self):
        mock_client = mock.MagicMock()

        with mock.patch.object(magics_impl._state, 'client', mock_client):
            magics_impl.grr_wget_impl('/foo/bar', path_type=magics_impl.TSK)

            mock_client.tsk.wget.assert_called_once_with('/foo/bar')
Exemple #2
0
  def testRegistryPathType(self):
    mock_client = mock.MagicMock()

    with mock.patch.object(magics_impl._state, 'client', mock_client):
      magics_impl.grr_wget_impl('/foo/bar', path_type=magics_impl.REGISTRY)

      mock_client.registry.wget.assert_called_once_with('/foo/bar')
Exemple #3
0
    def testCached(self):
        mock_client = mock.MagicMock()

        with mock.patch.object(magics_impl._state, 'client', mock_client):
            with mock.patch.object(magics_impl._state, 'cur_dir', '/quux'):
                magics_impl.grr_wget_impl('/foo/bar', cached=True)

                mock_client.os.cached.wget.assert_called_once_with('/foo/bar')
Exemple #4
0
    def testRelativePath(self):
        mock_client = mock.MagicMock()

        with mock.patch.object(magics_impl._state, 'client', mock_client):
            with mock.patch.object(magics_impl._state, 'cur_dir', '/quux'):
                magics_impl.grr_wget_impl('foo/bar')

                mock_client.os.wget.assert_called_once_with('/quux/foo/bar')
Exemple #5
0
def grr_wget(line):
    """Downloads a file and returns a link to it.

  Args:
    line: A string representing arguments passed to the magic command.

  Returns:
    A link to the file.

  Raises:
    NoClientSelectedError: Client is not selected to perform this operation.
  """
    args = grr_wget.parser.parse_args(shlex.split(line))
    return magics_impl.grr_wget_impl(args.path, args.cached)
Exemple #6
0
 def testNoClientSelected(self):
     with self.assertRaises(magics_impl.NoClientSelectedError):
         magics_impl.grr_wget_impl('foo')