A stale or empty-token Caddyfile on disk caused Caddy to reject the /load request, so the Renew button appeared to do nothing. Now renew_cert() calls regenerate_with_installed([]) first, which writes a fresh Caddyfile from current identity/config before reloading Caddy. This ensures a broken on-disk file never blocks ACME renewal. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -493,17 +493,17 @@ class TestRenewCert(unittest.TestCase):
|
||||
self.assertFalse(result['ok'])
|
||||
self.assertIn('LAN', result['error'])
|
||||
|
||||
def test_acme_mode_calls_reload(self):
|
||||
def test_acme_mode_calls_regenerate(self):
|
||||
mgr = _mgr(identity={'domain_mode': 'pic_ngo'})
|
||||
with patch.object(mgr, 'reload_caddy', return_value=True) as mock_reload:
|
||||
with patch.object(mgr, 'regenerate_with_installed', return_value=True) as mock_regen:
|
||||
result = mgr.renew_cert()
|
||||
mock_reload.assert_called_once()
|
||||
mock_regen.assert_called_once_with([])
|
||||
self.assertTrue(result['ok'])
|
||||
self.assertEqual(result['status'], 'pending')
|
||||
|
||||
def test_reload_failure_propagated(self):
|
||||
mgr = _mgr(identity={'domain_mode': 'cloudflare'})
|
||||
with patch.object(mgr, 'reload_caddy', return_value=False):
|
||||
with patch.object(mgr, 'regenerate_with_installed', return_value=False):
|
||||
result = mgr.renew_cert()
|
||||
self.assertFalse(result['ok'])
|
||||
self.assertIn('reload failed', result['error'])
|
||||
@@ -512,7 +512,7 @@ class TestRenewCert(unittest.TestCase):
|
||||
import time
|
||||
mgr = _mgr(identity={'domain_mode': 'pic_ngo'})
|
||||
mgr._cert_refreshed_at = time.monotonic()
|
||||
with patch.object(mgr, 'reload_caddy', return_value=True):
|
||||
with patch.object(mgr, 'regenerate_with_installed', return_value=True):
|
||||
mgr.renew_cert()
|
||||
self.assertIsNone(mgr._cert_refreshed_at)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user