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