mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-18 21:49:37 -04:00
replace user PUT with POSTs
the update_user fn was used in two places, for things that are handled fine by update_user_attribute. Reduce complexity in the API by killing the PUT, which is more dangerous (might silently overwrite things that shouldn't be, like "last_logged_in_at" etc). Had to change the code not received mobile number form, and the activate user function.
This commit is contained in:
@@ -324,7 +324,7 @@ def test_new_invited_user_verifies_and_added_to_service(
|
||||
mock_send_verify_code,
|
||||
mock_check_verify_code,
|
||||
mock_get_user,
|
||||
mock_update_user,
|
||||
mock_update_user_attribute,
|
||||
mock_add_user_to_service,
|
||||
mock_accept_invite,
|
||||
mock_get_service,
|
||||
|
||||
@@ -79,11 +79,10 @@ def test_should_resend_verify_code_and_update_mobile_for_pending_user(
|
||||
client,
|
||||
mocker,
|
||||
api_user_pending,
|
||||
mock_update_user,
|
||||
mock_update_user_attribute,
|
||||
mock_send_verify_code,
|
||||
phone_number_to_register_with,
|
||||
):
|
||||
|
||||
mocker.patch('app.user_api_client.get_user_by_email', return_value=api_user_pending)
|
||||
|
||||
with client.session_transaction() as session:
|
||||
@@ -95,7 +94,7 @@ def test_should_resend_verify_code_and_update_mobile_for_pending_user(
|
||||
assert response.status_code == 302
|
||||
assert response.location == url_for('main.verify', _external=True)
|
||||
|
||||
mock_update_user.assert_called_once_with(api_user_pending)
|
||||
mock_update_user_attribute.assert_called_once_with(api_user_pending.id, mobile_number=phone_number_to_register_with)
|
||||
mock_send_verify_code.assert_called_once_with(api_user_pending.id, 'sms', to=phone_number_to_register_with)
|
||||
|
||||
|
||||
|
||||
@@ -200,7 +200,7 @@ def test_two_factor_should_activate_pending_user(
|
||||
mocker,
|
||||
api_user_pending,
|
||||
mock_check_verify_code,
|
||||
mock_update_user,
|
||||
mock_activate_user,
|
||||
):
|
||||
mocker.patch('app.user_api_client.get_user', return_value=api_user_pending)
|
||||
mocker.patch('app.service_api_client.get_services', return_value={'data': []})
|
||||
@@ -211,5 +211,5 @@ def test_two_factor_should_activate_pending_user(
|
||||
}
|
||||
client.post(url_for('main.two_factor'), data={'sms_code': '12345'})
|
||||
|
||||
assert mock_update_user.called
|
||||
assert mock_activate_user.called
|
||||
assert api_user_pending.is_active
|
||||
|
||||
@@ -30,7 +30,7 @@ def test_should_redirect_to_add_service_when_sms_code_is_correct(
|
||||
client,
|
||||
api_user_active,
|
||||
mocker,
|
||||
mock_update_user,
|
||||
mock_update_user_attribute,
|
||||
mock_check_verify_code,
|
||||
fake_uuid
|
||||
):
|
||||
@@ -60,14 +60,14 @@ def test_should_activate_user_after_verify(
|
||||
api_user_pending,
|
||||
mock_send_verify_code,
|
||||
mock_check_verify_code,
|
||||
mock_update_user,
|
||||
mock_activate_user,
|
||||
):
|
||||
mocker.patch('app.user_api_client.get_user', return_value=api_user_pending)
|
||||
with client.session_transaction() as session:
|
||||
session['user_details'] = {'email_address': api_user_pending.email_address, 'id': api_user_pending.id}
|
||||
client.post(url_for('main.verify'),
|
||||
data={'sms_code': '12345'})
|
||||
assert mock_update_user.called
|
||||
assert mock_activate_user.called
|
||||
|
||||
|
||||
def test_should_return_200_when_sms_code_is_wrong(
|
||||
|
||||
Reference in New Issue
Block a user