[nginx-tests] Tests: added auth_request_set tests with prefix va...

Maxim Dounin mdounin at mdounin.ru
Mon Jun 8 14:59:29 UTC 2026


details:   http://freenginx.org/hg/nginx-tests/rev/30114671bcf3
branches:  
changeset: 2066:30114671bcf3
user:      Maxim Dounin <mdounin at mdounin.ru>
date:      Mon Jun 08 17:57:56 2026 +0300
description:
Tests: added auth_request_set tests with prefix variables.

diffstat:

 auth_request_set.t |  26 +++++++++++++++++++++++++-
 1 files changed, 25 insertions(+), 1 deletions(-)

diffs (55 lines):

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