API - update picture endpoint

This commit is contained in:
Sam 2019-07-21 22:09:43 +02:00
parent 03d385500e
commit edf4f4e4ca
3 changed files with 3 additions and 46 deletions

View File

@ -290,19 +290,12 @@
<dl class="field-list simple"> <dl class="field-list simple">
<dt class="field-odd">Parameters</dt> <dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple"> <dd class="field-odd"><ul class="simple">
<li><p><strong>auth_user_id</strong> (<em>integer</em>) authenticate user id (from JSON Web Token)</p></li>
<li><p><strong>user_id</strong> (<em>integer</em>) user id</p></li> <li><p><strong>user_id</strong> (<em>integer</em>) user id</p></li>
</ul> </ul>
</dd> </dd>
<dt class="field-even">Status Codes</dt> <dt class="field-even">Status Codes</dt>
<dd class="field-even"><ul class="simple"> <dd class="field-even"><ul class="simple">
<li><p><a class="reference external" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1">200 OK</a> success</p></li> <li><p><a class="reference external" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1">200 OK</a> success</p></li>
<li><p><a class="reference external" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.2">401 Unauthorized</a> <ul>
<li><p>Provide a valid auth token.</p></li>
<li><p>Signature expired. Please log in again.</p></li>
<li><p>Invalid token. Please log in again.</p></li>
</ul>
</p></li>
<li><p><a class="reference external" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5">404 Not Found</a> <ul> <li><p><a class="reference external" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5">404 Not Found</a> <ul>
<li><p>User does not exist</p></li> <li><p>User does not exist</p></li>
<li><p>No picture.</p></li> <li><p>No picture.</p></li>

View File

@ -210,22 +210,7 @@ def test_decode_auth_token(app, user_1):
def test_user_no_picture(app, user_1): def test_user_no_picture(app, user_1):
client = app.test_client() client = app.test_client()
resp_login = client.post( response = client.get('/api/users/1/picture')
'/api/auth/login',
data=json.dumps(dict(
email='test@test.com',
password='12345678'
)),
content_type='application/json'
)
response = client.get(
'/api/users/1/picture',
headers=dict(
Authorization='Bearer ' + json.loads(
resp_login.data.decode()
)['auth_token']
)
)
data = json.loads(response.data.decode()) data = json.loads(response.data.decode())
assert response.status_code == 404 assert response.status_code == 404
@ -235,22 +220,7 @@ def test_user_no_picture(app, user_1):
def test_user_picture_no_user(app, user_1): def test_user_picture_no_user(app, user_1):
client = app.test_client() client = app.test_client()
resp_login = client.post( response = client.get('/api/users/2/picture')
'/api/auth/login',
data=json.dumps(dict(
email='test@test.com',
password='12345678'
)),
content_type='application/json'
)
response = client.get(
'/api/users/2/picture',
headers=dict(
Authorization='Bearer ' + json.loads(
resp_login.data.decode()
)['auth_token']
)
)
data = json.loads(response.data.decode()) data = json.loads(response.data.decode())
assert response.status_code == 404 assert response.status_code == 404

View File

@ -167,8 +167,7 @@ def get_single_user(auth_user_id, user_id):
@users_blueprint.route('/users/<user_id>/picture', methods=['GET']) @users_blueprint.route('/users/<user_id>/picture', methods=['GET'])
@authenticate def get_picture(user_id):
def get_picture(auth_user_id, user_id):
""" get user picture """ get user picture
**Example request**: **Example request**:
@ -185,14 +184,9 @@ def get_picture(auth_user_id, user_id):
HTTP/1.1 200 OK HTTP/1.1 200 OK
Content-Type: image/jpeg Content-Type: image/jpeg
:param integer auth_user_id: authenticate user id (from JSON Web Token)
:param integer user_id: user id :param integer user_id: user id
:statuscode 200: success :statuscode 200: success
:statuscode 401:
- Provide a valid auth token.
- Signature expired. Please log in again.
- Invalid token. Please log in again.
:statuscode 404: :statuscode 404:
- User does not exist - User does not exist
- No picture. - No picture.