mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-20 14:29:51 -04:00
109898688: Complete the implementation of the did not receive code.
This commit is contained in:
@@ -86,6 +86,22 @@ def test_should_return_errors_when_code_is_expired(notifications_admin, notifica
|
||||
assert set(errors) == set(expected)
|
||||
|
||||
|
||||
def test_should_return_valid_form_when_many_codes_exist(notifications_admin,
|
||||
notifications_admin_db,
|
||||
notify_db_session):
|
||||
with notifications_admin.test_request_context(method='POST',
|
||||
data={'sms_code': '23456',
|
||||
'email_code': '23456'}) as req:
|
||||
user = set_up_test_data()
|
||||
verify_codes_dao.add_code(user_id=user.id, code='23456', code_type='email')
|
||||
verify_codes_dao.add_code(user_id=user.id, code='23456', code_type='sms')
|
||||
verify_codes_dao.add_code(user_id=user.id, code='60456', code_type='email')
|
||||
verify_codes_dao.add_code(user_id=user.id, code='27856', code_type='sms')
|
||||
req.session['user_id'] = user.id
|
||||
form = VerifyForm(req.request.form)
|
||||
assert form.validate() is True
|
||||
|
||||
|
||||
def set_up_test_data():
|
||||
user = create_test_user('pending')
|
||||
verify_codes_dao.add_code(user_id=user.id, code='12345', code_type='email')
|
||||
|
||||
@@ -56,3 +56,24 @@ def test_should_return_400_when_codes_are_wrong(notifications_admin, notificatio
|
||||
errors = json.loads(response.get_data(as_text=True))
|
||||
assert len(errors) == 2
|
||||
assert set(errors) == set(expected)
|
||||
|
||||
|
||||
def test_should_mark_all_codes_as_used_when_many_codes_exist(notifications_admin,
|
||||
notifications_admin_db,
|
||||
notify_db_session):
|
||||
with notifications_admin.test_client() as client:
|
||||
with client.session_transaction() as session:
|
||||
user = create_test_user('pending')
|
||||
session['user_id'] = user.id
|
||||
code1 = verify_codes_dao.add_code(user_id=user.id, code='23345', code_type='sms')
|
||||
code2 = verify_codes_dao.add_code(user_id=user.id, code='98456', code_type='email')
|
||||
code3 = verify_codes_dao.add_code(user_id=user.id, code='12345', code_type='sms')
|
||||
code4 = verify_codes_dao.add_code(user_id=user.id, code='23412', code_type='email')
|
||||
response = client.post('/verify',
|
||||
data={'sms_code': '23345',
|
||||
'email_code': '23412'})
|
||||
assert response.status_code == 302
|
||||
assert verify_codes_dao.get_code_by_id(code1).code_used is True
|
||||
assert verify_codes_dao.get_code_by_id(code2).code_used is True
|
||||
assert verify_codes_dao.get_code_by_id(code3).code_used is True
|
||||
assert verify_codes_dao.get_code_by_id(code4).code_used is True
|
||||
|
||||
Reference in New Issue
Block a user