Commit 692b12ce authored by Tom Fitzhenry's avatar Tom Fitzhenry Committed by tomf
Browse files

nixos/tests/spiped: init

parent 6b8c4f11
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -929,6 +929,7 @@ in {
  sourcehut = handleTest ./sourcehut {};
  spacecookie = handleTest ./spacecookie.nix {};
  spark = handleTestOn [ "x86_64-linux" "aarch64-linux" ] ./spark {};
  spiped = runTest ./spiped.nix;
  sqlite3-to-mysql = handleTest ./sqlite3-to-mysql.nix {};
  sslh = handleTest ./sslh.nix {};
  ssh-agent-auth = handleTest ./ssh-agent-auth.nix {};

nixos/tests/spiped.nix

0 → 100644
+73 −0
Original line number Diff line number Diff line
{ pkgs, ... }:
let
  key = pkgs.runCommand "key" { } "${pkgs.openssl}/bin/openssl rand 32 > $out";
in
{
  name = "spiped";
  meta = with pkgs.lib.maintainers; {
    maintainers = [ tomfitzhenry ];
  };

  nodes = {
    server =
      { pkgs, lib, ... }:
      {
        services.caddy = {
          enable = true;
          settings = {
            apps.http.servers.default = {
              listen = [ ":80" ];
              routes = [
                {
                  handle = [
                    {
                      body = "hello world";
                      handler = "static_response";
                      status_code = 200;
                    }
                  ];
                }
              ];
            };
          };
        };

        systemd.services."spiped@server" = {
          wantedBy = [ "multi-user.target" ];
          overrideStrategy = "asDropin";
        };
        systemd.services."spiped@client" = {
          wantedBy = [ "multi-user.target" ];
          overrideStrategy = "asDropin";
        };
        services.spiped = {
          enable = true;
          config = {
            server = {
              source = "localhost:8080";
              target = "localhost:80";
              keyfile = key;
              decrypt = true;
            };
            client = {
              source = "localhost:8081";
              target = "localhost:8080";
              keyfile = key;
              encrypt = true;
            };
          };
        };
      };
  };

  testScript =
    { nodes, ... }:
    ''
      server.wait_for_unit("caddy")
      server.wait_for_open_port(80)
      server.wait_for_open_port(8080)
      server.wait_for_open_port(8081)

      server.succeed("curl http://localhost:8081 | grep hello")
    '';
}
+3 −0
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@
  fetchurl,
  openssl,
  coreutils,
  nixosTests,
}:

stdenv.mkDerivation rec {
@@ -34,6 +35,8 @@ stdenv.mkDerivation rec {
    runHook postInstall
  '';

  passthru.tests.spiped = nixosTests.spiped;

  meta = {
    description = "Utility for secure encrypted channels between sockets";
    homepage = "https://www.tarsnap.com/spiped.html";