def create_cert_that_expires_in_days(days, serial=None, domains=None, owner=None): import random from random import randrange from string import ascii_lowercase now = arrow.utcnow() not_after = now + timedelta( days=days, hours=1) # a bit more than specified since we'll check in the future certificate = CertificateFactory() certificate.not_after = not_after certificate.notify = True certificate.owner = ''.join( random.choice(ascii_lowercase) for _ in range(10)) + '@example.com' endpoints = [] for i in range(0, randrange(0, 5)): endpoints.append(EndpointFactory()) certificate.endpoints = endpoints if serial: certificate.serial = serial if owner: certificate.owner = owner if domains: certificate.domains = domains return certificate
def test_send_rotation_notification(notification_plugin, certificate): from lemur.notifications.messaging import send_rotation_notification verify_sender_email() new_cert = CertificateFactory() new_cert.replaces.append(certificate) assert send_rotation_notification(new_cert) new_cert.endpoints = [EndpointFactory()] assert send_rotation_notification(new_cert)
def test_send_rotation_notification(certificate, endpoint, source_plugin): from lemur.notifications.messaging import send_rotation_notification from lemur.deployment.service import rotate_certificate new_certificate = CertificateFactory() rotate_certificate(endpoint, new_certificate) new_certificate.replaces.append(certificate) assert endpoint.certificate == new_certificate verify_sender_email() assert send_rotation_notification(new_certificate) new_certificate.endpoints = [EndpointFactory()] assert send_rotation_notification(new_certificate)
def create_cert_that_expires_in_days(days): from random import randrange now = arrow.utcnow() not_after = now + timedelta(days=days, hours=1) # a bit more than specified since we'll check in the future certificate = CertificateFactory() certificate.not_after = not_after certificate.notify = True endpoints = [] for i in range(0, randrange(0, 5)): endpoints.append(EndpointFactory()) certificate.endpoints = endpoints return certificate