Fix reporting on bad login (#6201)
This commit is contained in:
parent
df5866dd95
commit
d6818c7015
5 changed files with 28 additions and 23 deletions
|
@ -9,7 +9,7 @@ import pytest
|
|||
from homeassistant.core import callback
|
||||
from homeassistant.components import websocket_api as wapi, frontend
|
||||
|
||||
from tests.common import mock_http_component_app
|
||||
from tests.common import mock_http_component_app, mock_coro
|
||||
|
||||
API_PASSWORD = 'test1234'
|
||||
|
||||
|
@ -66,13 +66,16 @@ def test_auth_via_msg(no_auth_websocket_client):
|
|||
@asyncio.coroutine
|
||||
def test_auth_via_msg_incorrect_pass(no_auth_websocket_client):
|
||||
"""Test authenticating."""
|
||||
no_auth_websocket_client.send_json({
|
||||
'type': wapi.TYPE_AUTH,
|
||||
'api_password': API_PASSWORD + 'wrong'
|
||||
})
|
||||
with patch('homeassistant.components.websocket_api.process_wrong_login',
|
||||
return_value=mock_coro()) as mock_process_wrong_login:
|
||||
no_auth_websocket_client.send_json({
|
||||
'type': wapi.TYPE_AUTH,
|
||||
'api_password': API_PASSWORD + 'wrong'
|
||||
})
|
||||
|
||||
msg = yield from no_auth_websocket_client.receive_json()
|
||||
msg = yield from no_auth_websocket_client.receive_json()
|
||||
|
||||
assert mock_process_wrong_login.called
|
||||
assert msg['type'] == wapi.TYPE_AUTH_INVALID
|
||||
assert msg['message'] == 'Invalid password'
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue