mirror of
https://github.com/certbot/certbot.git
synced 2026-06-14 19:20:09 -04:00
Add a test to ensure test coverage regardless of the vhost order (#6873)
Add a new test to make sure that we are covering all the branches of get_virtual_hosts() regardless of the order that Augeas returns the found VirtualHost paths. Fixes: #6813 * Add a test to ensure test coverage regardless of the order of returned vhosts * Use deepcopy instead, and increase coverage requirement back to 100%
This commit is contained in:
parent
491d6c8f45
commit
b30a5e5b73
2 changed files with 25 additions and 4 deletions
|
|
@ -1,5 +1,6 @@
|
|||
# pylint: disable=too-many-public-methods,too-many-lines
|
||||
"""Test for certbot_apache.configurator."""
|
||||
import copy
|
||||
import os
|
||||
import shutil
|
||||
import socket
|
||||
|
|
@ -1512,6 +1513,29 @@ class MultipleVhostsTest(util.ApacheTest):
|
|||
second_id = self.config.add_vhost_id(self.vh_truth[0])
|
||||
self.assertEqual(first_id, second_id)
|
||||
|
||||
def test_realpath_replaces_symlink(self):
|
||||
orig_match = self.config.aug.match
|
||||
mock_vhost = copy.deepcopy(self.vh_truth[0])
|
||||
mock_vhost.filep = mock_vhost.filep.replace('sites-enabled', u'sites-available')
|
||||
mock_vhost.path = mock_vhost.path.replace('sites-enabled', 'sites-available')
|
||||
mock_vhost.enabled = False
|
||||
self.config.parser.parse_file(mock_vhost.filep)
|
||||
|
||||
def mock_match(aug_expr):
|
||||
"""Return a mocked match list of VirtualHosts"""
|
||||
if "/mocked/path" in aug_expr:
|
||||
return [self.vh_truth[1].path, self.vh_truth[0].path, mock_vhost.path]
|
||||
return orig_match(aug_expr)
|
||||
|
||||
self.config.parser.parser_paths = ["/mocked/path"]
|
||||
self.config.aug.match = mock_match
|
||||
vhs = self.config.get_virtual_hosts()
|
||||
self.assertEqual(len(vhs), 2)
|
||||
self.assertTrue(vhs[0] == self.vh_truth[1])
|
||||
# mock_vhost should have replaced the vh_truth[0], because its filepath
|
||||
# isn't a symlink
|
||||
self.assertTrue(vhs[1] == mock_vhost)
|
||||
|
||||
|
||||
class AugeasVhostsTest(util.ApacheTest):
|
||||
"""Test vhosts with illegal names dependent on augeas version."""
|
||||
|
|
|
|||
|
|
@ -14,10 +14,7 @@ DEFAULT_PACKAGES = [
|
|||
COVER_THRESHOLDS = {
|
||||
'certbot': {'linux': 98, 'windows': 93},
|
||||
'acme': {'linux': 100, 'windows': 99},
|
||||
# certbot_apache coverage not being at 100% is a workaround for
|
||||
# https://github.com/certbot/certbot/issues/6813. We should increase
|
||||
# the minimum coverage back to 100% when this issue is resolved.
|
||||
'certbot_apache': {'linux': 99, 'windows': 99},
|
||||
'certbot_apache': {'linux': 100, 'windows': 100},
|
||||
'certbot_dns_cloudflare': {'linux': 98, 'windows': 98},
|
||||
'certbot_dns_cloudxns': {'linux': 99, 'windows': 99},
|
||||
'certbot_dns_digitalocean': {'linux': 98, 'windows': 98},
|
||||
|
|
|
|||
Loading…
Reference in a new issue