From 1cd47d4af3f0bd7a2b094ad2c2c38051f981511c Mon Sep 17 00:00:00 2001 From: James Kasten Date: Mon, 22 Jun 2015 23:23:57 -0700 Subject: [PATCH 1/3] first pass for ssl labs --- letsencrypt/display/ops.py | 17 +++++++++++++++-- letsencrypt/tests/display/ops_test.py | 21 +++++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/letsencrypt/display/ops.py b/letsencrypt/display/ops.py index fa77e3566..0bb7f5977 100644 --- a/letsencrypt/display/ops.py +++ b/letsencrypt/display/ops.py @@ -205,8 +205,21 @@ def success_installation(domains): """ util(interfaces.IDisplay).notification( - "Congratulations! You have successfully enabled " - "%s!" % _gen_https_names(domains), pause=False) + "Congratulations! You have successfully enabled {0}! You should test your configuration:{1}" + "{2}".format( + _gen_https_names(domains), + os.linesep, + os.linesep.join(_gen_ssl_lab_urls(domains))), + pause=False) + + +def _gen_ssl_lab_urls(domains): + """Returns a list of urls. + + :param list domains: Each domain is a 'str' + + """ + return ["https://www.ssllabs.com/ssltest/analyze.html?d=%s", dom for dom in domains] def _gen_https_names(domains): diff --git a/letsencrypt/tests/display/ops_test.py b/letsencrypt/tests/display/ops_test.py index 01daf0004..a1f9a65f6 100644 --- a/letsencrypt/tests/display/ops_test.py +++ b/letsencrypt/tests/display/ops_test.py @@ -182,6 +182,27 @@ class ChooseAccountTest(unittest.TestCase): self.assertTrue(self._call([self.acc1, self.acc2]) is None) +class GenSSLLabURLs(unittest.TestCase): + """Loose test of _gen_ssl_lab_urls. URL can change easily in the future""" + def setUp(self): + zope.component.provideUtility(display_util.FileDisplay(sys.stdout)) + + @classmethod + def _call(cls, domains): + from letsencrypt.display.ops import _gen_ssl_lab_urls + return _gen_ssl_lab_urls(domains) + + def test_zero(self): + self.assertEqual(self._call([]), []) + + def test_one(self): + self.assertTrue("eff.org" in self._call(["eff.org"])[0]) + + def test_two(self): + urls = self._call(["eff.org", "umich.edu"]) + self.assertTrue("eff.org" in urls[0]) + self.assertTrue("umich.edu" in urls[1]) + class GenHttpsNamesTest(unittest.TestCase): """Test _gen_https_names.""" def setUp(self): From f8384127c093b576d73840a529defe1751cb2685 Mon Sep 17 00:00:00 2001 From: James Kasten Date: Wed, 24 Jun 2015 10:55:08 -0700 Subject: [PATCH 2/3] Format and fix ssl_labs printout --- letsencrypt/display/ops.py | 7 ++++--- letsencrypt/tests/display/ops_test.py | 5 +---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/letsencrypt/display/ops.py b/letsencrypt/display/ops.py index 0bb7f5977..48718f88c 100644 --- a/letsencrypt/display/ops.py +++ b/letsencrypt/display/ops.py @@ -205,11 +205,12 @@ def success_installation(domains): """ util(interfaces.IDisplay).notification( - "Congratulations! You have successfully enabled {0}! You should test your configuration:{1}" - "{2}".format( + "Congratulations! You have successfully enabled {0}!{1}{1}" + "You should test your configuration at:{1}{2}".format( _gen_https_names(domains), os.linesep, os.linesep.join(_gen_ssl_lab_urls(domains))), + height=(10 + len(domains)), pause=False) @@ -219,7 +220,7 @@ def _gen_ssl_lab_urls(domains): :param list domains: Each domain is a 'str' """ - return ["https://www.ssllabs.com/ssltest/analyze.html?d=%s", dom for dom in domains] + return ["https://www.ssllabs.com/ssltest/analyze.html?d=%s" % dom for dom in domains] def _gen_https_names(domains): diff --git a/letsencrypt/tests/display/ops_test.py b/letsencrypt/tests/display/ops_test.py index a1f9a65f6..48a51bf27 100644 --- a/letsencrypt/tests/display/ops_test.py +++ b/letsencrypt/tests/display/ops_test.py @@ -195,9 +195,6 @@ class GenSSLLabURLs(unittest.TestCase): def test_zero(self): self.assertEqual(self._call([]), []) - def test_one(self): - self.assertTrue("eff.org" in self._call(["eff.org"])[0]) - def test_two(self): urls = self._call(["eff.org", "umich.edu"]) self.assertTrue("eff.org" in urls[0]) @@ -328,7 +325,7 @@ class SuccessInstallationTest(unittest.TestCase): names = ["example.com", "abc.com"] self._call(names) - + self.assertEqual(mock_util().notification.call_count, 1) arg = mock_util().notification.call_args_list[0][0][0] From 67f67fea02446e53ccc0de78a7f566d04a2a9607 Mon Sep 17 00:00:00 2001 From: James Kasten Date: Wed, 24 Jun 2015 14:53:28 -0700 Subject: [PATCH 3/3] Remove trailing whitespace --- letsencrypt/display/ops.py | 2 +- letsencrypt/tests/display/ops_test.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/letsencrypt/display/ops.py b/letsencrypt/display/ops.py index 48718f88c..1a1887b9a 100644 --- a/letsencrypt/display/ops.py +++ b/letsencrypt/display/ops.py @@ -216,7 +216,7 @@ def success_installation(domains): def _gen_ssl_lab_urls(domains): """Returns a list of urls. - + :param list domains: Each domain is a 'str' """ diff --git a/letsencrypt/tests/display/ops_test.py b/letsencrypt/tests/display/ops_test.py index 48a51bf27..25be6bebc 100644 --- a/letsencrypt/tests/display/ops_test.py +++ b/letsencrypt/tests/display/ops_test.py @@ -183,7 +183,7 @@ class ChooseAccountTest(unittest.TestCase): class GenSSLLabURLs(unittest.TestCase): - """Loose test of _gen_ssl_lab_urls. URL can change easily in the future""" + """Loose test of _gen_ssl_lab_urls. URL can change easily in the future.""" def setUp(self): zope.component.provideUtility(display_util.FileDisplay(sys.stdout)) @@ -325,7 +325,7 @@ class SuccessInstallationTest(unittest.TestCase): names = ["example.com", "abc.com"] self._call(names) - + self.assertEqual(mock_util().notification.call_count, 1) arg = mock_util().notification.call_args_list[0][0][0]