summary refs log tree commit diff
diff options
context:
space:
mode:
authorStig Palmquist <stig@stig.io>2021-08-13 20:55:15 +0200
committerStig Palmquist <stig@stig.io>2021-08-13 21:03:15 +0200
commit5e13c58f78b685f1d9fd451160dfb1adc9c4ce07 (patch)
treecf69c9247b1ab7eddee14c1e8e449477e91bb61c
parentc4095d0e4129dd7914a885a0f4088b2ff8f0b2c5 (diff)
downloadnixpkgs-5e13c58f78b685f1d9fd451160dfb1adc9c4ce07.tar
nixpkgs-5e13c58f78b685f1d9fd451160dfb1adc9c4ce07.tar.gz
nixpkgs-5e13c58f78b685f1d9fd451160dfb1adc9c4ce07.tar.bz2
nixpkgs-5e13c58f78b685f1d9fd451160dfb1adc9c4ce07.tar.lz
nixpkgs-5e13c58f78b685f1d9fd451160dfb1adc9c4ce07.tar.xz
nixpkgs-5e13c58f78b685f1d9fd451160dfb1adc9c4ce07.tar.zst
nixpkgs-5e13c58f78b685f1d9fd451160dfb1adc9c4ce07.zip
nixos/mod_perl: add test
-rw-r--r--nixos/tests/all-tests.nix1
-rw-r--r--nixos/tests/mod_perl.nix53
2 files changed, 54 insertions, 0 deletions
diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix
index 7e657878509..450b65b8b66 100644
--- a/nixos/tests/all-tests.nix
+++ b/nixos/tests/all-tests.nix
@@ -255,6 +255,7 @@ in
   miniflux = handleTest ./miniflux.nix {};
   minio = handleTest ./minio.nix {};
   misc = handleTest ./misc.nix {};
+  mod_perl = handleTest ./mod_perl.nix {};
   moinmoin = handleTest ./moinmoin.nix {};
   mongodb = handleTest ./mongodb.nix {};
   moodle = handleTest ./moodle.nix {};
diff --git a/nixos/tests/mod_perl.nix b/nixos/tests/mod_perl.nix
new file mode 100644
index 00000000000..29a1eb6503f
--- /dev/null
+++ b/nixos/tests/mod_perl.nix
@@ -0,0 +1,53 @@
+import ./make-test-python.nix ({ pkgs, lib, ... }: {
+  name = "mod_perl";
+
+  meta = with pkgs.lib.maintainers; {
+    maintainers = [ sgo ];
+  };
+
+  machine = { config, lib, pkgs, ... }: {
+    services.httpd = {
+      enable = true;
+      adminAddr = "admin@localhost";
+      virtualHosts."modperl" =
+        let
+          inc = pkgs.writeTextDir "ModPerlTest.pm" ''
+            package ModPerlTest;
+            use strict;
+            use Apache2::RequestRec ();
+            use Apache2::RequestIO ();
+            use Apache2::Const -compile => qw(OK);
+            sub handler {
+              my $r = shift;
+              $r->content_type('text/plain');
+              print "Hello mod_perl!\n";
+              return Apache2::Const::OK;
+            }
+            1;
+          '';
+          startup = pkgs.writeScript "startup.pl" ''
+            use lib "${inc}",
+              split ":","${with pkgs.perl.pkgs; makeFullPerlPath ([ mod_perl2 ])}";
+            1;
+          '';
+        in
+        {
+          extraConfig = ''
+            PerlRequire ${startup}
+          '';
+          locations."/modperl" = {
+            extraConfig = ''
+              SetHandler perl-script
+              PerlResponseHandler ModPerlTest
+            '';
+          };
+        };
+      enablePerl = true;
+    };
+  };
+  testScript = { ... }: ''
+    machine.wait_for_unit("httpd.service")
+    response = machine.succeed("curl -fvvv -s http://127.0.0.1:80/modperl")
+    assert "Hello mod_perl!" in response, "/modperl handler did not respond"
+  '';
+})