Again require RenewableCert to be given a ConfigObj

This commit is contained in:
Seth Schoen 2015-05-11 11:49:20 -07:00
parent 06a3f54c92
commit 6f56dc1418
2 changed files with 4 additions and 22 deletions

View file

@ -35,29 +35,19 @@ class RenewableCert(object): # pylint: disable=too-many-instance-attributes
associated renewal configuration file."""
def __init__(self, configfile, defaults=DEFAULTS):
if isinstance(configfile, str):
if not os.path.exists(configfile):
raise ValueError(
"renewal config file {0} doesn't exist".format(configfile))
if not configfile.endswith(".conf"):
if isinstance(configfile, configobj.ConfigObj):
if not os.path.basename(configfile.filename).endswith(".conf"):
raise ValueError("renewal config file name must end in .conf")
self.lineagename = os.path.basename(configfile)[:-5]
self.configfilename = os.path.basename(configfile)
elif isinstance(configfile, configobj.ConfigObj):
self.lineagename = os.path.basename(configfile.filename)[:-5]
self.configfilename = os.path.basename(configfile.filename)
if not self.configfilename.endswith(".conf"):
raise ValueError("renewal config file name must end in .conf")
else:
raise TypeError("RenewableCert config must be file path "
"or ConfigObj object")
raise TypeError("RenewableCert config must be ConfigObj object")
# self.configuration should be used to read parameters that
# may have been chosen based on default values from the
# systemwide renewal configuration; self.configfile should be
# used to make and save changes.
self.configfile = configfile
self.configuration = copy.deepcopy(defaults)
self.configfile = configobj.ConfigObj(configfile)
self.configuration.merge(self.configfile)
if not all(self.configuration.has_key(x) for x in ALL_FOUR):

View file

@ -73,14 +73,6 @@ class RenewableCertTests(unittest.TestCase):
config["fullchain"] = "/tmp/fullchain.pem"
config.filename = "/tmp/sillyfile"
self.assertRaises(ValueError, storage.RenewableCert, config, defaults)
self.assertRaises(ValueError, storage.RenewableCert, "/tmp", defaults)
def test_renewal_config_filename_exists(self):
"""Test that the RenewableCert constructor will complain if
the renewal configuration file doesn't exist."""
from letsencrypt.client import storage
defaults = configobj.ConfigObj()
self.assertRaises(ValueError, storage.RenewableCert, "XXXXX", defaults)
def test_consistent(self): # pylint: disable=too-many-statements
oldcert = self.test_rc.cert