-
Notifications
You must be signed in to change notification settings - Fork 16
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
fix: change base class for JwtAuthenticationError #433
Conversation
Hi @robrap, could i please get your review here? |
a2147bc
to
6d17379
Compare
@@ -34,7 +34,7 @@ class JwtSessionUserMismatchError(JwtAuthenticationError): | |||
pass | |||
|
|||
|
|||
class JwtUserEmailMismatchError(JwtAuthenticationError): | |||
class JwtUserEmailMismatchError(exceptions.AuthenticationFailed): |
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.
- Could we change the base class instead?
class JwtAuthenticationError(exceptions.AuthenticationFailed):
- Is there any additional assertion we could add to a test to ensure that the right type of exception is being used?
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.
Could we change the base class instead?
Yes, done.
Is there any additional assertion we could add to a test to ensure that the right type of exception is being used?
Since AuthenticationFailed
is a known exception to the default exception handler therefore it gets handled by the exception handler and we only get a 401 Unauthorized
response. Exception is not being propagated up and we are not getting it in the test. So, I don't think we can assert the exception type.
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.
Although it is unlikely that someone will break this, a unit test that creates an instance of JwtSessionUserMismatchError
and asserts that it is also an instance of AuthenticationFailed
would prevent regressions. I'm not sure if it is worth it, but it is also very quick to implement. I'll leave it to you to decide.
87c7b47
to
71c5b64
Compare
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.
I left a unit test idea, but I'll leave that to you to decide. See #433 (comment). Thanks.
71c5b64
to
0ca3546
Compare
0ca3546
to
9a75d40
Compare
Thanks, I have added the test |
Description:
Issue: When JwtAuthentication class raises
JwtUserEmailMismatchError
custom exception, it is not identified by the default exception handler of rest framework, therefore, returnsresponse = None
and hence we get500 Server error
.Fix: This PR handles this issue by subclassing
JwtAuthenticationError
from theAuthenticationFailed
exception which is a known exception and will be handled by the default exception handler.JIRA:
VAN-1694
Additional Details
Reviewers:
Merge checklist:
Post merge:
finished.