Compare commits
4 Commits
test-use_d
...
apache_doc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
541bd720d9 | ||
|
|
70d868ab5e | ||
|
|
7031d66622 | ||
|
|
1527a7e4a2 |
@@ -50,6 +50,8 @@ More details about these changes can be found on our GitHub repo.
|
|||||||
to the `update_account` subcommand.
|
to the `update_account` subcommand.
|
||||||
* Marked usage `register --update-registration` for deprecation and
|
* Marked usage `register --update-registration` for deprecation and
|
||||||
removal in a future release.
|
removal in a future release.
|
||||||
|
* Apache plugin now respects CERTBOT_DOCS environment variable when adding
|
||||||
|
command line defaults.
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
|||||||
@@ -92,6 +92,11 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
description = "Apache Web Server plugin"
|
description = "Apache Web Server plugin"
|
||||||
|
if os.environ.get("CERTBOT_DOCS") == "1":
|
||||||
|
description += (
|
||||||
|
"(Please note that the default values of the Apache plugin options"
|
||||||
|
" change depending on the operating system Certbot is run on.)"
|
||||||
|
)
|
||||||
|
|
||||||
OS_DEFAULTS = dict(
|
OS_DEFAULTS = dict(
|
||||||
server_root="/etc/apache2",
|
server_root="/etc/apache2",
|
||||||
@@ -141,28 +146,36 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
|
|||||||
# When adding, modifying or deleting command line arguments, be sure to
|
# When adding, modifying or deleting command line arguments, be sure to
|
||||||
# include the changes in the list used in method _prepare_options() to
|
# include the changes in the list used in method _prepare_options() to
|
||||||
# ensure consistent behavior.
|
# ensure consistent behavior.
|
||||||
add("enmod", default=cls.OS_DEFAULTS["enmod"],
|
|
||||||
|
# Respect CERTBOT_DOCS environment variable and use default values from
|
||||||
|
# base class regardless of the underlying distribution (overrides).
|
||||||
|
if os.environ.get("CERTBOT_DOCS") == "1":
|
||||||
|
DEFAULTS = ApacheConfigurator.OS_DEFAULTS
|
||||||
|
else:
|
||||||
|
# cls.OS_DEFAULTS can be distribution specific, see override classes
|
||||||
|
DEFAULTS = cls.OS_DEFAULTS
|
||||||
|
add("enmod", default=DEFAULTS["enmod"],
|
||||||
help="Path to the Apache 'a2enmod' binary")
|
help="Path to the Apache 'a2enmod' binary")
|
||||||
add("dismod", default=cls.OS_DEFAULTS["dismod"],
|
add("dismod", default=DEFAULTS["dismod"],
|
||||||
help="Path to the Apache 'a2dismod' binary")
|
help="Path to the Apache 'a2dismod' binary")
|
||||||
add("le-vhost-ext", default=cls.OS_DEFAULTS["le_vhost_ext"],
|
add("le-vhost-ext", default=DEFAULTS["le_vhost_ext"],
|
||||||
help="SSL vhost configuration extension")
|
help="SSL vhost configuration extension")
|
||||||
add("server-root", default=cls.OS_DEFAULTS["server_root"],
|
add("server-root", default=DEFAULTS["server_root"],
|
||||||
help="Apache server root directory")
|
help="Apache server root directory")
|
||||||
add("vhost-root", default=None,
|
add("vhost-root", default=None,
|
||||||
help="Apache server VirtualHost configuration root")
|
help="Apache server VirtualHost configuration root")
|
||||||
add("logs-root", default=cls.OS_DEFAULTS["logs_root"],
|
add("logs-root", default=DEFAULTS["logs_root"],
|
||||||
help="Apache server logs directory")
|
help="Apache server logs directory")
|
||||||
add("challenge-location",
|
add("challenge-location",
|
||||||
default=cls.OS_DEFAULTS["challenge_location"],
|
default=DEFAULTS["challenge_location"],
|
||||||
help="Directory path for challenge configuration")
|
help="Directory path for challenge configuration")
|
||||||
add("handle-modules", default=cls.OS_DEFAULTS["handle_modules"],
|
add("handle-modules", default=DEFAULTS["handle_modules"],
|
||||||
help="Let installer handle enabling required modules for you " +
|
help="Let installer handle enabling required modules for you " +
|
||||||
"(Only Ubuntu/Debian currently)")
|
"(Only Ubuntu/Debian currently)")
|
||||||
add("handle-sites", default=cls.OS_DEFAULTS["handle_sites"],
|
add("handle-sites", default=DEFAULTS["handle_sites"],
|
||||||
help="Let installer handle enabling sites for you " +
|
help="Let installer handle enabling sites for you " +
|
||||||
"(Only Ubuntu/Debian currently)")
|
"(Only Ubuntu/Debian currently)")
|
||||||
add("ctl", default=cls.OS_DEFAULTS["ctl"],
|
add("ctl", default=DEFAULTS["ctl"],
|
||||||
help="Full path to Apache control script")
|
help="Full path to Apache control script")
|
||||||
util.add_deprecated_argument(
|
util.add_deprecated_argument(
|
||||||
add, argument_name="init-script", nargs=1)
|
add, argument_name="init-script", nargs=1)
|
||||||
|
|||||||
73
certbot/tests/certbotdocs_test.py
Normal file
73
certbot/tests/certbotdocs_test.py
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
"""Tests for help text when invoked with environmental variable CERTBOT_DOCS=1"""
|
||||||
|
import itertools
|
||||||
|
import os
|
||||||
|
import pkg_resources
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
import mock
|
||||||
|
import six
|
||||||
|
|
||||||
|
from certbot import cli, constants
|
||||||
|
from certbot.plugins import disco
|
||||||
|
|
||||||
|
import certbot.tests.util as test_util
|
||||||
|
|
||||||
|
|
||||||
|
class CertbotDocsTest(test_util.ConfigTestCase):
|
||||||
|
"""Tests for CERTBOT_DOCS=1"""
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _parse(*args, **kwargs):
|
||||||
|
"""Get result of cli.prepare_and_parse_args."""
|
||||||
|
|
||||||
|
plugins = disco.PluginsRegistry.find_all()
|
||||||
|
return cli.prepare_and_parse_args(plugins, *args, **kwargs)
|
||||||
|
|
||||||
|
def _help_output(self):
|
||||||
|
"Get output of certbot --help all"
|
||||||
|
|
||||||
|
output = six.StringIO()
|
||||||
|
|
||||||
|
def write_msg(message, *args, **kwargs): # pylint: disable=missing-docstring,unused-argument
|
||||||
|
output.write(message)
|
||||||
|
|
||||||
|
with mock.patch('certbot.main.sys.stdout', new=output):
|
||||||
|
with test_util.patch_get_utility() as mock_get_utility:
|
||||||
|
mock_get_utility().notification.side_effect = write_msg
|
||||||
|
with mock.patch('certbot.main.sys.stderr'):
|
||||||
|
self.assertRaises(SystemExit, self._parse, ["help", "all"], output)
|
||||||
|
|
||||||
|
return output.getvalue()
|
||||||
|
|
||||||
|
def test_help_certbot_docs(self):
|
||||||
|
"""Test that a consistent help text is printed when CERTBOT_DOCS=1
|
||||||
|
environmental variable is set."""
|
||||||
|
os.environ["CERTBOT_DOCS"] = "1"
|
||||||
|
|
||||||
|
entry_points = itertools.chain(
|
||||||
|
pkg_resources.iter_entry_points(
|
||||||
|
constants.SETUPTOOLS_PLUGINS_ENTRY_POINT),
|
||||||
|
pkg_resources.iter_entry_points(
|
||||||
|
constants.OLD_SETUPTOOLS_PLUGINS_ENTRY_POINT),)
|
||||||
|
apache_ep = None
|
||||||
|
for ep in entry_points:
|
||||||
|
if ep.name == "apache":
|
||||||
|
apache_ep = disco.PluginEntryPoint(ep)
|
||||||
|
mock_add = mock.MagicMock()
|
||||||
|
with mock.patch("certbot.util.exe_exists") as mock_exe:
|
||||||
|
mock_exe.return_value = True
|
||||||
|
apache_plugin = apache_ep.init(config=self.config)
|
||||||
|
apache_plugin._prepare_options()
|
||||||
|
apache_plugin.add_parser_arguments(mock_add)
|
||||||
|
expected_srv_root = {'default': '/etc/apache2',
|
||||||
|
'help': 'Apache server root directory'}
|
||||||
|
found = False
|
||||||
|
for c in mock_add.mock_calls:
|
||||||
|
if c[2] == expected_srv_root:
|
||||||
|
found = True
|
||||||
|
self.assertTrue(found)
|
||||||
|
self.assertTrue("Please note that the default values of the Apache" in apache_plugin.description)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main() # pragma: no cover
|
||||||
Reference in New Issue
Block a user