def test_command_injection_exit(fixture_tmpdir): """test that subprocess.run isn't raising an exception due to exit 1""" mocked_self = mock.MagicMock() mocked_self._gitcmd = Gitget._gitcmd mocked_self._repodir = fixture_tmpdir # must not raise an exception Gitget._run_command(mocked_self, ("--version", ";", "exit", "1"))
def test_command_injection_output(fixture_tmpdir): """test that subprocess.run output doesn't contain output from injected command""" mocked_self = mock.MagicMock() mocked_self._gitcmd = Gitget._gitcmd mocked_self._repodir = fixture_tmpdir output = Gitget._run_command(mocked_self, ("--version", ";", "pwd")) assert mocked_self._repodir not in output
def test_shell_false(mocker): """test that subprocess.run is using shell=False""" mocked_run = mocker.patch("as3ninja.gitget.run") Gitget._run_command(mock.MagicMock(), ("ls")) assert "shell=False" in str(mocked_run.call_args)