wchisp: remove overuse of with lib (#357239)
[NixPkgs.git] / nixos / tests / spiped.nix
bloba39fc2fd722b2d0ea2f9d44b9d500aebd29b68b0
1 { pkgs, ... }:
2 let
3   key = pkgs.runCommand "key" { } "${pkgs.openssl}/bin/openssl rand 32 > $out";
4 in
6   name = "spiped";
7   meta = with pkgs.lib.maintainers; {
8     maintainers = [ tomfitzhenry ];
9   };
11   nodes = {
12     server =
13       { pkgs, lib, ... }:
14       {
15         services.caddy = {
16           enable = true;
17           settings = {
18             apps.http.servers.default = {
19               listen = [ ":80" ];
20               routes = [
21                 {
22                   handle = [
23                     {
24                       body = "hello world";
25                       handler = "static_response";
26                       status_code = 200;
27                     }
28                   ];
29                 }
30               ];
31             };
32           };
33         };
35         systemd.services."spiped@server" = {
36           wantedBy = [ "multi-user.target" ];
37           overrideStrategy = "asDropin";
38         };
39         systemd.services."spiped@client" = {
40           wantedBy = [ "multi-user.target" ];
41           overrideStrategy = "asDropin";
42         };
43         services.spiped = {
44           enable = true;
45           config = {
46             server = {
47               source = "localhost:8080";
48               target = "localhost:80";
49               keyfile = key;
50               decrypt = true;
51             };
52             client = {
53               source = "localhost:8081";
54               target = "localhost:8080";
55               keyfile = key;
56               encrypt = true;
57             };
58           };
59         };
60       };
61   };
63   testScript =
64     { nodes, ... }:
65     ''
66       server.wait_for_unit("caddy")
67       server.wait_for_open_port(80)
68       server.wait_for_open_port(8080)
69       server.wait_for_open_port(8081)
71       server.succeed("curl http://localhost:8081 | grep hello")
72     '';