MCPcopy Create free account
hub / github.com/apache/httpd / test_md_901_030

Method test_md_901_030

test/modules/md/test_901_message.py:247–298  ·  view source on GitHub ↗
(self, env)

Source from the content-addressed store, hash-verified

245 # resets the MD activity.
246 @pytest.mark.skipif(MDTestEnv.is_pebble(), reason="ACME server certs valid too long")
247 def test_md_901_030(self, env):
248 domain = self.test_domain
249 domains = [domain, "www." + domain]
250 conf = MDConf(env)
251 conf.add_md(domains)
252 conf.add_vhost(domains)
253 conf.install()
254 assert env.apache_restart() == 0, f'{env.apachectl_stderr}'
255 assert env.await_completion([domain])
256 # set the warn window that triggers right away and a failing message command
257 conf = MDConf(env)
258 conf.add(f"MDMessageCmd {env.test_dir}../modules/md/notifail.py {self.mlog}")
259 conf.add_md(domains)
260 conf.add("""
261 MDWarnWindow 100d
262 """)
263 conf.add_vhost(domains)
264 conf.install()
265 assert env.apache_restart() == 0, f'{env.apachectl_stderr}'
266 env.get_md_status(domain)
267 # this command should have failed and logged an error
268 # shut down server to make sure that md has completed
269 assert env.await_file(env.store_staged_file(domain, 'job.json'))
270 while True:
271 with open(env.store_staged_file(domain, 'job.json')) as f:
272 job = json.load(f)
273 if job["errors"] > 0:
274 assert job["errors"] > 0, "unexpected job result: {0}".format(job)
275 assert job["last"]["problem"] == "urn:org:apache:httpd:log:AH10109:"
276 break
277 time.sleep(0.1)
278
279 # reconfigure to a working notification command and restart
280 conf = MDConf(env)
281 conf.add(f"MDMessageCmd {self.mcmd} {self.mlog}")
282 conf.add_md(domains)
283 conf.add("""
284 MDWarnWindow 100d
285 """)
286 conf.add_vhost(domains)
287 conf.install()
288 assert env.apache_restart() == 0, f'{env.apachectl_stderr}'
289 assert env.await_file(self.mlog)
290 # we see the notification logged by the command
291 nlines = open(self.mlog).readlines()
292 assert len(nlines) == 1
293 assert nlines[0].strip() == f"['{self.mcmd}', '{self.mlog}', 'expiring', '{domain}']"
294 # the error needs to be gone
295 assert env.await_file(env.store_staged_file(domain, 'job.json'))
296 with open(env.store_staged_file(domain, 'job.json')) as f:
297 job = json.load(f)
298 assert job["errors"] == 0
299
300 # MD, check a failed challenge setup
301 def test_md_901_040(self, env):

Callers

nothing calls this directly

Calls 10

add_mdMethod · 0.95
MDConfClass · 0.85
add_vhostMethod · 0.80
installMethod · 0.80
apache_restartMethod · 0.80
await_completionMethod · 0.80
addMethod · 0.80
get_md_statusMethod · 0.80
await_fileMethod · 0.80
store_staged_fileMethod · 0.80

Tested by

no test coverage detected