apache: expose aug_save errors in the debug log (#9169)

Fixes #9168.

* apache: expose aug_save errors in the debug log

* logger arguments wrong way around

* log formatting

Co-authored-by: Brad Warren <bmw@users.noreply.github.com>
This commit is contained in:
alexzorin
2022-01-24 09:33:11 -08:00
committed by GitHub
co-authored by Brad Warren
parent fb564cddd9
commit 7198f43008
2 changed files with 29 additions and 7 deletions
+13
View File
@@ -35,6 +35,19 @@ class BasicParserTest(util.ParserTest):
self.parser.aug.save = mock_save
self.assertRaises(errors.PluginError, self.parser.unsaved_files)
@mock.patch("certbot_apache._internal.parser.logger")
def test_bad_save_errors(self, mock_logger):
nx_path = "/non/existent/path.conf"
self.parser.aug.set("/augeas/load/Httpd/incl[last()]", nx_path)
self.parser.add_dir(f"/files{nx_path}", "AddDirective", "test")
self.assertRaises(IOError, self.parser.save, {})
mock_logger.error.assert_called_with(
'Unable to save files: %s.%s', '/non/existent/path.conf', mock.ANY)
mock_logger.debug.assert_called_with(
"Error %s saving %s: %s", "mk_augtemp",
"/non/existent/path.conf", "No such file or directory")
def test_aug_version(self):
mock_match = mock.Mock(return_value=["something"])
self.parser.aug.match = mock_match