vuls: init at 0.27.0 (#348530)
[NixPkgs.git] / nixos / tests / endlessh.nix
blobbe742a749fdd88d68f8d64986a210acb0227eeff
1 import ./make-test-python.nix ({ lib, pkgs, ... }:
3   name = "endlessh";
4   meta.maintainers = with lib.maintainers; [ azahi ];
6   nodes = {
7     server = { ... }: {
8       services.endlessh = {
9         enable = true;
10         openFirewall = true;
11       };
13       specialisation = {
14         unprivileged.configuration.services.endlessh.port = 2222;
16         privileged.configuration.services.endlessh.port = 22;
17       };
18     };
20     client = { pkgs, ... }: {
21       environment.systemPackages = with pkgs; [ curl netcat ];
22     };
23   };
25   testScript = ''
26     def activate_specialisation(name: str):
27         server.succeed(f"/run/booted-system/specialisation/{name}/bin/switch-to-configuration test >&2")
29     start_all()
31     with subtest("Unprivileged"):
32         activate_specialisation("unprivileged")
33         server.wait_for_unit("endlessh.service")
34         server.wait_for_open_port(2222)
35         client.succeed("nc -dvW5 server 2222")
37     with subtest("Privileged"):
38         activate_specialisation("privileged")
39         server.wait_for_unit("endlessh.service")
40         server.wait_for_open_port(22)
41         client.succeed("nc -dvW5 server 22")
42   '';