Пример #1
0
def test_send_expiration_summary_notification(certificate, notification, notification_plugin):
    from lemur.notifications.messaging import send_security_expiration_summary
    verify_sender_email()

    # 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
    create_cert_that_expires_in_days(14)
    create_cert_that_expires_in_days(12)
    create_cert_that_expires_in_days(9)
    create_cert_that_expires_in_days(7)
    create_cert_that_expires_in_days(7)
    create_cert_that_expires_in_days(2)
    create_cert_that_expires_in_days(30)
    create_cert_that_expires_in_days(15)
    create_cert_that_expires_in_days(20)
    create_cert_that_expires_in_days(1)
    create_cert_that_expires_in_days(100)

    assert send_security_expiration_summary([])
Пример #2
0
def security_expiration_summary(exclude):
    """
    Sends a summary email with info on all expiring certs (that match the configured expiry intervals).

    :return:
    """
    status = FAILURE_METRIC_STATUS
    try:
        print("Starting to notify security team about expiring certificates!")
        success = send_security_expiration_summary(exclude)
        print(
            f"Finished notifying security team about expiring certificates! Success: {success}"
        )
        if success:
            status = SUCCESS_METRIC_STATUS
    except Exception:
        capture_exception()

    metrics.send(
        "security_expiration_notification_job", "counter", 1, metric_tags={"status": status}
    )