Remove unused cloud APIs (#12913)
This commit is contained in:
1 parent
e07fb24987
commit
e5c4bba906
4 files changed
-233
No files matched your search
@@ -94,24 +94,6 @@ def test_register_fails(mock_cognito):
|
||||
auth_api.register(cloud, 'email@home-assistant.io', 'password')
|
||||
|
||||
|
||||
def test_confirm_register(mock_cognito):
|
||||
"""Test confirming a registration of an account."""
|
||||
cloud = MagicMock()
|
||||
auth_api.confirm_register(cloud, '123456', 'email@home-assistant.io')
|
||||
assert len(mock_cognito.confirm_sign_up.mock_calls) == 1
|
||||
result_code, result_user = mock_cognito.confirm_sign_up.mock_calls[0][1]
|
||||
assert result_user == 'email@home-assistant.io'
|
||||
assert result_code == '123456'
|
||||
|
||||
|
||||
def test_confirm_register_fails(mock_cognito):
|
||||
"""Test an error during confirmation of an account."""
|
||||
cloud = MagicMock()
|
||||
mock_cognito.confirm_sign_up.side_effect = aws_error('SomeError')
|
||||
with pytest.raises(auth_api.CloudError):
|
||||
auth_api.confirm_register(cloud, '123456', 'email@home-assistant.io')
|
||||
|
||||
|
||||
def test_resend_email_confirm(mock_cognito):
|
||||
"""Test starting forgot password flow."""
|
||||
cloud = MagicMock()
|
||||
@@ -143,27 +125,6 @@ def test_forgot_password_fails(mock_cognito):
|
||||
auth_api.forgot_password(cloud, 'email@home-assistant.io')
|
||||
|
||||
|
||||
def test_confirm_forgot_password(mock_cognito):
|
||||
"""Test confirming forgot password."""
|
||||
cloud = MagicMock()
|
||||
auth_api.confirm_forgot_password(
|
||||
cloud, '123456', 'email@home-assistant.io', 'new password')
|
||||
assert len(mock_cognito.confirm_forgot_password.mock_calls) == 1
|
||||
result_code, result_password = \
|
||||
mock_cognito.confirm_forgot_password.mock_calls[0][1]
|
||||
assert result_code == '123456'
|
||||
assert result_password == 'new password'
|
||||
|
||||
|
||||
def test_confirm_forgot_password_fails(mock_cognito):
|
||||
"""Test failure when confirming forgot password."""
|
||||
cloud = MagicMock()
|
||||
mock_cognito.confirm_forgot_password.side_effect = aws_error('SomeError')
|
||||
with pytest.raises(auth_api.CloudError):
|
||||
auth_api.confirm_forgot_password(
|
||||
cloud, '123456', 'email@home-assistant.io', 'new password')
|
||||
|
||||
|
||||
def test_check_token_writes_new_token_on_refresh(mock_cognito):
|
||||
"""Test check_token writes new token if refreshed."""
|
||||
cloud = MagicMock()
|
||||
|
||||
@@ -231,53 +231,6 @@ def test_register_view_unknown_error(mock_cognito, cloud_client):
|
||||
assert req.status == 502
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def test_confirm_register_view(mock_cognito, cloud_client):
|
||||
"""Test logging out."""
|
||||
req = yield from cloud_client.post('/api/cloud/confirm_register', json={
|
||||
'email': 'hello@bla.com',
|
||||
'confirmation_code': '123456'
|
||||
})
|
||||
assert req.status == 200
|
||||
assert len(mock_cognito.confirm_sign_up.mock_calls) == 1
|
||||
result_code, result_email = mock_cognito.confirm_sign_up.mock_calls[0][1]
|
||||
assert result_email == 'hello@bla.com'
|
||||
assert result_code == '123456'
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def test_confirm_register_view_bad_data(mock_cognito, cloud_client):
|
||||
"""Test logging out."""
|
||||
req = yield from cloud_client.post('/api/cloud/confirm_register', json={
|
||||
'email': 'hello@bla.com',
|
||||
'not_confirmation_code': '123456'
|
||||
})
|
||||
assert req.status == 400
|
||||
assert len(mock_cognito.confirm_sign_up.mock_calls) == 0
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def test_confirm_register_view_request_timeout(mock_cognito, cloud_client):
|
||||
"""Test timeout while logging out."""
|
||||
mock_cognito.confirm_sign_up.side_effect = asyncio.TimeoutError
|
||||
req = yield from cloud_client.post('/api/cloud/confirm_register', json={
|
||||
'email': 'hello@bla.com',
|
||||
'confirmation_code': '123456'
|
||||
})
|
||||
assert req.status == 502
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def test_confirm_register_view_unknown_error(mock_cognito, cloud_client):
|
||||
"""Test unknown error while logging out."""
|
||||
mock_cognito.confirm_sign_up.side_effect = auth_api.UnknownError
|
||||
req = yield from cloud_client.post('/api/cloud/confirm_register', json={
|
||||
'email': 'hello@bla.com',
|
||||
'confirmation_code': '123456'
|
||||
})
|
||||
assert req.status == 502
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def test_forgot_password_view(mock_cognito, cloud_client):
|
||||
"""Test logging out."""
|
||||
@@ -358,61 +311,3 @@ def test_resend_confirm_view_unknown_error(mock_cognito, cloud_client):
|
||||
'email': 'hello@bla.com',
|
||||
})
|
||||
assert req.status == 502
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def test_confirm_forgot_password_view(mock_cognito, cloud_client):
|
||||
"""Test logging out."""
|
||||
req = yield from cloud_client.post(
|
||||
'/api/cloud/confirm_forgot_password', json={
|
||||
'email': 'hello@bla.com',
|
||||
'confirmation_code': '123456',
|
||||
'new_password': 'hello2',
|
||||
})
|
||||
assert req.status == 200
|
||||
assert len(mock_cognito.confirm_forgot_password.mock_calls) == 1
|
||||
result_code, result_new_password = \
|
||||
mock_cognito.confirm_forgot_password.mock_calls[0][1]
|
||||
assert result_code == '123456'
|
||||
assert result_new_password == 'hello2'
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def test_confirm_forgot_password_view_bad_data(mock_cognito, cloud_client):
|
||||
"""Test logging out."""
|
||||
req = yield from cloud_client.post(
|
||||
'/api/cloud/confirm_forgot_password', json={
|
||||
'email': 'hello@bla.com',
|
||||
'not_confirmation_code': '123456',
|
||||
'new_password': 'hello2',
|
||||
})
|
||||
assert req.status == 400
|
||||
assert len(mock_cognito.confirm_forgot_password.mock_calls) == 0
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def test_confirm_forgot_password_view_request_timeout(mock_cognito,
|
||||
cloud_client):
|
||||
"""Test timeout while logging out."""
|
||||
mock_cognito.confirm_forgot_password.side_effect = asyncio.TimeoutError
|
||||
req = yield from cloud_client.post(
|
||||
'/api/cloud/confirm_forgot_password', json={
|
||||
'email': 'hello@bla.com',
|
||||
'confirmation_code': '123456',
|
||||
'new_password': 'hello2',
|
||||
})
|
||||
assert req.status == 502
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def test_confirm_forgot_password_view_unknown_error(mock_cognito,
|
||||
cloud_client):
|
||||
"""Test unknown error while logging out."""
|
||||
mock_cognito.confirm_forgot_password.side_effect = auth_api.UnknownError
|
||||
req = yield from cloud_client.post(
|
||||
'/api/cloud/confirm_forgot_password', json={
|
||||
'email': 'hello@bla.com',
|
||||
'confirmation_code': '123456',
|
||||
'new_password': 'hello2',
|
||||
})
|
||||
assert req.status == 502
|
||||
Reference in new issue
Block a user