Code cleanup
This commit is contained in:
parent
d6075ebc11
commit
4f552cb636
@ -1462,7 +1462,7 @@ AWS (Destination)
|
||||
Uses AWS IAM as a destination for Lemur generated certificates. Support a multi-account deployment.
|
||||
|
||||
|
||||
AWS (Notification)
|
||||
AWS (SNS Notification)
|
||||
-----
|
||||
|
||||
:Authors:
|
||||
|
@ -107,6 +107,7 @@ def send_plugin_notification(event_type, data, recipients, notification):
|
||||
}
|
||||
status = FAILURE_METRIC_STATUS
|
||||
try:
|
||||
current_app.logger.debug(log_data)
|
||||
notification.plugin.send(event_type, data, recipients, notification.options)
|
||||
status = SUCCESS_METRIC_STATUS
|
||||
except Exception as e:
|
||||
@ -203,6 +204,7 @@ def send_default_notification(notification_type, data, targets, notification_opt
|
||||
)
|
||||
|
||||
try:
|
||||
current_app.logger.debug(log_data)
|
||||
# we need the notification.options here because the email templates utilize the interval/unit info
|
||||
notification_plugin.send(notification_type, data, targets, notification_options)
|
||||
status = SUCCESS_METRIC_STATUS
|
||||
@ -288,8 +290,6 @@ def needs_notification(certificate):
|
||||
raise Exception(
|
||||
f"Invalid base unit for expiration interval: {unit}"
|
||||
)
|
||||
print(f"Does cert {certificate.name} need a notification {notification.label}? Actual: {days}, "
|
||||
f"configured: {interval}") # TODO REMOVE
|
||||
if days == interval:
|
||||
notifications.append(notification)
|
||||
return notifications
|
||||
|
@ -3,7 +3,7 @@
|
||||
:platform: Unix
|
||||
:copyright: (c) 2020 by Netflix Inc., see AUTHORS for more
|
||||
:license: Apache, see LICENSE for more details.
|
||||
.. moduleauthor:: Kevin Glisson <kglisson@netflix.com>
|
||||
.. moduleauthor:: Jasmine Schladen <jschladen@netflix.com>
|
||||
"""
|
||||
import json
|
||||
|
||||
|
@ -107,13 +107,11 @@ class EmailNotificationPlugin(ExpirationNotificationPlugin):
|
||||
|
||||
s_type = current_app.config.get("LEMUR_EMAIL_SENDER", "ses").lower()
|
||||
|
||||
print(f"Would send {s_type} email to {targets}: {subject}")
|
||||
if s_type == "ses":
|
||||
send_via_ses(subject, body, targets)
|
||||
|
||||
# if s_type == "ses":
|
||||
# send_via_ses(subject, body, targets)
|
||||
|
||||
# elif s_type == "smtp":
|
||||
# send_via_smtp(subject, body, targets)
|
||||
elif s_type == "smtp":
|
||||
send_via_smtp(subject, body, targets)
|
||||
|
||||
@staticmethod
|
||||
def filter_recipients(options, excluded_recipients, **kwargs):
|
||||
|
@ -81,10 +81,10 @@ def test_send_pending_failure_notification(user, pending_certificate, async_issu
|
||||
def test_filter_recipients(certificate, endpoint):
|
||||
from lemur.plugins.lemur_email.plugin import EmailNotificationPlugin
|
||||
|
||||
options = [{"name": "recipients", "value": "security@netflix.com,bob@netflix.com,joe@netflix.com"}]
|
||||
assert EmailNotificationPlugin.filter_recipients(options, []) == ["security@netflix.com", "bob@netflix.com",
|
||||
"joe@netflix.com"]
|
||||
assert EmailNotificationPlugin.filter_recipients(options, ["security@netflix.com"]) == ["bob@netflix.com",
|
||||
"joe@netflix.com"]
|
||||
assert EmailNotificationPlugin.filter_recipients(options, ["security@netflix.com", "bob@netflix.com",
|
||||
"joe@netflix.com"]) == []
|
||||
options = [{"name": "recipients", "value": "security@example.com,bob@example.com,joe@example.com"}]
|
||||
assert EmailNotificationPlugin.filter_recipients(options, []) == ["security@example.com", "bob@example.com",
|
||||
"joe@example.com"]
|
||||
assert EmailNotificationPlugin.filter_recipients(options, ["security@example.com"]) == ["bob@example.com",
|
||||
"joe@example.com"]
|
||||
assert EmailNotificationPlugin.filter_recipients(options, ["security@example.com", "bob@example.com",
|
||||
"joe@example.com"]) == []
|
||||
|
Loading…
Reference in New Issue
Block a user