Correctly test for existing Certbot redirect when adding an Nginx redirect block (#5192)

* add test that should fail on completion of this PR

* fix double redirect problem

* update existing test to match new whitespace
This commit is contained in:
ohemorange
2017-10-19 14:56:53 -07:00
committed by Brad Warren
parent a6cecd784b
commit 3c1dafa9e9
2 changed files with 19 additions and 2 deletions
@@ -512,6 +512,23 @@ class NginxConfiguratorTest(util.NginxTest):
self.assertEqual(mock_logger.info.call_args[0][0],
'No matching insecure server blocks listening on port %s found.')
def test_no_double_redirect(self):
# Test that we don't also add the commented redirect if we've just added
# a redirect to that vhost this run
example_conf = self.config.parser.abs_path('sites-enabled/example.com')
self.config.enhance("example.com", "redirect")
self.config.enhance("example.org", "redirect")
unexpected = [
['#', ' Redirect non-https traffic to https'],
['#', ' if ($scheme != "https") {'],
['#', ' return 301 https://$host$request_uri;'],
['#', ' } # managed by Certbot']
]
generated_conf = self.config.parser.parsed[example_conf]
for line in unexpected:
self.assertFalse(util.contains_at_depth(generated_conf, line, 2))
def test_staple_ocsp_bad_version(self):
self.config.version = (1, 3, 1)
self.assertRaises(errors.PluginError, self.config.enhance,