vuls: init at 0.27.0
[NixPkgs.git] / nixos / tests / endlessh-go.nix
blobb261dbf1c56050b9f75befeb61a45f26fa4e53cc
1 import ./make-test-python.nix ({ lib, pkgs, ... }:
3   name = "endlessh-go";
4   meta.maintainers = with lib.maintainers; [ azahi ];
6   nodes = {
7     server = { ... }: {
8       services.endlessh-go = {
9         enable = true;
10         prometheus.enable = true;
11         openFirewall = true;
12       };
14       specialisation = {
15         unprivileged.configuration = {
16           services.endlessh-go = {
17             port = 2222;
18             prometheus.port = 9229;
19           };
20         };
22         privileged.configuration = {
23           services.endlessh-go = {
24             port = 22;
25             prometheus.port = 92;
26           };
27         };
28       };
29     };
31     client = { pkgs, ... }: {
32       environment.systemPackages = with pkgs; [ curl netcat ];
33     };
34   };
36   testScript = ''
37     def activate_specialisation(name: str):
38         server.succeed(f"/run/booted-system/specialisation/{name}/bin/switch-to-configuration test >&2")
40     start_all()
42     with subtest("Unprivileged"):
43         activate_specialisation("unprivileged")
44         server.wait_for_unit("endlessh-go.service")
45         server.wait_for_open_port(2222)
46         server.wait_for_open_port(9229)
47         client.succeed("nc -dvW5 server 2222")
48         client.succeed("curl -kv server:9229/metrics")
50     with subtest("Privileged"):
51         activate_specialisation("privileged")
52         server.wait_for_unit("endlessh-go.service")
53         server.wait_for_open_port(22)
54         server.wait_for_open_port(92)
55         client.succeed("nc -dvW5 server 22")
56         client.succeed("curl -kv server:92/metrics")
57   '';