Correct typo and enable Slack notification test
This commit is contained in:
parent
6a1889787d
commit
e90b08b363
|
@ -217,9 +217,9 @@ def send_rotation_notification(certificate, notification_plugin=None):
|
||||||
notification_plugin.send("rotation", data, [data["owner"]], [])
|
notification_plugin.send("rotation", data, [data["owner"]], [])
|
||||||
status = SUCCESS_METRIC_STATUS
|
status = SUCCESS_METRIC_STATUS
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log_data["message"] = "Unable to send rotation notification for certificate {0} to ownner {1}" \
|
log_data["message"] = "Unable to send rotation notification for certificate {0} to owner {1}" \
|
||||||
.format(certificate.name, data["owner"])
|
.format(certificate.name, data["owner"])
|
||||||
current_app.logger.error(log_data)
|
current_app.logger.error(log_data, exc_info=True)
|
||||||
sentry.captureException()
|
sentry.captureException()
|
||||||
|
|
||||||
metrics.send(
|
metrics.send(
|
||||||
|
|
|
@ -1,3 +1,10 @@
|
||||||
|
from datetime import timedelta
|
||||||
|
|
||||||
|
import arrow
|
||||||
|
|
||||||
|
from lemur.tests.factories import NotificationFactory, CertificateFactory
|
||||||
|
|
||||||
|
|
||||||
def test_formatting(certificate):
|
def test_formatting(certificate):
|
||||||
from lemur.plugins.lemur_slack.plugin import create_expiration_attachments
|
from lemur.plugins.lemur_slack.plugin import create_expiration_attachments
|
||||||
from lemur.certificates.schemas import certificate_notification_output_schema
|
from lemur.certificates.schemas import certificate_notification_output_schema
|
||||||
|
@ -27,32 +34,33 @@ def get_options():
|
||||||
return [
|
return [
|
||||||
{"name": "interval", "value": 10},
|
{"name": "interval", "value": 10},
|
||||||
{"name": "unit", "value": "days"},
|
{"name": "unit", "value": "days"},
|
||||||
|
{"name": "webhook", "value": "https://slack.com/api/api.test"},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
# Currently disabled as we have no good way to mock Slack webhooks
|
def test_send_expiration_notification():
|
||||||
# def test_send_expiration_notification():
|
from lemur.notifications.messaging import send_expiration_notifications
|
||||||
# from lemur.notifications.messaging import send_expiration_notifications
|
|
||||||
# from lemur.tests.factories import CertificateFactory
|
notification = NotificationFactory(plugin_name="slack-notification")
|
||||||
#
|
notification.options = get_options()
|
||||||
# now = arrow.utcnow()
|
|
||||||
# in_ten_days = now + timedelta(days=10, hours=1) # a bit more than 10 days since we'll check in the future
|
now = arrow.utcnow()
|
||||||
# certificate = CertificateFactory()
|
in_ten_days = now + timedelta(days=10, hours=1) # a bit more than 10 days since we'll check in the future
|
||||||
# notification = NotificationFactory(plugin_name="slack-notification")
|
|
||||||
#
|
certificate = CertificateFactory()
|
||||||
# certificate.not_after = in_ten_days
|
certificate.not_after = in_ten_days
|
||||||
# certificate.notifications.append(notification)
|
certificate.notifications.append(notification)
|
||||||
# certificate.notifications[0].options = get_options()
|
|
||||||
#
|
assert send_expiration_notifications([]) == (2, 0)
|
||||||
# assert send_expiration_notifications([]) == (2, 0)
|
|
||||||
|
|
||||||
|
|
||||||
# Currently disabled as we have no good way to mock Slack webhooks
|
# Currently disabled as the Slack plugin doesn't support this type of notification
|
||||||
# def test_send_rotation_notification(endpoint, source_plugin):
|
# def test_send_rotation_notification(endpoint, source_plugin):
|
||||||
# from lemur.notifications.messaging import send_rotation_notification
|
# from lemur.notifications.messaging import send_rotation_notification
|
||||||
# from lemur.deployment.service import rotate_certificate
|
# from lemur.deployment.service import rotate_certificate
|
||||||
#
|
#
|
||||||
# notification = NotificationFactory(plugin_name="slack-notification")
|
# notification = NotificationFactory(plugin_name="slack-notification")
|
||||||
|
# notification.options = get_options()
|
||||||
#
|
#
|
||||||
# new_certificate = CertificateFactory()
|
# new_certificate = CertificateFactory()
|
||||||
# rotate_certificate(endpoint, new_certificate)
|
# rotate_certificate(endpoint, new_certificate)
|
||||||
|
|
Loading…
Reference in New Issue