[PATCH] Tests: added auth_request_set tests with prefix variables

Maxim Dounin mdounin at mdounin.ru
Wed Jun 3 15:50:35 UTC 2026


# HG changeset patch
# User Maxim Dounin <mdounin at mdounin.ru>
# Date 1780501789 -10800
#      Wed Jun 03 18:49:49 2026 +0300
# Node ID fd936830a8ea642b9b9a32c771fc23f71d9f8149
# Parent  26a9c0862ac79ff6efd78999e4773ef4059cc600
Tests: added auth_request_set tests with prefix variables.

diff --git a/auth_request_set.t b/auth_request_set.t
--- a/auth_request_set.t
+++ b/auth_request_set.t
@@ -22,7 +22,7 @@ select STDERR; $| = 1;
 select STDOUT; $| = 1;
 
 my $t = Test::Nginx->new()->has(qw/http rewrite proxy auth_request/)
-	->plan(6);
+	->plan(8);
 
 $t->write_file_expand('nginx.conf', <<'EOF');
 
@@ -88,6 +88,17 @@ http {
             return 204;
         }
 
+        location = /prefix {
+            add_header X-Foo $arg_foo;
+            return 204;
+        }
+
+        location = /prefix_set {
+            auth_request /auth;
+            auth_request_set $arg_foo "set";
+            add_header X-Foo $arg_foo;
+        }
+
         location = /auth {
             proxy_pass http://127.0.0.1:8081;
         }
@@ -121,6 +132,7 @@ EOF
 
 $t->write_file('t1.html', '');
 $t->write_file('t4-fallback.html', '');
+$t->write_file('prefix_set', '');
 $t->run();
 
 ###############################################################################
@@ -141,4 +153,16 @@ like(http_get('/t5.html'), qr/X-Args: se
 
 like(http_get('/t6.html'), qr/X-Unset-Username: xx/, 'unset variable');
 
+# variables introduced by auth_request_set did not use the NGX_HTTP_VAR_WEAK
+# flag, thus overriding corresponding prefix variables in unrelated contexts
+
+TODO: {
+local $TODO = 'not yet' unless $t->has_version('1.31.3');
+
+like(http_get('/prefix?foo=arg'), qr/X-Foo: arg/, 'prefix variable');
+
+}
+
+like(http_get('/prefix_set?foo=arg'), qr/X-Foo: set/, 'set prefix variable');
+
 ###############################################################################



More information about the nginx-devel mailing list