Skip to content

Commit

Permalink
--webroot-root -> --webroot-path
Browse files Browse the repository at this point in the history
  • Loading branch information
kuba committed Oct 4, 2015
1 parent d88455a commit 63c080b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
16 changes: 8 additions & 8 deletions letsencrypt/plugins/webroot.py
Expand Up @@ -29,11 +29,11 @@ class Authenticator(common.Plugin):
to serve all files under specified web root ({0})."""

def more_info(self): # pylint: disable=missing-docstring,no-self-use
return self.MORE_INFO.format(self.conf("root"))
return self.MORE_INFO.format(self.conf("path"))

@classmethod
def add_parser_arguments(cls, add):
add("root", help="public_html / webroot path")
add("path", help="public_html / webroot path")

def get_chall_pref(self, domain): # pragma: no cover
# pylint: disable=missing-docstring,no-self-use,unused-argument
Expand All @@ -44,15 +44,15 @@ def __init__(self, *args, **kwargs):
self.full_root = None

def prepare(self): # pylint: disable=missing-docstring
root = self.conf("root")
if root is None:
path = self.conf("path")
if path is None:
raise errors.PluginError("--{0} must be set".format(
self.option_name("root")))
if not os.path.isdir(root):
self.option_name("path")))
if not os.path.isdir(path):
raise errors.PluginError(
root + " does not exist or is not a directory")
path + " does not exist or is not a directory")
self.full_root = os.path.join(
root, challenges.SimpleHTTPResponse.URI_ROOT_PATH)
path, challenges.SimpleHTTPResponse.URI_ROOT_PATH)

logger.debug("Creating root challenges validation dir at %s",
self.full_root)
Expand Down
20 changes: 10 additions & 10 deletions letsencrypt/plugins/webroot_test.py
Expand Up @@ -26,44 +26,44 @@ class AuthenticatorTest(unittest.TestCase):

def setUp(self):
from letsencrypt.plugins.webroot import Authenticator
self.root = tempfile.mkdtemp()
self.path = tempfile.mkdtemp()
self.validation_path = os.path.join(
self.root, ".well-known", "acme-challenge",
self.path, ".well-known", "acme-challenge",
"ZXZhR3hmQURzNnBTUmIyTEF2OUlaZjE3RHQzanV4R0orUEN0OTJ3citvQQ")
self.config = mock.MagicMock(webroot_root=self.root)
self.config = mock.MagicMock(webroot_path=self.path)
self.auth = Authenticator(self.config, "webroot")
self.auth.prepare()

def tearDown(self):
shutil.rmtree(self.root)
shutil.rmtree(self.path)

def test_more_info(self):
more_info = self.auth.more_info()
self.assertTrue(isinstance(more_info, str))
self.assertTrue(self.root in more_info)
self.assertTrue(self.path in more_info)

def test_add_parser_arguments(self):
add = mock.MagicMock()
self.auth.add_parser_arguments(add)
self.assertEqual(1, add.call_count)

def test_prepare_bad_root(self):
self.config.webroot_root = os.path.join(self.root, "null")
self.config.webroot_path = os.path.join(self.path, "null")
self.assertRaises(errors.PluginError, self.auth.prepare)

def test_prepare_missing_root(self):
self.config.webroot_root = None
self.config.webroot_path = None
self.assertRaises(errors.PluginError, self.auth.prepare)

def test_prepare_full_root_exists(self):
# prepare() has already been called once in setUp()
self.auth.prepare() # shouldn't raise any exceptions

def test_prepare_reraises_other_errors(self):
self.auth.full_root = os.path.join(self.root, "null")
os.chmod(self.root, 0o000)
self.auth.full_path = os.path.join(self.path, "null")
os.chmod(self.path, 0o000)
self.assertRaises(errors.PluginError, self.auth.prepare)
os.chmod(self.root, 0o700)
os.chmod(self.path, 0o700)

def test_perform_cleanup(self):
responses = self.auth.perform([self.achall])
Expand Down

0 comments on commit 63c080b

Please sign in to comment.