1import ../make-test-python.nix ({ lib, pkgs, ... }: {
2 name = "ttyd";
3 meta.maintainers = with lib.maintainers; [ stunkymonkey ];
4
5 nodes.readonly = { pkgs, ... }: {
6 services.ttyd = {
7 enable = true;
8 entrypoint = [ (lib.getExe pkgs.htop) ];
9 writeable = false;
10 };
11 };
12
13 nodes.writeable = { pkgs, ... }: {
14 services.ttyd = {
15 enable = true;
16 username = "foo";
17 passwordFile = pkgs.writeText "password" "bar";
18 writeable = true;
19 };
20 };
21
22 testScript = ''
23 for machine in [readonly, writeable]:
24 machine.wait_for_unit("ttyd.service")
25 machine.wait_for_open_port(7681)
26 response = machine.succeed("curl -vvv -u foo:bar -s -H 'Host: ttyd' http://127.0.0.1:7681/")
27 assert '<title>ttyd - Terminal</title>' in response, "Page didn't load successfully"
28 '';
29})