File tree Expand file tree Collapse file tree 3 files changed +25
-0
lines changed Expand file tree Collapse file tree 3 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,16 @@ http://{{ caddy.addresses.webhook }} {
46
46
}
47
47
}
48
48
49
+ handle /ping {
50
+ reverse_proxy * localhost:1234 {
51
+ # Don't leak out internal problems.
52
+ @error status 4xx 5xx
53
+ handle_response @error {
54
+ error 503
55
+ }
56
+ }
57
+ }
58
+
49
59
handle {
50
60
error 404
51
61
}
Original file line number Diff line number Diff line change @@ -65,6 +65,15 @@ async def test_update_repo(tmp_path_factory):
65
65
assert dest_commit == src_commit
66
66
67
67
68
+ async def test_ping (aiohttp_client , monkeypatch , tmp_path ):
69
+ """Test ping always works."""
70
+ monkeypatch .setenv ('SITE_DIR' , str (tmp_path ))
71
+ client = await aiohttp_client (create_app ())
72
+
73
+ resp = await client .get ('/ping' )
74
+ assert resp .status == 200
75
+
76
+
68
77
async def test_github_webhook_errors (aiohttp_client , monkeypatch , tmp_path ):
69
78
"""Test invalid inputs to webhook."""
70
79
monkeypatch .setenv ('SITE_DIR' , str (tmp_path ))
Original file line number Diff line number Diff line change @@ -173,6 +173,11 @@ async def github_webhook(request: web.Request):
173
173
return web .Response (status = 200 )
174
174
175
175
176
+ async def ping (request : web .Request ):
177
+ """Respond to a ping, thus verifying the webhook service is alive."""
178
+ return web .Response (status = 200 )
179
+
180
+
176
181
def create_app ():
177
182
"""Create the aiohttp app and setup routes."""
178
183
site_dir = Path (os .environ .get ('SITE_DIR' , 'sites' )).resolve ()
@@ -182,6 +187,7 @@ def create_app():
182
187
app ['site_dir' ] = site_dir
183
188
app .add_routes ([
184
189
web .post ('/gh/{repo}' , github_webhook ),
190
+ web .get ('/ping' , ping ),
185
191
])
186
192
return app
187
193
You can’t perform that action at this time.
0 commit comments