nixpkgs/nixos/tests/endlessh.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

53 lines
1.3 KiB
Nix
Raw Normal View History

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