mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-05-05 16:38:59 -04:00
Update two-factor to use new update password endpoint and refactor tests
This commit is contained in:
@@ -164,7 +164,7 @@ def test_two_factor_should_set_password_when_new_password_exists_in_session(
|
||||
mock_get_user,
|
||||
mock_check_verify_code,
|
||||
mock_get_services_with_one_service,
|
||||
mock_update_user,
|
||||
mock_update_user_password,
|
||||
):
|
||||
with client.session_transaction() as session:
|
||||
session['user_details'] = {
|
||||
@@ -180,36 +180,7 @@ def test_two_factor_should_set_password_when_new_password_exists_in_session(
|
||||
service_id=SERVICE_ONE_ID,
|
||||
_external=True
|
||||
)
|
||||
api_user_active.password = 'changedpassword'
|
||||
mock_update_user.assert_called_once_with(api_user_active)
|
||||
|
||||
|
||||
def test_two_factor_reset_login_count_called(
|
||||
client,
|
||||
api_user_locked,
|
||||
mock_get_locked_user,
|
||||
mock_update_user,
|
||||
mock_check_verify_code,
|
||||
mock_get_services_with_one_service,
|
||||
):
|
||||
with client.session_transaction() as session:
|
||||
new_password = "1234567890"
|
||||
session['user_details'] = {
|
||||
'id': api_user_locked.id,
|
||||
'email': api_user_locked.email_address,
|
||||
'password': new_password
|
||||
}
|
||||
response = client.post(url_for('main.two_factor'),
|
||||
data={'sms_code': '12345'})
|
||||
assert response.status_code == 302
|
||||
assert response.location == url_for(
|
||||
'main.service_dashboard',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
_external=True
|
||||
)
|
||||
api_user_locked.reset_failed_login_count()
|
||||
api_user_locked.password = new_password
|
||||
mock_update_user.assert_called_once_with(api_user_locked)
|
||||
mock_update_user_password.assert_called_once_with(api_user_active.id, password='changedpassword')
|
||||
|
||||
|
||||
def test_two_factor_returns_error_when_user_is_locked(
|
||||
|
||||
Reference in New Issue
Block a user