From 6bd6c3b28b4a3fc94e2f6a0f0ceb7508338cdee4 Mon Sep 17 00:00:00 2001 From: Josue Kouka Date: Mon, 30 Jan 2017 15:47:57 +0100 Subject: [PATCH] don't link user if PhantomJS response is erroneous (#14813) --- mandayejs/mandaye/utils.py | 3 ++- tests/test_mandayejs.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/mandayejs/mandaye/utils.py b/mandayejs/mandaye/utils.py index 0cd1979..0da440d 100644 --- a/mandayejs/mandaye/utils.py +++ b/mandayejs/mandaye/utils.py @@ -44,7 +44,8 @@ def exec_phantom(data, script='do_login.js'): try: result = json.loads(stdout) except (ValueError,): - result = {"result": "failure, couldn't decode JSON"} + result = {"result": "failure", + "reason": "couldn't decode JSON"} logger.error(stdout) if result.get('stderr'): diff --git a/tests/test_mandayejs.py b/tests/test_mandayejs.py index 96faf97..835f7f8 100644 --- a/tests/test_mandayejs.py +++ b/tests/test_mandayejs.py @@ -252,7 +252,8 @@ def test_phantom_invalid_json(mocked_popen, caplog): assert record.levelname == 'ERROR' assert record.message == 'This is not a valid JSON' - assert result['result'] == "failure, couldn't decode JSON" + assert result['result'] == "failure" + assert result['reason'] == "couldn't decode JSON" @mock.patch('mandayejs.mandaye.utils.subprocess.Popen') -- 2.11.0