blob: af4cbf1eb6eade08a4210e2ed229b990767c370e [file] [log] [blame]
Tim Duesterhus84ebc132020-05-19 13:49:41 +02001varnishtest "Lua: set_var"
Christopher Faulet80f59e52020-05-26 11:11:23 +02002#REQUIRE_VERSION=2.2
Tim Duesterhus84ebc132020-05-19 13:49:41 +02003#REQUIRE_OPTIONS=LUA
4
5feature ignore_unknown_macro
6
7haproxy h1 -conf {
8 global
Willy Tarreaue1465c12021-05-09 14:41:41 +02009 # WT: limit false-positives causing "HTTP header incomplete" due to
10 # idle server connections being randomly used and randomly expiring
11 # under us.
12 tune.idle-pool.shared off
13
14 global
Tim Duesterhus84ebc132020-05-19 13:49:41 +020015 lua-load ${testdir}/set_var.lua
16
17 frontend fe1
18 mode http
19 ${no-htx} option http-use-htx
20 bind "fd@${fe1}"
21
22 http-request use-service lua.set_var
Tim Duesterhus4e172c92020-05-19 13:49:42 +020023
24 frontend fe2
25 mode http
26 ${no-htx} option http-use-htx
27 bind "fd@${fe2}"
28
29 http-request set-header Dummy %[var(txn.fe2_foo)]
30
31 http-request use-service lua.set_var_ifexist
Tim Duesterhus84ebc132020-05-19 13:49:41 +020032} -start
33
34client c0 -connect ${h1_fe1_sock} {
35 txreq -url "/" \
Tim Duesterhus4e172c92020-05-19 13:49:42 +020036 -hdr "Var: txn.fe1_foo"
Tim Duesterhus84ebc132020-05-19 13:49:41 +020037 rxresp
38 expect resp.status == 202
39 expect resp.http.echo == "value"
40 txreq -url "/" \
41 -hdr "Var: invalid.var"
42 rxresp
43 expect resp.status == 400
44 expect resp.http.echo == "(nil)"
45} -run
Tim Duesterhus4e172c92020-05-19 13:49:42 +020046
47client c1 -connect ${h1_fe2_sock} {
48 txreq -url "/" \
49 -hdr "Var: txn.fe2_foo"
50 rxresp
51 expect resp.status == 202
52 expect resp.http.echo == "value"
53 txreq -url "/" \
54 -hdr "Var: txn.fe2_bar"
55 rxresp
56 expect resp.status == 400
57 expect resp.http.echo == "(nil)"
58} -run