Create a signal for expired API tokens.
Review Request #12589 — Created Sept. 12, 2022 and submitted
Information | |
---|---|
maubin | |
Djblets | |
release-3.x | |
12591 | |
Reviewers | |
djblets | |
Create a signal for expired API tokens. This signal gets triggered when an
expired API token is used for authentication.We also switch from using naive date objects to timezone-aware date objects in
API token related unit tests to ensure that test data can be properly compared
to the API token's timezone-aware date objects.
- Created unit tests for the new signal and ran tests in
djblets/webapi/tests/test_signals.py
- Manually tested authenticating with expired and non expired tokens, confirmed
that appropriate notifications were sent and triggered by the signal.
Summary |
---|
Description | From | Last Updated |
---|---|---|
Can we make it so we set this key here in djblets instead of in Review Board? It seems fragile … |
|
|
The summary has to be one line without wrapping. |
|
|
Too many "d"s. |
|
|
pytz is a third-party library, so it needs to be in the second import group. Although, we don't need it … |
|
|
Can we update this to explicitly specify the class that's being tested? |
|
|
No blank line here. |
|
|
This should be outside the try, since if it were to fail (highly theoretical), the disconnect would have nothing to … |
|
-
-
djblets/webapi/auth/backends/api_tokens.py (Diff revision 1) Can we make it so we set this key here in djblets instead of in Review Board? It seems fragile and confusing to have this responsibility split between the two packages.
We might also want to change "email" to "notification" just to be a bit more agnostic as to how the notification occurs.

Change Summary:
No longer checks the token to see if an expired notification has already been sent.
Description: |
|
|||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Testing Done: |
|
|||||||||||||||||||||||||||||||||
Commits: |
|
|||||||||||||||||||||||||||||||||
Diff: |
Revision 2 (+180 -16) |
Checks run (2 succeeded)
-
-
-
-
djblets/webapi/tests/test_api_auth_backend.py (Diff revision 2) pytz
is a third-party library, so it needs to be in the second import group.Although, we don't need it for
UTC
. Django has its own thing we can use. -
djblets/webapi/tests/test_signals.py (Diff revision 2) Can we update this to explicitly specify the class that's being tested?
-

Commits: |
|
||||||
---|---|---|---|---|---|---|---|
Diff: |
Revision 3 (+180 -10) |
Checks run (2 succeeded)
-
-
djblets/webapi/tests/test_signals.py (Diff revision 3) This should be outside the
try
, since if it were to fail (highly theoretical), the disconnect would have nothing to try to disconnect.

Change Summary:
Moved the
signal.connect()
calls outside of the try blocks.
Commits: |
|
||||||
---|---|---|---|---|---|---|---|
Diff: |
Revision 4 (+194 -20) |