]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
REGTEST: add an extra testcase for ifnone-forwardfor
authorAurelien DARRAGON <adarragon@haproxy.com>
Tue, 20 Jun 2023 13:02:11 +0000 (15:02 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 20 Jun 2023 13:33:01 +0000 (15:33 +0200)
In GH #2187 it was mentioned that the ifnone-forwardfor regtest
did not cover the case where forwardfor ifnone is explicitly set in
the frontend but forwardfor option is not used in the backend.

Expected behavior in this case is that the frontend takes the precedence
because the backend did not specify the option.

Adding this missing case to prevent regressions in the future.

reg-tests/http-rules/ifnone-forwardfor.vtc

index 87f5d38271e983d67f026f4a8c8ccca0fd017cb3..4be82ac2f9849c6acfaf3e6bc379857d5b0402f9 100644 (file)
@@ -24,6 +24,7 @@ haproxy h1 -conf {
        option forwardfor if-none
        use_backend be1 if { path /req1 }
        use_backend be2 if { path /req2 }
+       use_backend be3 if { path /req3 }
 
     frontend normal
         bind "fd@${normal}"
@@ -44,6 +45,9 @@ haproxy h1 -conf {
     backend be2
         option forwardfor if-none
         server s1 ${h1_fe2_addr}:${h1_fe2_port}
+
+    backend be3
+        server s1 ${h1_fe2_addr}:${h1_fe2_port}
 } -start
 
 client c1 -connect ${h1_none_sock} {
@@ -67,6 +71,13 @@ client c1 -connect ${h1_none_sock} {
     expect resp.status == 200
     expect resp.http.x-ff == 1
 
+    txreq -req GET -url /req3 \
+        -hdr "x-src: 10.0.0.128" \
+        -hdr "x-forwarded-for: 127.0.0.1"
+    rxresp
+    expect resp.status == 200
+    expect resp.http.x-ff == 1
+
 } -run
 
 client c1 -connect ${h1_normal_sock} {