Skip to content
This repository was archived by the owner on Feb 6, 2024. It is now read-only.

Commit e0e3755

Browse files
committed
surveyor: add libredict test
1 parent 87cebc1 commit e0e3755

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

infra/surveyor/default.nix

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ with rec
2222
{ text = builtins.toString port ;
2323
name = "someAPI";
2424
};
25+
26+
27+
setHosts = hosts:
28+
with rec
29+
{ mkHost = host: "${pkgs.lib.elemAt host 0} ${pkgs.lib.elemAt host 1}";
30+
lines = map mkHost hosts;
31+
}; pkgs.writeText "hosts" (pkgs.lib.concatStringsSep "\n" lines);
2532
};
2633

2734
let tests =
@@ -66,6 +73,24 @@ let tests =
6673
6774
touch $out
6875
'';
76+
77+
test_redirectHosts =
78+
''
79+
${runPort 1234}
80+
${runPort 1235}
81+
82+
export SRV_MAP="0.0.0.42:80:127.0.0.1:1234 0.0.0.43:80:127.0.0.1:1235"
83+
export NIX_REDIRECTS=/etc/hosts=${setHosts
84+
[["0.0.0.42" "www.example.com"] ["0.0.0.43" "does.not.exist"]]}
85+
86+
87+
LD_PRELOAD="${pkgs.surveyor}/lib/surveyor.so ${pkgs.libredirect}/lib/libredirect.so" \
88+
curl www.example.com | grep -q '1234'
89+
LD_PRELOAD="${pkgs.surveyor}/lib/surveyor.so ${pkgs.libredirect}/lib/libredirect.so" \
90+
curl does.not.exist | grep -q '1235'
91+
92+
touch $out
93+
'';
6994
}; in
7095

7196
{ inherit (pkgs) surveyor;

0 commit comments

Comments
 (0)