diff --git a/docs/development/journalist_api.rst b/docs/development/journalist_api.rst index 677ee42bfb..b055ead7f8 100644 --- a/docs/development/journalist_api.rst +++ b/docs/development/journalist_api.rst @@ -284,6 +284,8 @@ Response 200 (application/json): "filename": "3-famished_sheep-reply.gpg", "is_deleted_by_source": false, "journalist_username": "journalist", + "journalist_first_name": "Bob", + "journalist_last_name": "Smith", "journalist_uuid": "a2405127-1c9e-4a3a-80ea-95f6a71e5738", "reply_url": "/api/v1/sources/f381dbb4-4bb5-451a-801a-e961461af6e5/replies/98cc4ed6-6ac5-4867-b144-f97d0497f2c1", "size": 1116, @@ -295,6 +297,8 @@ Response 200 (application/json): "is_deleted_by_source": false, "journalist_username": "journalist", "journalist_uuid": "a2405127-1c9e-4a3a-80ea-95f6a71e5738", + "journalist_first_name": "Bob", + "journalist_last_name": "Smith", "reply_url": "/api/v1/sources/f381dbb4-4bb5-451a-801a-e961461af6e5/replies/2863e3ec-66c8-4b74-ba43-615c805be4da", "size": 1116, "source_url": "/api/v1/sources/f381dbb4-4bb5-451a-801a-e961461af6e5", @@ -321,6 +325,8 @@ Response 200 (application/json): "is_deleted_by_source": false, "journalist_username": "journalist", "journalist_uuid": "a2405127-1c9e-4a3a-80ea-95f6a71e5738", + "journalist_first_name": "Bob", + "journalist_last_name": "Smith", "reply_url": "/api/v1/sources/f381dbb4-4bb5-451a-801a-e961461af6e5/replies/98cc4ed6-6ac5-4867-b144-f97d0497f2c1", "size": 1116, "source_url": "/api/v1/sources/f381dbb4-4bb5-451a-801a-e961461af6e5", @@ -597,6 +603,8 @@ Response 200: "is_deleted_by_source": false, "journalist_username": "journalist", "journalist_uuid": "a2405127-1c9e-4a3a-80ea-95f6a71e5738", + "journalist_first_name": "Bob", + "journalist_last_name": "Smith", "reply_url": "/api/v1/sources/f381dbb4-4bb5-451a-801a-e961461af6e5/replies/98cc4ed6-6ac5-4867-b144-f97d0497f2c1", "size": 1116, "source_url": "/api/v1/sources/f381dbb4-4bb5-451a-801a-e961461af6e5", @@ -607,6 +615,8 @@ Response 200: "is_deleted_by_source": false, "journalist_username": "journalist", "journalist_uuid": "a2405127-1c9e-4a3a-80ea-95f6a71e5738", + "journalist_first_name": "Bob", + "journalist_last_name": "Smith", "reply_url": "/api/v1/sources/f381dbb4-4bb5-451a-801a-e961461af6e5/replies/2863e3ec-66c8-4b74-ba43-615c805be4da", "size": 1116, "source_url": "/api/v1/sources/f381dbb4-4bb5-451a-801a-e961461af6e5", @@ -617,6 +627,8 @@ Response 200: "is_deleted_by_source": false, "journalist_username": "journalist", "journalist_uuid": "a2405127-1c9e-4a3a-80ea-95f6a71e5738", + "journalist_first_name": "Bob", + "journalist_last_name": "Smith", "reply_url": "/api/v1/sources/06bfd5ba-ed6a-4850-b713-4e6940b74931/replies/33b35f6e-b43e-4ad5-a24b-37fd1916ad75", "size": 1116, "source_url": "/api/v1/sources/06bfd5ba-ed6a-4850-b713-4e6940b74931", @@ -627,6 +639,8 @@ Response 200: "is_deleted_by_source": false, "journalist_username": "journalist", "journalist_uuid": "a2405127-1c9e-4a3a-80ea-95f6a71e5738", + "journalist_first_name": "Bob", + "journalist_last_name": "Smith", "reply_url": "/api/v1/sources/06bfd5ba-ed6a-4850-b713-4e6940b74931/replies/6fad52dd-bc55-42aa-96da-4636644fb3e2", "size": 1116, "source_url": "/api/v1/sources/06bfd5ba-ed6a-4850-b713-4e6940b74931", @@ -656,4 +670,6 @@ Response 200: "last_login": "2018-07-09T20:29:41.696782Z", "username": "journalist", "uuid": "a2405127-1c9e-4a3a-80ea-95f6a71e5738" + "first_name": "Bob", + "last_name": "Smith", } diff --git a/securedrop/models.py b/securedrop/models.py index e8e39bea82..fcf203098f 100644 --- a/securedrop/models.py +++ b/securedrop/models.py @@ -288,6 +288,8 @@ def to_json(self): 'filename': self.filename, 'size': self.size, 'journalist_username': self.journalist.username, + 'journalist_first_name': self.journalist.first_name, + 'journalist_last_name': self.journalist.last_name, 'journalist_uuid': self.journalist.uuid, 'uuid': self.uuid, 'is_deleted_by_source': self.deleted_by_source, @@ -704,7 +706,9 @@ def to_json(self): 'username': self.username, 'last_login': self.last_access.isoformat() + 'Z', 'is_admin': self.is_admin, - 'uuid': self.uuid + 'uuid': self.uuid, + 'first_name': self.first_name, + 'last_name': self.last_name } return json_user diff --git a/securedrop/tests/conftest.py b/securedrop/tests/conftest.py index cebf038a6d..f0fe007ac5 100644 --- a/securedrop/tests/conftest.py +++ b/securedrop/tests/conftest.py @@ -167,7 +167,9 @@ def test_journo(journalist_app): 'password': password, 'otp_secret': otp_secret, 'id': user.id, - 'uuid': user.uuid} + 'uuid': user.uuid, + 'first_name': user.first_name, + 'last_name': user.last_name} @pytest.fixture(scope='function') diff --git a/securedrop/tests/test_journalist_api.py b/securedrop/tests/test_journalist_api.py index ffe06c438a..3b34d04671 100644 --- a/securedrop/tests/test_journalist_api.py +++ b/securedrop/tests/test_journalist_api.py @@ -464,6 +464,10 @@ def test_authorized_user_can_get_single_reply(journalist_app, test_files, reply.journalist.username assert response.json['journalist_uuid'] == \ reply.journalist.uuid + assert response.json['journalist_first_name'] == \ + reply.journalist.first_name + assert response.json['journalist_last_name'] == \ + reply.journalist.last_name assert response.json['is_deleted_by_source'] is False assert response.json['filename'] == \ test_files['source'].replies[0].filename @@ -576,6 +580,8 @@ def test_authorized_user_can_get_current_user_endpoint(journalist_app, assert response.json['is_admin'] is False assert response.json['username'] == test_journo['username'] assert response.json['uuid'] == test_journo['journalist'].uuid + assert response.json['first_name'] == test_journo['journalist'].first_name + assert response.json['last_name'] == test_journo['journalist'].last_name def test_request_with_missing_auth_header_triggers_403(journalist_app):