Skip to content

Commit 456ce69

Browse files
authored
autest: adds a hrw test for LAST-CAPTURE group (#12814)
1 parent 1250319 commit 456ce69

2 files changed

Lines changed: 46 additions & 18 deletions

File tree

tests/gold_tests/pluginTest/header_rewrite/header_rewrite_bundle.replay.yaml

Lines changed: 41 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -754,17 +754,42 @@ sessions:
754754
- [ X-Match-2, { value: yes, as: equal } ]
755755
- [ X-Match, { as: absent } ]
756756

757-
# Test 19: set-body with empty string
757+
# Test 19: Regex test - query parameter capture
758758
- transactions:
759759
- client-request:
760760
method: "GET"
761761
version: "1.1"
762-
url: /from_10/
762+
url: /from_9/?uid=123
763763
headers:
764764
fields:
765765
- [ Host, www.example.com ]
766766
- [ uuid, 25 ]
767767

768+
server-response:
769+
status: 200
770+
reason: OK
771+
headers:
772+
fields:
773+
- [ Connection, close ]
774+
775+
proxy-response:
776+
status: 200
777+
headers:
778+
fields:
779+
- [ X-Match-3, { value: "123", as: equal } ]
780+
- [ X-Match-2, { as: absent } ]
781+
782+
# Test 20: set-body with empty string
783+
- transactions:
784+
- client-request:
785+
method: "GET"
786+
version: "1.1"
787+
url: /from_10/
788+
headers:
789+
fields:
790+
- [ Host, www.example.com ]
791+
- [ uuid, 26 ]
792+
768793
server-response:
769794
status: 200
770795
reason: OK
@@ -784,7 +809,7 @@ sessions:
784809
content:
785810
size: 0
786811

787-
# Test 20: set-body with STATUS variable
812+
# Test 21: set-body with STATUS variable
788813
- transactions:
789814
- client-request:
790815
method: "GET"
@@ -793,7 +818,7 @@ sessions:
793818
headers:
794819
fields:
795820
- [ Host, www.example.com ]
796-
- [ uuid, 26 ]
821+
- [ uuid, 27 ]
797822

798823
server-response:
799824
status: 200
@@ -814,7 +839,7 @@ sessions:
814839
content:
815840
data: "200"
816841

817-
# Test 21: Nested if/elif/else - X-Foo=foo + X-Bar=bar path
842+
# Test 22: Nested if/elif/else - X-Foo=foo + X-Bar=bar path
818843
- transactions:
819844
- client-request:
820845
method: "GET"
@@ -825,7 +850,7 @@ sessions:
825850
- [ Host, www.example.com ]
826851
- [ X-Foo, "foo" ]
827852
- [ X-Bar, "bar" ]
828-
- [ uuid, 27 ]
853+
- [ uuid, 28 ]
829854

830855
server-response:
831856
status: 200
@@ -845,7 +870,7 @@ sessions:
845870
- [ X-Fie-Anywhere, { as: absent } ]
846871
- [ X-When-200-After, { value: "Yes", as: equal } ]
847872

848-
# Test 22: Nested if/elif/else - X-Foo=foo + X-Fie=fie path
873+
# Test 23: Nested if/elif/else - X-Foo=foo + X-Fie=fie path
849874
- transactions:
850875
- client-request:
851876
method: "GET"
@@ -856,7 +881,7 @@ sessions:
856881
- [ Host, www.example.com ]
857882
- [ X-Foo, "foo" ]
858883
- [ X-Fie, "fie" ]
859-
- [ uuid, 28 ]
884+
- [ uuid, 29 ]
860885

861886
server-response:
862887
status: 200
@@ -876,7 +901,7 @@ sessions:
876901
- [ X-Fie-Anywhere, { value: "Yes", as: equal } ]
877902
- [ X-When-200-After, { value: "Yes", as: equal } ]
878903

879-
# Test 23: Nested if/elif/else - X-Foo=maybe path
904+
# Test 24: Nested if/elif/else - X-Foo=maybe path
880905
- transactions:
881906
- client-request:
882907
method: "GET"
@@ -886,7 +911,7 @@ sessions:
886911
fields:
887912
- [ Host, www.example.com ]
888913
- [ X-Foo, "maybe" ]
889-
- [ uuid, 29 ]
914+
- [ uuid, 30 ]
890915

891916
server-response:
892917
status: 200
@@ -906,7 +931,7 @@ sessions:
906931
- [ X-Fie-Anywhere, { as: absent } ]
907932
- [ X-When-200-After, { value: "Yes", as: equal } ]
908933

909-
# Test 24: Nested if/elif/else - X-Foo=definitely path
934+
# Test 25: Nested if/elif/else - X-Foo=definitely path
910935
- transactions:
911936
- client-request:
912937
method: "GET"
@@ -916,7 +941,7 @@ sessions:
916941
fields:
917942
- [ Host, www.example.com ]
918943
- [ X-Foo, "definitely" ]
919-
- [ uuid, 30 ]
944+
- [ uuid, 31 ]
920945

921946
server-response:
922947
status: 200
@@ -936,7 +961,7 @@ sessions:
936961
- [ X-Fie-Anywhere, { as: absent } ]
937962
- [ X-When-200-After, { value: "Yes", as: equal } ]
938963

939-
# Test 25: Nested if/elif/else - else path (no X-Foo)
964+
# Test 26: Nested if/elif/else - else path (no X-Foo)
940965
- transactions:
941966
- client-request:
942967
method: "GET"
@@ -945,7 +970,7 @@ sessions:
945970
headers:
946971
fields:
947972
- [ Host, www.example.com ]
948-
- [ uuid, 31 ]
973+
- [ uuid, 32 ]
949974

950975
server-response:
951976
status: 200
@@ -965,7 +990,7 @@ sessions:
965990
- [ X-Fie-Anywhere, { as: absent } ]
966991
- [ X-When-200-After, { value: "Yes", as: equal } ]
967992

968-
# Test 26: Nested if/elif/else - else path with X-Fie
993+
# Test 27: Nested if/elif/else - else path with X-Fie
969994
- transactions:
970995
- client-request:
971996
method: "GET"
@@ -975,7 +1000,7 @@ sessions:
9751000
fields:
9761001
- [ Host, www.example.com ]
9771002
- [ X-Fie, "fie" ]
978-
- [ uuid, 32 ]
1003+
- [ uuid, 33 ]
9791004

9801005
server-response:
9811006
status: 200

tests/gold_tests/pluginTest/header_rewrite/rules/regex_tests.conf

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@ cond %{CLIENT-HEADER:X-Test1} /^[Ff]o+[bB]ar/
2020
set-header X-Match "yes"
2121

2222
cond %{SEND_RESPONSE_HDR_HOOK} [AND]
23-
cond %{CLIENT-HEADER:X-We-Set} /^fie[0-9]+fum$/ [NOCASE]
24-
set-header X-Match-2 "yes"
23+
cond %{CLIENT-URL:QUERY} /uid=([0-9]+)/
24+
set-header X-Match-3 "%{LAST-CAPTURE:1}"
25+
elif
26+
cond %{CLIENT-HEADER:X-We-Set} /^fie[0-9]+fum$/ [NOCASE]
27+
set-header X-Match-2 "yes"
2528

2629
cond %{REMAP_PSEUDO_HOOK} [AND]
2730
cond %{CLIENT-URL:PATH} /^from/

0 commit comments

Comments
 (0)