Add HTTP endpoint for resending email confirmation (#11354)

This commit is contained in:
Paulus Schoutsen authored and Pascal Vizeli committed 2017-12-29 14:46:10 +01:00
1 parent 2a2e6b6334
commit cfd78f7b02
4 files changed
+97

No files matched your search

+16
View File
@@ -119,6 +119,22 @@ def test_confirm_register_fails(mock_cognito):
auth_api.confirm_register(cloud, '123456', 'email@home-assistant.io')
def test_resend_email_confirm(mock_cognito):
"""Test starting forgot password flow."""
cloud = MagicMock()
auth_api.resend_email_confirm(cloud, 'email@home-assistant.io')
assert len(mock_cognito.client.resend_confirmation_code.mock_calls) == 1
def test_resend_email_confirm_fails(mock_cognito):
"""Test failure when starting forgot password flow."""
cloud = MagicMock()
mock_cognito.client.resend_confirmation_code.side_effect = \
aws_error('SomeError')
with pytest.raises(auth_api.CloudError):
auth_api.resend_email_confirm(cloud, 'email@home-assistant.io')
def test_forgot_password(mock_cognito):
"""Test starting forgot password flow."""
cloud = MagicMock()
+42
View File
@@ -315,6 +315,48 @@ def test_forgot_password_view_unknown_error(mock_cognito, cloud_client):
assert req.status == 502
@asyncio.coroutine
def test_resend_confirm_view(mock_cognito, cloud_client):
"""Test logging out."""
req = yield from cloud_client.post('/api/cloud/resend_confirm', json={
'email': 'hello@bla.com',
})
assert req.status == 200
assert len(mock_cognito.client.resend_confirmation_code.mock_calls) == 1
@asyncio.coroutine
def test_resend_confirm_view_bad_data(mock_cognito, cloud_client):
"""Test logging out."""
req = yield from cloud_client.post('/api/cloud/resend_confirm', json={
'not_email': 'hello@bla.com',
})
assert req.status == 400
assert len(mock_cognito.client.resend_confirmation_code.mock_calls) == 0
@asyncio.coroutine
def test_resend_confirm_view_request_timeout(mock_cognito, cloud_client):
"""Test timeout while logging out."""
mock_cognito.client.resend_confirmation_code.side_effect = \
asyncio.TimeoutError
req = yield from cloud_client.post('/api/cloud/resend_confirm', json={
'email': 'hello@bla.com',
})
assert req.status == 502
@asyncio.coroutine
def test_resend_confirm_view_unknown_error(mock_cognito, cloud_client):
"""Test unknown error while logging out."""
mock_cognito.client.resend_confirmation_code.side_effect = \
auth_api.UnknownError
req = yield from cloud_client.post('/api/cloud/resend_confirm', json={
'email': 'hello@bla.com',
})
assert req.status == 502
@asyncio.coroutine
def test_confirm_forgot_password_view(mock_cognito, cloud_client):
"""Test logging out."""