Unverified Commit 9969fb7f authored by Nick Cao's avatar Nick Cao Committed by GitHub
Browse files

Merge pull request #281904 from Stunkymonkey/ttyd-fix-leakage

ttyd: add test & use systemd LoadCredential
parents 71ef6600 c34493d7
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -180,10 +180,11 @@ in
        # Runs login which needs to be run as root
        # login: Cannot possibly work without effective root
        User = "root";
        LoadCredential = lib.optionalString (cfg.passwordFile != null) "TTYD_PASSWORD_FILE:${cfg.passwordFile}";
      };

      script = if cfg.passwordFile != null then ''
        PASSWORD=$(cat ${escapeShellArg cfg.passwordFile})
        PASSWORD=$(cat "$CREDENTIALS_DIRECTORY/TTYD_PASSWORD_FILE")
        ${pkgs.ttyd}/bin/ttyd ${lib.escapeShellArgs args} \
          --credential ${escapeShellArg cfg.username}:"$PASSWORD" \
          ${pkgs.shadow}/bin/login
+1 −0
Original line number Diff line number Diff line
@@ -905,6 +905,7 @@ in {
  trilium-server = handleTestOn ["x86_64-linux"] ./trilium-server.nix {};
  tsja = handleTest ./tsja.nix {};
  tsm-client-gui = handleTest ./tsm-client-gui.nix {};
  ttyd = handleTest ./web-servers/ttyd.nix {};
  txredisapi = handleTest ./txredisapi.nix {};
  tuptime = handleTest ./tuptime.nix {};
  turbovnc-headless-server = handleTest ./turbovnc-headless-server.nix {};
+19 −0
Original line number Diff line number Diff line
import ../make-test-python.nix ({ lib, pkgs, ... }: {
  name = "ttyd";
  meta.maintainers = with lib.maintainers; [ stunkymonkey ];

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

  testScript = ''
    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"
  '';
})
+4 −0
Original line number Diff line number Diff line
@@ -20,6 +20,10 @@ stdenv.mkDerivation rec {

  outputs = [ "out" "man" ];

  passthru.tests = {
    inherit (nixosTests) ttyd;
  };

  meta = {
    description = "Share your terminal over the web";
    homepage    = "https://github.com/tsl0922/ttyd";