def test_render(certificate, endpoint): from lemur.certificates.schemas import certificate_notification_output_schema new_cert = CertificateFactory() new_cert.replaces.append(certificate) data = { 'certificates': [certificate_notification_output_schema.dump(certificate).data], 'options': [{ 'name': 'interval', 'value': 10 }, { 'name': 'unit', 'value': 'days' }] } template = env.get_template('{}.html'.format('expiration')) with open(os.path.join(dir_path, 'expiration-rendered.html'), 'w') as f: body = template.render( dict(message=data, hostname='lemur.test.example.com')) f.write(body) template = env.get_template('{}.html'.format('rotation')) certificate.endpoints.append(endpoint) with open(os.path.join(dir_path, 'rotation-rendered.html'), 'w') as f: body = template.render( dict(certificate=certificate_notification_output_schema.dump( certificate).data, hostname='lemur.test.example.com')) f.write(body)
def test_render(certificate, endpoint): from lemur.certificates.schemas import certificate_notification_output_schema new_cert = CertificateFactory() new_cert.replaces.append(certificate) data = { 'certificates': [certificate_notification_output_schema.dump(certificate).data], 'options': [{'name': 'interval', 'value': 10}, {'name': 'unit', 'value': 'days'}] } template = env.get_template('{}.html'.format('expiration')) with open(os.path.join(dir_path, 'expiration-rendered.html'), 'w') as f: body = template.render(dict(message=data, hostname='lemur.test.example.com')) f.write(body) template = env.get_template('{}.html'.format('rotation')) certificate.endpoints.append(endpoint) with open(os.path.join(dir_path, 'rotation-rendered.html'), 'w') as f: body = template.render( dict( certificate=certificate_notification_output_schema.dump(certificate).data, hostname='lemur.test.example.com' ) ) f.write(body)
def test_render(certificate, endpoint): from lemur.certificates.schemas import certificate_notification_output_schema new_cert = CertificateFactory() new_cert.replaces.append(certificate) certificates = [certificate_notification_output_schema.dump(certificate).data] template = env.get_template('{}.html'.format('expiration')) with open(os.path.join(dir_path, 'expiration-rendered.html'), 'w') as f: body = template.render(dict(certificates=certificates, hostname='lemur.test.example.com')) f.write(body) template = env.get_template('{}.html'.format('rotation')) certificate.endpoints.append(endpoint) with open(os.path.join(dir_path, 'rotation-rendered.html'), 'w') as f: body = template.render( dict( certificate=certificate_notification_output_schema.dump(certificate).data, hostname='lemur.test.example.com' ) ) f.write(body)
def send(event_type, message, targets, options, **kwargs): """ Configures all Lemur email messaging :param event_type: :param options: """ subject = 'Notification: Lemur' if event_type == 'expiration': subject = 'Notification: SSL Certificate Expiration ' # jinja template depending on type template = env.get_template('{}.html'.format(event_type)) body = template.render(dict(messages=message, hostname=current_app.config.get('LEMUR_HOSTNAME'))) s_type = current_app.config.get("LEMUR_EMAIL_SENDER", 'ses').lower() if s_type == 'ses': conn = boto.connect_ses() conn.send_email(current_app.config.get("LEMUR_EMAIL"), subject, body, targets, format='html') elif s_type == 'smtp': msg = Message(subject, recipients=targets) msg.body = "" # kinda a weird api for sending html emails msg.html = body smtp_mail.send(msg) else: current_app.logger.error("No mail carrier specified, notification emails were not able to be sent!")
def test_render(): messages = [{ 'name': 'a-really-really-long-certificate-name', 'owner': '*****@*****.**', 'not_after': '2015-12-14 23:59:59' }] * 10 template = env.get_template('{}.html'.format('expiration')) body = template.render(dict(messages=messages, hostname='lemur.test.example.com'))
def render_html(template_name, message): """ Renders the html for our email notification. :param template_name: :param message: :return: """ template = env.get_template('{}.html'.format(template_name)) return template.render(dict(message=message, hostname=current_app.config.get('LEMUR_HOSTNAME')))
def render_html(template_name, message): """ Renders the html for our email notification. :param template_name: :param message: :return: """ template = env.get_template('{}.html'.format(template_name)) return template.render(dict(message=message, hostname=current_app.config.get('LEMUR_HOSTNAME')))
def test_render(): messages = [ { "name": "a-really-really-long-certificate-name", "owner": "*****@*****.**", "not_after": "2015-12-14 23:59:59", } ] * 10 template = env.get_template("{}.html".format("expiration")) body = template.render(dict(messages=messages, hostname="lemur.test.example.com")) with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "email.html"), "w+") as f: f.write(body.encode("utf8"))
def render_html(template_name, options, certificates): """ Renders the html for our email notification. :param template_name: :param options: :param certificates: :return: """ message = {"options": options, "certificates": certificates} template = env.get_template("{}.html".format(template_name)) return template.render( dict(message=message, hostname=current_app.config.get("LEMUR_HOSTNAME")))
def test_render(): messages = [{ 'name': 'a-really-really-long-certificate-name', 'owner': '*****@*****.**', 'not_after': '2015-12-14 23:59:59' }] * 10 template = env.get_template('{}.html'.format('expiration')) body = template.render( dict(messages=messages, hostname='lemur.test.example.com')) with open( os.path.join(os.path.dirname(os.path.abspath(__file__)), 'email.html'), 'w+') as f: f.write(body.encode('utf8'))
def test_render(certificate, endpoint): from lemur.certificates.schemas import certificate_notification_output_schema new_cert = CertificateFactory() new_cert.replaces.append(certificate) data = { "certificates": [certificate_notification_output_schema.dump(certificate).data], "options": [ { "name": "interval", "value": 10 }, { "name": "unit", "value": "days" }, ], } template = env.get_template("{}.html".format("expiration")) body = template.render( dict(message=data, hostname="lemur.test.example.com")) template = env.get_template("{}.html".format("rotation")) certificate.endpoints.append(endpoint) body = template.render( dict( certificate=certificate_notification_output_schema.dump( certificate).data, hostname="lemur.test.example.com", ))
def send(event_type, message, targets, options, **kwargs): """ Configures all Lemur email messaging :param event_type: :param options: """ subject = 'Notification: Lemur' if event_type == 'expiration': subject = 'Notification: SSL Certificate Expiration ' # jinja template depending on type template = env.get_template('{}.html'.format(event_type)) body = template.render( dict(messages=message, hostname=current_app.config.get('LEMUR_HOSTNAME'))) s_type = current_app.config.get("LEMUR_EMAIL_SENDER", 'ses').lower() if s_type == 'ses': conn = boto.connect_ses() conn.send_email(current_app.config.get("LEMUR_EMAIL"), subject, body, targets, format='html') elif s_type == 'smtp': msg = Message(subject, recipients=targets) msg.body = "" # kinda a weird api for sending html emails msg.html = body smtp_mail.send(msg) else: current_app.logger.error( "No mail carrier specified, notification emails were not able to be sent!" )