diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2020-03-21 10:28:17 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-02-07 11:16:53 +0000 |
commit | 06cba6ccd165ca8b224797e37fccb9e63f026d77 (patch) | |
tree | e82f1bc439997ae296f2e74f8a64d84c5d95f140 /tests/cli_tests/test_history.py | |
parent | Initial commit. (diff) | |
download | iredis-06cba6ccd165ca8b224797e37fccb9e63f026d77.tar.xz iredis-06cba6ccd165ca8b224797e37fccb9e63f026d77.zip |
Adding upstream version 1.9.1.upstream/1.9.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | tests/cli_tests/test_history.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/cli_tests/test_history.py b/tests/cli_tests/test_history.py new file mode 100644 index 0000000..09e6c82 --- /dev/null +++ b/tests/cli_tests/test_history.py @@ -0,0 +1,42 @@ +import os +import pexpect +from pathlib import Path +from textwrap import dedent + + +def test_history_not_log_auth(cli): + cli.sendline("AUTH 123") + cli.expect(["Client sent AUTH, but no password is set", "127.0.0.1"]) + cli.sendline("set foo bar") + cli.expect("OK") + + with open(os.path.expanduser("~/.iredis_history"), "r") as history_file: + content = history_file.read() + + assert "set foo bar" in content + assert "AUTH" not in content + + +def test_history_create_and_writing_with_config(): + config_content = dedent( + """ + [main] + history_location = /tmp/iredis_history.txt + """ + ) + with open("/tmp/iredisrc", "w+") as etc_config: + etc_config.write(config_content) + + cli = pexpect.spawn("iredis -n 15 --iredisrc /tmp/iredisrc", timeout=2) + cli.expect("127.0.0.1") + cli.sendline("set hello world") + cli.expect("OK") + cli.close() + + log = Path("/tmp/iredis_history.txt") + assert log.exists() + + with open(log, "r") as logfile: + content = logfile.read() + + assert "set hello world" in content |