diff --git a/lemur/plugins/lemur_email/templates/config.py b/lemur/plugins/lemur_email/templates/config.py index 49729cc7..e10caa55 100644 --- a/lemur/plugins/lemur_email/templates/config.py +++ b/lemur/plugins/lemur_email/templates/config.py @@ -1,5 +1,12 @@ import os +import arrow from jinja2 import Environment, FileSystemLoader loader = FileSystemLoader(searchpath=os.path.dirname(os.path.realpath(__file__))) env = Environment(loader=loader) + + +def human_time(time): + return arrow.get(time).format('dddd, MMMM D, YYYY') + +env.filters['time'] = human_time diff --git a/lemur/plugins/lemur_email/templates/expiration.html b/lemur/plugins/lemur_email/templates/expiration.html index f30df1c0..53b98ad1 100644 --- a/lemur/plugins/lemur_email/templates/expiration.html +++ b/lemur/plugins/lemur_email/templates/expiration.html @@ -7,141 +7,171 @@ Lemur - - -
- - - - + + + + + + + + + + + + + + + + +
- - - - - - {% for message in messages %} - - +
-
-
- Notice: Your TLS certificates are expiring! -
-
-

- Lemur, has noticed that the following certificates are expiring soon, if you rely on these certificates - you should create new certificates to replace the certificates that are expiring. -

-

- Visit https://{{ hostname }}/#/certificates/create to reissue them. -

-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {% if message.domains %} - {% for name in message.domains %} - - - - {% endfor %} - {% else %} + +
+
Name
{{ message.name }}
Owner
{{ message.owner }}
Creator
{{ message.creator }}
Description
{{ message.description }}
Not Before
{{ message.not_before }}
Not After
{{ message.not_after }}
Associated Domains
{{ name }}
+ + + + + - - - - -
+ + + + - - {% endfor %} -
+ + - + - {% endif %} - - - - {% if message.superseded %} - {% for name in message.superseded %} - - {% endfor %} - {% else %} - - {% endif %} - -
Unknown + Lemur +
Potentially Superseded by (Lemur's best guess)
{{ name }}
Unknown
-
- -
- Lemur is broken regularly by Netflix -
- -
-
- - +
+
+ + + + + + + + + + + + + + +
+ Your certificate(s) are expiring! +
+
+ + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ Hi, +
+
This is a Lemur certificate expiration notice. Please verify that the following certificates are no longer used. + + + {% for message in messages %} + + + + + + + {% if not loop.last %} + + + + + {% endif %} + {% endfor %} + +
{{ message.name }}
{{ message.owner }} +
{{ message.not_after | time }} + Details +
+
+
+ If the above certificates are still in use. You should re-issue and deploy new certificates as soon as possible. +
+
Best,
Lemur +
+ + + + + + +
*All expiration times are in UTC
+
+
+
+ + + + + + + + + +
You received this mandatory email service announcement to update you about + important changes to your TLS certificate. +
+
© 2015 Lemur
+
+
+ + + + + + + diff --git a/lemur/plugins/lemur_email/tests/test_email.py b/lemur/plugins/lemur_email/tests/test_email.py new file mode 100644 index 00000000..2590a301 --- /dev/null +++ b/lemur/plugins/lemur_email/tests/test_email.py @@ -0,0 +1,16 @@ +from lemur.plugins.lemur_email.templates.config import env + +import os.path + + +def test_render(): + messages = [{ + 'name': 'a-really-really-long-certificate-name', + 'owner': 'bob@example.com', + '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'))