mirror of
https://github.com/certbot/certbot.git
synced 2026-05-04 17:25:37 -04:00
Explicit test for modified write_renewal_config
This commit is contained in:
parent
4964f5dc67
commit
33a4acf6eb
1 changed files with 23 additions and 0 deletions
|
|
@ -742,6 +742,29 @@ class RenewableCertTests(BaseRenewableCertTest):
|
|||
storage.RenewableCert,
|
||||
self.config.filename, self.cli_config)
|
||||
|
||||
def test_write_renewal_config(self):
|
||||
# Mostly tested by the process of creating and updating lineages,
|
||||
# but we can test that this successfully creates files, removes
|
||||
# unneeded items, and preserves comments.
|
||||
tempfile = os.path.join(self.tempdir, "sample-file")
|
||||
tempfile2 = os.path.join(self.tempdir, "sample-file.new")
|
||||
with open(tempfile, "w") as f:
|
||||
f.write("[renewalparams]\nuseful = value # A useful value\n"
|
||||
"useless = value # Not needed\n")
|
||||
target = {}
|
||||
for x in ALL_FOUR:
|
||||
target[x] = "somewhere"
|
||||
relevant = {"useful": "new_value"}
|
||||
from letsencrypt import storage
|
||||
storage.write_renewal_config(tempfile, tempfile2, target, relevant)
|
||||
with open(tempfile2, "r") as f:
|
||||
content = f.read()
|
||||
# useful value was updated
|
||||
assert "useful = new_value" in content
|
||||
# associated comment was preserved
|
||||
assert "A useful value" in content
|
||||
# useless value was deleted
|
||||
assert "useless" not in content
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main() # pragma: no cover
|
||||
|
|
|
|||
Loading…
Reference in a new issue