Skip to content

Commit

Permalink
added "filename" to reply creation api response
Browse files Browse the repository at this point in the history
  • Loading branch information
heartsucker committed Jan 21, 2019
1 parent b725c81 commit 08e655e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion securedrop/journalist_app/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,8 @@ def all_source_replies(source_uuid):
raise e

return jsonify({'message': 'Your reply has been stored',
'uuid': reply.uuid}), 201
'uuid': reply.uuid,
'filename': reply.filename}), 201

@api.route('/sources/<source_uuid>/replies/<reply_uuid>',
methods=['GET', 'DELETE'])
Expand Down
1 change: 1 addition & 0 deletions securedrop/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@ def throttle_login(cls, user):
def login(cls, username, password, token):
try:
user = Journalist.query.filter_by(username=username).one()
return user
except NoResultFound:
raise InvalidUsernameException(
"invalid username '{}'".format(username))
Expand Down
3 changes: 3 additions & 0 deletions securedrop/tests/test_journalist_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,9 @@ def test_authorized_user_can_add_reply(journalist_app, journalist_api_token,
reply = Reply.query.filter_by(uuid=str(reply_uuid)).one_or_none()
assert reply is not None

# check that the filename is present and correct (#4047)
assert response.json['filename'] == reply.filename

with journalist_app.app_context(): # Now verify everything was saved.
assert reply.journalist_id == test_journo['id']
assert reply.source_id == source_id
Expand Down

0 comments on commit 08e655e

Please sign in to comment.