summaryrefslogtreecommitdiff
path: root/test/test_util.py
diff options
context:
space:
mode:
authorMichael Mercier <michael.mercier@ryax.tech>2021-03-15 18:39:26 +0100
committerMichael Mercier <michael.mercier@ryax.tech>2021-03-15 18:48:34 +0100
commit50cbafc690e5692a16148dbde9de680be70ddbd1 (patch)
treec07b6454aa8bd3050020edcc114d5f33b984f975 /test/test_util.py
parentf7968d136276607115907267b3be89c3ff9acd03 (diff)
downloadgitpython-50cbafc690e5692a16148dbde9de680be70ddbd1.tar.gz
Add more test and remove password also from error logs
Diffstat (limited to 'test/test_util.py')
-rw-r--r--test/test_util.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/test/test_util.py b/test/test_util.py
index 5eba6c50..a4963264 100644
--- a/test/test_util.py
+++ b/test/test_util.py
@@ -30,7 +30,8 @@ from git.util import (
Actor,
IterableList,
cygpath,
- decygpath
+ decygpath,
+ remove_password_if_present,
)
@@ -322,3 +323,17 @@ class TestUtils(TestBase):
t2 = pickle.loads(pickle.dumps(t1))
self.assertEqual(t1._offset, t2._offset)
self.assertEqual(t1._name, t2._name)
+
+ def test_remove_password_from_command_line(self):
+ """Check that the password is not printed on the logs"""
+ password = "fakepassword1234"
+ url_with_pass = "https://fakeuser:{}@fakerepo.example.com/testrepo".format(password)
+ url_without_pass = "https://fakerepo.example.com/testrepo"
+
+ cmd_1 = ["git", "clone", "-v", url_with_pass]
+ cmd_2 = ["git", "clone", "-v", url_without_pass]
+ cmd_3 = ["no", "url", "in", "this", "one"]
+
+ assert password not in remove_password_if_present(cmd_1)
+ assert cmd_2 == remove_password_if_present(cmd_2)
+ assert cmd_3 == remove_password_if_present(cmd_3)