blob: fc21b4133a085e54262fbb4f249be9e876cff508 [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
9 lua-load ${testdir}/set_var.lua
10
11 frontend fe1
12 mode http
13 ${no-htx} option http-use-htx
14 bind "fd@${fe1}"
15
16 http-request use-service lua.set_var
Tim Duesterhus4e172c92020-05-19 13:49:42 +020017
18 frontend fe2
19 mode http
20 ${no-htx} option http-use-htx
21 bind "fd@${fe2}"
22
23 http-request set-header Dummy %[var(txn.fe2_foo)]
24
25 http-request use-service lua.set_var_ifexist
Tim Duesterhus84ebc132020-05-19 13:49:41 +020026} -start
27
28client c0 -connect ${h1_fe1_sock} {
29 txreq -url "/" \
Tim Duesterhus4e172c92020-05-19 13:49:42 +020030 -hdr "Var: txn.fe1_foo"
Tim Duesterhus84ebc132020-05-19 13:49:41 +020031 rxresp
32 expect resp.status == 202
33 expect resp.http.echo == "value"
34 txreq -url "/" \
35 -hdr "Var: invalid.var"
36 rxresp
37 expect resp.status == 400
38 expect resp.http.echo == "(nil)"
39} -run
Tim Duesterhus4e172c92020-05-19 13:49:42 +020040
41client c1 -connect ${h1_fe2_sock} {
42 txreq -url "/" \
43 -hdr "Var: txn.fe2_foo"
44 rxresp
45 expect resp.status == 202
46 expect resp.http.echo == "value"
47 txreq -url "/" \
48 -hdr "Var: txn.fe2_bar"
49 rxresp
50 expect resp.status == 400
51 expect resp.http.echo == "(nil)"
52} -run