From 065e4d3964d5e1f7276b7a1511e7879266a6cfb7 Mon Sep 17 00:00:00 2001 From: Jasmine Schladen Date: Tue, 8 Dec 2020 11:46:55 -0800 Subject: [PATCH] Add new configuration for summary email intervals --- docs/administration.rst | 2 +- lemur/notifications/messaging.py | 7 +------ lemur/tests/test_messaging.py | 5 ++--- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/docs/administration.rst b/docs/administration.rst index 4c755e7b..fb576b9c 100644 --- a/docs/administration.rst +++ b/docs/administration.rst @@ -363,7 +363,7 @@ disabled by default; to enable it, you must set the option ``--notify`` (when us If you enable the Celery or cron task to send this notification type, Lemur will send a summary of all certificates with upcoming expiration date that matches one of the intervals configured in the -``LEMUR_SECURITY_TEAM_EMAIL_INTERVALS`` configuration parameter (with the same fallbacks as noted above). +``LEMUR_EXPIRATION_SUMMARY_EMAIL_INTERVALS`` configuration parameter (with a fallback of 14 days). Note that certificates will be included in this summary even if they do not have any associated notifications. This notification type also supports the same ``--exclude`` and ``EXCLUDE_CN_FROM_NOTIFICATION`` options as expiration emails. diff --git a/lemur/notifications/messaging.py b/lemur/notifications/messaging.py index e121e09a..b472a5f7 100644 --- a/lemur/notifications/messaging.py +++ b/lemur/notifications/messaging.py @@ -70,12 +70,7 @@ def get_certificates_for_security_summary_email(exclude=None): :return: """ now = arrow.utcnow() - expiration_summary_intervals = current_app.config.get("LEMUR_SECURITY_TEAM_EMAIL_INTERVALS", # first priority - current_app.config.get( # second priority - "LEMUR_DEFAULT_EXPIRATION_NOTIFICATION_INTERVALS", - [30, 15, 2] # third priority - ) - ) + expiration_summary_intervals = current_app.config.get("LEMUR_EXPIRATION_SUMMARY_EMAIL_INTERVALS", [14]) max_not_after = now + timedelta(days=max(expiration_summary_intervals) + 1) q = ( diff --git a/lemur/tests/test_messaging.py b/lemur/tests/test_messaging.py index 85032c00..c1c9b24a 100644 --- a/lemur/tests/test_messaging.py +++ b/lemur/tests/test_messaging.py @@ -119,10 +119,9 @@ def test_send_expiration_summary_notification(certificate, notification, notific # we don't actually test the email contents, but adding an assortment of certs here is useful for step debugging # to confirm the produced email body looks like we expect + for i in range(1, 6): + create_cert_that_expires_in_days(14) create_cert_that_expires_in_days(2) - create_cert_that_expires_in_days(2) - create_cert_that_expires_in_days(2) - create_cert_that_expires_in_days(30) create_cert_that_expires_in_days(30) create_cert_that_expires_in_days(15) create_cert_that_expires_in_days(20)