about summary refs log tree commit diff
path: root/nixos/tests
diff options
context:
space:
mode:
authorRyan Lahfa <masterancpp@gmail.com>2023-12-12 14:05:33 +0100
committerGitHub <noreply@github.com>2023-12-12 14:05:33 +0100
commit3bb93fb2cd3cb72f54e477b828a0fc717676fa51 (patch)
treefa44d5eaa2b12b928f4fcd6b5e0a91371e4239be /nixos/tests
parent7fe7e5a3463a4e87e42c1417cd61c84f2b9d2ca8 (diff)
parenta3c60d2ddc9f70dca3fa5c5926aefc9a74bd2519 (diff)
downloadnixlib-3bb93fb2cd3cb72f54e477b828a0fc717676fa51.tar
nixlib-3bb93fb2cd3cb72f54e477b828a0fc717676fa51.tar.gz
nixlib-3bb93fb2cd3cb72f54e477b828a0fc717676fa51.tar.bz2
nixlib-3bb93fb2cd3cb72f54e477b828a0fc717676fa51.tar.lz
nixlib-3bb93fb2cd3cb72f54e477b828a0fc717676fa51.tar.xz
nixlib-3bb93fb2cd3cb72f54e477b828a0fc717676fa51.tar.zst
nixlib-3bb93fb2cd3cb72f54e477b828a0fc717676fa51.zip
Merge pull request #271506 from Misterio77/nginx-redirect-status-code
Diffstat (limited to 'nixos/tests')
-rw-r--r--nixos/tests/all-tests.nix1
-rw-r--r--nixos/tests/nginx-redirectcode.nix25
2 files changed, 26 insertions, 0 deletions
diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix
index 0322ec9dc551..523035ae2a0a 100644
--- a/nixos/tests/all-tests.nix
+++ b/nixos/tests/all-tests.nix
@@ -583,6 +583,7 @@ in {
   nginx-njs = handleTest ./nginx-njs.nix {};
   nginx-proxyprotocol = handleTest ./nginx-proxyprotocol {};
   nginx-pubhtml = handleTest ./nginx-pubhtml.nix {};
+  nginx-redirectcode = handleTest ./nginx-redirectcode.nix {};
   nginx-sso = handleTest ./nginx-sso.nix {};
   nginx-status-page = handleTest ./nginx-status-page.nix {};
   nginx-tmpdir = handleTest ./nginx-tmpdir.nix {};
diff --git a/nixos/tests/nginx-redirectcode.nix b/nixos/tests/nginx-redirectcode.nix
new file mode 100644
index 000000000000..f60434a21a85
--- /dev/null
+++ b/nixos/tests/nginx-redirectcode.nix
@@ -0,0 +1,25 @@
+import ./make-test-python.nix ({ pkgs, lib, ... }: {
+  name = "nginx-redirectcode";
+  meta.maintainers = with lib.maintainers; [ misterio77 ];
+
+  nodes = {
+    webserver = { pkgs, lib, ... }: {
+      services.nginx = {
+        enable = true;
+        virtualHosts.localhost = {
+          globalRedirect = "example.com/foo";
+          # With 308 (and 307), the method and body are to be kept when following it
+          redirectCode = 308;
+        };
+      };
+    };
+  };
+
+  testScript = ''
+    webserver.wait_for_unit("nginx")
+    webserver.wait_for_open_port(80)
+
+    # Check the status code
+    webserver.succeed("curl -si http://localhost | grep '^HTTP/[0-9.]\+ 308 Permanent Redirect'")
+  '';
+})