10 webhookMachine = { pkgs, ... }: {
11 virtualisation.forwardPorts = [{
12 host.port = forwardedPort;
13 guest.port = internalPort;
21 execute-command = "echo";
22 response-message = "Webhook is reachable!";
28 "id": "echo-template",
29 "execute-command": "echo",
30 "response-message": "{{ getenv "WEBHOOK_MESSAGE" }}"
34 environment.WEBHOOK_MESSAGE = "Templates are working!";
39 extraPythonPackages = p: [
44 testScript = { nodes, ... }: ''
46 webhookMachine.wait_for_unit("webhook")
47 webhookMachine.wait_for_open_port(${toString internalPort})
49 with subtest("Check that webhooks can be called externally"):
50 response = requests.get("http://localhost:${toString forwardedPort}/hooks/echo")
51 print(f"Response code: {response.status_code}")
52 print("Response: %r" % response.content)
54 assert response.status_code == 200
55 assert response.content == b"Webhook is reachable!"
57 with subtest("Check that templated webhooks can be called externally"):
58 response = requests.get("http://localhost:${toString forwardedPort}/hooks/echo-template")
59 print(f"Response code: {response.status_code}")
60 print("Response: %r" % response.content)
62 assert response.status_code == 200
63 assert response.content == b"Templates are working!"