Merge pull request #197221 from azahi/endlessh-module

This commit is contained in:
Sandro
2022-11-01 23:44:25 +01:00
committed by GitHub
7 changed files with 170 additions and 3 deletions

View File

@@ -183,6 +183,7 @@ in {
ejabberd = handleTest ./xmpp/ejabberd.nix {};
elk = handleTestOn ["x86_64-linux"] ./elk.nix {};
emacs-daemon = handleTest ./emacs-daemon.nix {};
endlessh = handleTest ./endlessh.nix {};
endlessh-go = handleTest ./endlessh-go.nix {};
engelsystem = handleTest ./engelsystem.nix {};
enlightenment = handleTest ./enlightenment.nix {};

43
nixos/tests/endlessh.nix Normal file
View File

@@ -0,0 +1,43 @@
import ./make-test-python.nix ({ lib, pkgs, ... }:
{
name = "endlessh";
meta.maintainers = with lib.maintainers; [ azahi ];
nodes = {
server = { ... }: {
services.endlessh = {
enable = true;
openFirewall = true;
};
specialisation = {
unprivileged.configuration.services.endlessh.port = 2222;
privileged.configuration.services.endlessh.port = 22;
};
};
client = { pkgs, ... }: {
environment.systemPackages = with pkgs; [ curl netcat ];
};
};
testScript = ''
def activate_specialisation(name: str):
server.succeed(f"/run/booted-system/specialisation/{name}/bin/switch-to-configuration test >&2")
start_all()
with subtest("Unprivileged"):
activate_specialisation("unprivileged")
server.wait_for_unit("endlessh.service")
server.wait_for_open_port(2222)
client.succeed("nc -dvW5 server 2222")
with subtest("Privileged"):
activate_specialisation("privileged")
server.wait_for_unit("endlessh.service")
server.wait_for_open_port(22)
client.succeed("nc -dvW5 server 22")
'';
})