Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a test to ensure test coverage regardless of the vhost order #6873

Merged
merged 3 commits into from Mar 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 24 additions & 0 deletions certbot-apache/certbot_apache/tests/configurator_test.py
@@ -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
Expand Down Expand Up @@ -1512,6 +1513,29 @@ def test_add_vhost_id_already_exists(self):
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."""
Expand Down
5 changes: 1 addition & 4 deletions tox.cover.py
Expand Up @@ -14,10 +14,7 @@
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},
Expand Down