-
Notifications
You must be signed in to change notification settings - Fork 267
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
Added support to generate token of project #500
Added support to generate token of project #500
Conversation
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.
Here is some feedback:
- It seems that you also have code from your last pull request into this very one.
- Some stuff I put in inline comments.
Thanks!
method_decorators = [need_auth] | ||
|
||
def get(self, project): | ||
print(project) |
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.
It seems that this print shouldn't be here :-)
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.
You are right!
if not project: | ||
return "Not Found", 404 | ||
token = project.generate_token() | ||
print(token) |
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.
Extraneous print statement.
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.
you are right, only for testing
restful_api.add_resource(ProjectsHandler, "/projects") | ||
restful_api.add_resource(ProjectHandler, "/projects/<string:project_id>") | ||
restful_api.add_resource(TokenHandler, "/token/<string:project_id>") |
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.
Should we put this at /projects/:id/token
instead?
headers={"Authorization": "Basic %s" % decoded_resp["token"]}, | ||
) | ||
|
||
self.assertEqual(200, resp.status_code) |
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.
It seems to me that we should also test that the token can be used to login.
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.
Ok, I thought I was tested when the token was implemented
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.
It should have been, but my review was too weak :(
Thanks for your feedback it is very useful :) I don't know how to modify your fist advice "it seems that you also have code from your last pull request into this very one". I created the branch from a feature-request branch instead of master one. How can I change it? |
I believe the simplest way is to re-create a branch from master ( |
Now with endpoint /api/token/<project_id> you will get a {"token": "tokenofproject"} that you can use in GET "/api/project" with header "Authenthication: token ".
Hope it helps!
Issue: #412