summaryrefslogtreecommitdiffstats
path: root/tests/test_main.py
diff options
context:
space:
mode:
authorStuart Quin <stuart.quin@gmail.com>2015-10-19 18:40:50 +0100
committerStuart Quin <stuart.quin@gmail.com>2015-10-19 18:40:50 +0100
commiteea0cbd495e4cb0ba5ab49af968377e290e1ee27 (patch)
tree0dcf7e72213a4712bd6151a911b8b17802bdfabf /tests/test_main.py
parent748fcb76778b618d232b1c829f72d4ef65392441 (diff)
Clearer function name, handle passwords with spaces
Diffstat (limited to 'tests/test_main.py')
-rw-r--r--tests/test_main.py20
1 files changed, 16 insertions, 4 deletions
diff --git a/tests/test_main.py b/tests/test_main.py
index 6e8d14b0..efc5aa25 100644
--- a/tests/test_main.py
+++ b/tests/test_main.py
@@ -1,5 +1,5 @@
import pytest
-from pgcli.main import need_completion_refresh, obscure_process_password
+from pgcli.main import need_completion_refresh, obfuscate_process_password
@pytest.mark.parametrize('sql', [
@@ -9,18 +9,30 @@ from pgcli.main import need_completion_refresh, obscure_process_password
def test_need_completion_refresh(sql):
assert need_completion_refresh(sql)
-def test_obscure_process_password():
+def test_obfuscate_process_password():
import setproctitle
original_title = setproctitle.getproctitle()
setproctitle.setproctitle("pgcli user=root password=secret host=localhost")
- obscure_process_password()
+ obfuscate_process_password()
title = setproctitle.getproctitle()
expected = "pgcli user=root password=xxxx host=localhost"
assert title == expected
+ setproctitle.setproctitle("pgcli user=root password=top secret host=localhost")
+ obfuscate_process_password()
+ title = setproctitle.getproctitle()
+ expected = "pgcli user=root password=xxxx host=localhost"
+ assert title == expected
+
+ setproctitle.setproctitle("pgcli user=root password=top secret")
+ obfuscate_process_password()
+ title = setproctitle.getproctitle()
+ expected = "pgcli user=root password=xxxx"
+ assert title == expected
+
setproctitle.setproctitle("pgcli postgres://root:secret@localhost/db")
- obscure_process_password()
+ obfuscate_process_password()
title = setproctitle.getproctitle()
expected = "pgcli postgres://root:xxxx@localhost/db"
assert title == expected