Skip to content
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

Additional tests for logout (fixes #206). #207

Merged

Conversation

stanislawK
Copy link
Contributor

To test:
make start
make test

@app.route("/", methods=['GET'])
@jwt_required
def protected():
return jsonify({"msg": "That it proteced route"})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would go with "message" (as we would in other situations) I think.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • "that is", not "that it"

assert len(tokens) == 1
assert tokens[0].revoked
assert rv.status_code == HTTPStatus.UNAUTHORIZED
assert response["msg"] == "token has been revoked"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is behavior implemented in endpoint (not related to the test). Biside naming convencion for messages, we should not checking if token was revoked or not manually in every endpoint, as it is now (flask_jwt_extended has method to do it autmomatically). I added #208 targeting that problem.

})
response = rv.get_json()
assert rv.status_code == HTTPStatus.UNAUTHORIZED
assert response["msg"] == "token has been revoked"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

def test_get_protected_route_after_logout(
app, client, protected_route, access_token
):
"""Test access protected route after loggin out."""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logging

@magul
Copy link
Member

magul commented Dec 1, 2019

You have still tests failing here @stanislawK

@stanislawK
Copy link
Contributor Author

You have still tests failing here @stanislawK

@magul I think they should. Bug is in our app, not in tests. That why I added #208 and blocked this pr until issue will be resolved.

Comment on lines 39 to 47
rv = client.delete(
"/auth/logout/", headers={"Authorization": "Bearer {}".format(access_token)}
)
assert rv.status_code == HTTPStatus.OK
rv = client.delete(
"/auth/logout/", headers={"Authorization": "Bearer {}".format(access_token)}
)
tokens = JWTToken.query.all()
response = rv.get_json()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: Could you reaname variables on more meaningful? E.g. rv on response and response ( in response = rv.get_json()) on payload

Comment on lines 56 to 61
rv = client.delete(
"/auth/logout/", headers={"Authorization": "Bearer {}".format(access_token)}
)
assert rv.status_code == HTTPStatus.OK
rv = client.get("/", headers={"Authorization": "Bearer {}".format(access_token)})
response = rv.get_json()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@app.route("/", methods=["GET"])
@jwt_required
def protected():
return jsonify({"message": "That is proteced route"})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

protected

@w1stler
Copy link
Member

w1stler commented Feb 5, 2020

@stanislawK please resolve conflicts & address comments.

Copy link
Contributor

@jacekkalbarczyk jacekkalbarczyk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems legit.

@jacekkalbarczyk jacekkalbarczyk merged commit d1aafdb into CodeForPoznan:master Feb 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants