summaryrefslogtreecommitdiff
path: root/tests/test_cli.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_cli.py')
-rw-r--r--tests/test_cli.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/test_cli.py b/tests/test_cli.py
index f08cf6b..422dc9d 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -57,6 +57,19 @@ class TestCli:
assert 'There was an error decoding the token' in str(excinfo.value)
+ def test_decode_payload_raises_terminal_not_a_tty(self, monkeypatch):
+ decode_args = ['--key', '1234', 'decode']
+ parser = build_argparser()
+ args = parser.parse_args(decode_args)
+
+ monkeypatch.setattr(sys.stdin, 'isatty', lambda: False)
+ monkeypatch.setattr(sys.stdin, 'read', lambda: 'token')
+
+ with pytest.raises(IOError) as excinfo:
+ decode_payload(args)
+ assert 'Cannot read from stdin: terminal not a TTY' \
+ in str(excinfo.value)
+
@pytest.mark.parametrize('key,name,job,exp,verify', [
('1234', 'Vader', 'Sith', None, None),
('4567', 'Anakin', 'Jedi', '+1', None),