Send email notifications when a token becomes expired.

Review Request #12591 — Created Sept. 12, 2022 and submitted

Information

Review Board
release-5.0.x

Reviewers

Currently, users do not get notified about expired tokens. With this change, an
email is sent the first time an expired token is used. The email describes when
the token expired and how to create new tokens. If the email was successfully
sent, any subsequent uses of the token do not trigger another email.

This change also fixes up all of the API token email templates by adding date
formatting and fixing some missing URLs. The tests for the templates were also
fixed up.

  • Created unit tests for the expired token emails and ran unit tests in
    reviewboard/notifications/tests/test_email_sending.py
  • Manually tested authenticating with expired and non expired tokens, confirmed
    that appropriate emails were sent.
Summary ID
Send email notifications when a token becomes expired.
c776280c3483ba6eb35f95e8ca56cc0b603e4f3b
Description From Last Updated

'djblets.webapi.signals.webapi_token_deleted' imported but unused Column: 1 Error code: F401

reviewbotreviewbot

continuation line under-indented for visual indent Column: 25 Error code: E128

reviewbotreviewbot

continuation line under-indented for visual indent Column: 25 Error code: E128

reviewbotreviewbot

I think this is meant to say "deleted"?

chipx86chipx86

You can leave off the , None, since that's the default.

chipx86chipx86

This would be better as a boolean, I think.

chipx86chipx86

Can you add some additional checks to verify the display of the timestamps in the content? I noticed none of …

chipx86chipx86

line too long (80 > 79 characters) Column: 80 Error code: E501

reviewbotreviewbot

line too long (80 > 79 characters) Column: 80 Error code: E501

reviewbotreviewbot

line too long (80 > 79 characters) Column: 80 Error code: E501

reviewbotreviewbot

line too long (80 > 79 characters) Column: 80 Error code: E501

reviewbotreviewbot
Checks run (1 failed, 1 succeeded)
flake8 failed.
JSHint passed.

flake8

maubin
maubin
Review request changed
Change Summary:

Checks whether an expired notification has already been sent.

Commits:
Summary ID
Send email notifications when a token becomes expired.
9b8288b530a283b467b7763f4867576b4ca1e2a2
Send email notifications when a token becomes expired.
02beaf6960bc85338a1c4ca41bcdce943b513a73

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

maubin
chipx86
  1. 
      
  2. Show all issues

    I think this is meant to say "deleted"?

  3. Show all issues

    You can leave off the , None, since that's the default.

  4. Show all issues

    This would be better as a boolean, I think.

  5. reviewboard/notifications/tests/test_email_sending.py (Diff revision 4)
     
     
     
     
     
     
     
    Show all issues

    Can you add some additional checks to verify the display of the timestamps in the content?

    I noticed none of our API token e-mails force a timestamp format, but our other templates all do. Inconsistent, which.. fine, it's been that way a while, but for some future-proofing, it'll be good to make sure we have some testing around how it actually ends up rendering.

    In fact, these templates are so small, let's compare the full strings (assertHTMLEqual for the HTML one).

  6. 
      
maubin
Review request changed
Change Summary:
  • Changed expired_notification_sent to a boolean
  • Spruced up the API token email templates by adding date formatting and fixing some missing URLs.
  • Spruced up the tests for the templates by checking the full strings of the text and html templates.
Description:
   

Currently, users do not get notified about expired tokens. With this change, an

    email is sent the first time an expired token is used. The email describes when
    the token expired and how to create new tokens. If the email was successfully
    sent, any subsequent uses of the token do not trigger another email.

  +
  +

This change also fixes up all of the API token email templates by adding date

  + formatting and fixing some missing URLs. The tests for the templates were also
  + fixed up.

Commits:
Summary ID
Send email notifications when a token becomes expired.
ac5d088ae9646d3b353cc14e2dfca19a8de5daae
Send email notifications when a token becomes expired.
c67837f6476fa1c1d5feda35fbedc82aaffd57d8

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

maubin
david
  1. Ship It!
  2. 
      
maubin
Review request changed
Status:
Completed
Change Summary:
Pushed to release-5.0.x (27c2137)