about summary refs log tree commit diff
path: root/nixpkgs/nixos/tests/web-servers/ttyd.nix
blob: b79a2032ec75a3185eaf19654c8d5c938127269d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import ../make-test-python.nix ({ lib, pkgs, ... }: {
  name = "ttyd";
  meta.maintainers = with lib.maintainers; [ stunkymonkey ];

  nodes.readonly = { pkgs, ... }: {
    services.ttyd = {
      enable = true;
      entrypoint = [ (lib.getExe pkgs.htop) ];
      writeable = false;
    };
  };

  nodes.writeable = { pkgs, ... }: {
    services.ttyd = {
      enable = true;
      username = "foo";
      passwordFile = pkgs.writeText "password" "bar";
      writeable = true;
    };
  };

  testScript = ''
    for machine in [readonly, writeable]:
      machine.wait_for_unit("ttyd.service")
      machine.wait_for_open_port(7681)
      response = machine.succeed("curl -vvv -u foo:bar -s -H 'Host: ttyd' http://127.0.0.1:7681/")
      assert '<title>ttyd - Terminal</title>' in response, "Page didn't load successfully"
  '';
})