summaryrefslogtreecommitdiff
path: root/test/test_exc.py
diff options
context:
space:
mode:
authorSebastian Thiel <sebastian.thiel@icloud.com>2022-05-05 08:15:56 +0800
committerGitHub <noreply@github.com>2022-05-05 08:15:56 +0800
commitb3166ece31bfb29e89f6ed4bb9214bf1c03791df (patch)
treeee9aa2356a5f57cf547580d56e2df3723df6c6df /test/test_exc.py
parentd5cee4a467a0ab543c0a118cc763ad3a54b8fc69 (diff)
parent85fe2735b7c9119804813bcbbdd8d14018291ed3 (diff)
downloadgitpython-b3166ece31bfb29e89f6ed4bb9214bf1c03791df.tar.gz
Merge pull request #1437 from glennmatthews/issue-1284
Strip usernames from URLs as well as passwords
Diffstat (limited to 'test/test_exc.py')
-rw-r--r--test/test_exc.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/test/test_exc.py b/test/test_exc.py
index f16498ab..c77be782 100644
--- a/test/test_exc.py
+++ b/test/test_exc.py
@@ -22,6 +22,7 @@ from git.exc import (
HookExecutionError,
RepositoryDirtyError,
)
+from git.util import remove_password_if_present
from test.lib import TestBase
import itertools as itt
@@ -34,6 +35,7 @@ _cmd_argvs = (
('cmd', 'ελληνικα', 'args'),
('θνιψοδε', 'κι', 'αλλα', 'strange', 'args'),
('θνιψοδε', 'κι', 'αλλα', 'non-unicode', 'args'),
+ ('git', 'clone', '-v', 'https://fakeuser:fakepassword1234@fakerepo.example.com/testrepo'),
)
_causes_n_substrings = (
(None, None), # noqa: E241 @IgnorePep8
@@ -81,7 +83,7 @@ class TExc(TestBase):
self.assertIsNotNone(c._msg)
self.assertIn(' cmdline: ', s)
- for a in argv:
+ for a in remove_password_if_present(argv):
self.assertIn(a, s)
if not cause:
@@ -137,14 +139,15 @@ class TExc(TestBase):
@ddt.data(
(['cmd1'], None),
(['cmd1'], "some cause"),
- (['cmd1'], Exception()),
+ (['cmd1', 'https://fakeuser@fakerepo.example.com/testrepo'], Exception()),
)
def test_GitCommandError(self, init_args):
argv, cause = init_args
c = GitCommandError(argv, cause)
s = str(c)
- self.assertIn(argv[0], s)
+ for arg in remove_password_if_present(argv):
+ self.assertIn(arg, s)
if cause:
self.assertIn(' failed due to: ', s)
self.assertIn(str(cause), s)