-
Notifications
You must be signed in to change notification settings - Fork 0
Update books.py #32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Update books.py #32
Conversation
@@ -49,11 +49,11 @@ def add_new_book(): | |||
|
|||
|
|||
def get_by_title(book_title): | |||
resp = token_validator(request.headers.get('Authorization')) | |||
resp = token_validator() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The token validation response handling should include tests to verify proper error responses for expired and invalid tokens
@@ -65,7 +65,7 @@ def get_by_title(book_title): | |||
} | |||
return Response(json.dumps(responseObject), 200, mimetype="application/json") | |||
else: | |||
return Response(error_message_helper("Book not found!"), 404, mimetype="application/json") | |||
return Response(error_message_helper(), 404, mimetype="application/json") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add test coverage for the 404 error case when book is not found
return Response(error_message_helper(), 404, mimetype="application/json") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error handling for non-existent books is consistent, but should be tested for both vulnerable and non-vulnerable paths
@@ -49,11 +49,11 @@ def add_new_book(): | |||
|
|||
|
|||
def get_by_title(book_title): | |||
resp = token_validator(request.headers.get('Authorization')) | |||
resp = token_validator() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
token_validator() is called without any arguments but based on the error handling it seems to expect an authorization token parameter
if "expired" in resp: | ||
return Response(error_message_helper(resp), 401, mimetype="application/json") | ||
return Response(error_message_helper(), 401, mimetype="application/json") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
error_message_helper() is called without a message parameter which deviates from the helper function's intended usage pattern
elif "Invalid token" in resp: | ||
return Response(error_message_helper(resp), 401, mimetype="application/json") | ||
return Response(error_message_helper(), 401, mimetype="application/json") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message for invalid token case should be passed to error_message_helper() to provide more specific feedback
@@ -65,7 +65,7 @@ def get_by_title(book_title): | |||
} | |||
return Response(json.dumps(responseObject), 200, mimetype="application/json") | |||
else: | |||
return Response(error_message_helper("Book not found!"), 404, mimetype="application/json") | |||
return Response(error_message_helper(), 404, mimetype="application/json") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing message parameter in error_message_helper() call for 404 response
return Response(error_message_helper(), 404, mimetype="application/json") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 404 error message should include details about which book was not found
No description provided.