mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-02 17:31:14 -05:00
Send email address in the data rather than the user_id as a path param.
Remove unused OldRequestVerifyCodeSchema.
This commit is contained in:
@@ -286,7 +286,7 @@ def test_get_user_by_email(notify_api, notify_db, notify_db_session, sample_serv
|
||||
assert sorted(expected_permissions) == sorted(fetched['permissions'][str(sample_service.id)])
|
||||
|
||||
|
||||
def test_get_user_by_email_not_found_returns_400(notify_api,
|
||||
def test_get_user_by_email_not_found_returns_404(notify_api,
|
||||
notify_db,
|
||||
notify_db_session,
|
||||
sample_user):
|
||||
@@ -299,7 +299,7 @@ def test_get_user_by_email_not_found_returns_400(notify_api,
|
||||
assert resp.status_code == 404
|
||||
json_resp = json.loads(resp.get_data(as_text=True))
|
||||
assert json_resp['result'] == 'error'
|
||||
assert json_resp['message'] == 'not found'
|
||||
assert json_resp['message'] == 'User not found for email address: {}'.format('no_user@digital.gov.uk')
|
||||
|
||||
|
||||
def test_get_user_by_email_bad_url_returns_404(notify_api,
|
||||
@@ -436,13 +436,14 @@ def test_send_reset_password_should_send_reset_password_link(notify_api,
|
||||
with notify_api.test_request_context():
|
||||
with notify_api.test_client() as client:
|
||||
mocker.patch('app.celery.tasks.email_reset_password.apply_async')
|
||||
data = json.dumps({'email': sample_user.email_address})
|
||||
auth_header = create_authorization_header(
|
||||
path=url_for('user.send_reset_password', user_id=sample_user.id),
|
||||
path=url_for('user.send_reset_password'),
|
||||
method='POST',
|
||||
request_body={})
|
||||
request_body=data)
|
||||
resp = client.post(
|
||||
url_for('user.send_reset_password', user_id=sample_user.id),
|
||||
data={},
|
||||
url_for('user.send_reset_password'),
|
||||
data=data,
|
||||
headers=[('Content-Type', 'application/json'), auth_header])
|
||||
|
||||
assert resp.status_code == 204
|
||||
@@ -453,21 +454,41 @@ def test_send_reset_password_should_send_reset_password_link(notify_api,
|
||||
queue='send-reset-password')
|
||||
|
||||
|
||||
def test_send_reset_password_should_return_404_when_user_doesnot_exist(notify_api,
|
||||
sample_user,
|
||||
def test_send_reset_password_should_return_400_when_user_doesnot_exist(notify_api,
|
||||
mocker):
|
||||
with notify_api.test_request_context():
|
||||
with notify_api.test_client() as client:
|
||||
user_id = 99999
|
||||
bad_email_address = 'bad@email.gov.uk'
|
||||
data = json.dumps({'email': bad_email_address})
|
||||
auth_header = create_authorization_header(
|
||||
path=url_for('user.send_reset_password', user_id=user_id),
|
||||
path=url_for('user.send_reset_password'),
|
||||
method='POST',
|
||||
request_body={})
|
||||
request_body=data)
|
||||
|
||||
resp = client.post(
|
||||
url_for('user.send_reset_password', user_id=user_id),
|
||||
data={},
|
||||
url_for('user.send_reset_password'),
|
||||
data=data,
|
||||
headers=[('Content-Type', 'application/json'), auth_header])
|
||||
|
||||
assert resp.status_code == 404
|
||||
assert json.loads(resp.get_data(as_text=True))['message'] == 'User not found for id: {}'.format(user_id)
|
||||
assert json.loads(resp.get_data(as_text=True))['message'] == 'User not found for email address: {}'.format(
|
||||
bad_email_address)
|
||||
|
||||
|
||||
def test_send_reset_password_should_return_400_when_data_is_not_email_address(notify_api, mocker):
|
||||
with notify_api.test_request_context():
|
||||
with notify_api.test_client() as client:
|
||||
bad_email_address = 'bad.email.gov.uk'
|
||||
data = json.dumps({'email': bad_email_address})
|
||||
auth_header = create_authorization_header(
|
||||
path=url_for('user.send_reset_password'),
|
||||
method='POST',
|
||||
request_body=data)
|
||||
|
||||
resp = client.post(
|
||||
url_for('user.send_reset_password'),
|
||||
data=data,
|
||||
headers=[('Content-Type', 'application/json'), auth_header])
|
||||
|
||||
assert resp.status_code == 400
|
||||
assert json.loads(resp.get_data(as_text=True))['message'] == {'email': ['Invalid email']}
|
||||
|
||||
Reference in New Issue
Block a user