3 test_script = pkgs.stdenv.mkDerivation {
4 pname = "stargazer-test-script";
5 inherit (pkgs.stargazer) version src;
6 buildInputs = with pkgs; [ (python3.withPackages (ps: with ps; [ cryptography urllib3 ])) ];
11 cp scripts/gemini-diagnostics $out/bin/test
14 test_env = pkgs.stdenv.mkDerivation {
15 pname = "stargazer-test-env";
16 inherit (pkgs.stargazer) version src;
18 cc test_data/cgi-bin/loop.c -o test_data/cgi-bin/loop
26 scgi_server = pkgs.stdenv.mkDerivation {
27 pname = "stargazer-test-scgi-server";
28 inherit (pkgs.stargazer) version src;
29 buildInputs = with pkgs; [ python3 ];
35 cp scripts/scgi-server $out/bin/scgi-server
41 meta = with lib.maintainers; { maintainers = [ gaykitty ]; };
44 geminiserver = { pkgs, ... }: {
45 services.stargazer = {
47 connectionLogging = false;
52 root = "${test_env}/test_data/test_site";
55 route = "localhost=/en.gmi";
56 root = "${test_env}/test_data/test_site";
61 route = "localhost~/(.*).gemini";
62 root = "${test_env}/test_data/test_site";
68 route = "localhost=/plain.txt";
69 root = "${test_env}/test_data/test_site";
72 cert-path = "/var/lib/gemini/certs/localhost.crt";
73 key-path = "/var/lib/gemini/certs/localhost.key";
76 route = "localhost:/cgi-bin";
77 root = "${test_env}/test_data";
82 route = "localhost:/scgi";
84 scgi-address = "127.0.0.1:1099";
87 route = "localhost=/root";
92 route = "localhost=/priv.gmi";
93 root = "${test_env}/test_data/test_site";
94 client-cert = "${test_env}/test_data/client_cert/good.crt";
97 route = "example.com~(.*)";
98 redirect = "gemini://localhost";
102 route = "localhost:/no-exist";
103 root = "${test_env}/does_not_exist";
106 route = "localhost=/rss.xml";
107 root = "${test_env}/test_data/test_site";
108 mime-override = "application/atom+xml";
112 systemd.services.scgi_server = {
113 after = [ "network.target" ];
114 wantedBy = [ "multi-user.target" ];
116 ExecStart = "${scgi_server}/bin/scgi-server";
120 cgiTestServer = { ... }: {
125 users.groups.cgi = { };
126 services.stargazer = {
128 connectionLogging = false;
133 route = "localhost:/cgi-bin";
134 root = "${test_env}/test_data";
144 testScript = { nodes, ... }: ''
145 geminiserver.wait_for_unit("scgi_server")
146 geminiserver.wait_for_open_port(1099)
147 geminiserver.wait_for_unit("stargazer")
148 cgiTestServer.wait_for_open_port(1965)
150 with subtest("stargazer test suite"):
151 response = geminiserver.succeed("sh -c 'cd ${test_env}; ${test_script}/bin/test'")
153 with subtest("stargazer cgi-user test"):
154 response = cgiTestServer.succeed("sh -c 'cd ${test_env}; ${test_script}/bin/test --checks CGIVars'")