FEATURE: notify admins about old credentials (PR #9854)

Security and API keys should be renewed periodically. This additional notification should help admins keep their Discourse safe and secure.

GitHub

      User.real.admins

Could probably do SiteSetting.notify_about_secrets_older_than.to_i.years

Could save a line here with: next if site_setting&.value.blank?

I don’t think we should be testing private methods. A test should stick to the public API surface because this prevents us from refactoring in the future.

In this case I would recommend moving the old_xxx methods to SiteSetting as public and testing using those.

For the title, body etc you can look for the post that was created after the job finishes.

@eviltrout thank you for the feedback. I fixed it. I think that old keys setting is very specific to this problem, so I didn’t want to move that to SiteSettings model. Instead, I extended the test for “execute” method so there is no more need to test private methods.

Minor but instead of two intermediate arrays, because we can just push into an existing array?

Thank you! nice catch, fixed and I will merge that stuff tomorrow in the morning :slight_smile:

Btw I left a small comment in dev about the design of this feature in https://dev.discourse.org/t/automatic-reminder-to-reset-old-machine-generated-secrets/16311/9