Frédéric Lécaille | c11ec4a | 2018-12-14 20:07:57 +0100 | [diff] [blame] | 1 | varnishtest "HTTP cookie basic test" |
| 2 | feature ignore_unknown_macro |
| 3 | |
| 4 | # This script tests "cookie <name> insert indirect" directive. |
| 5 | # The client sends a wrong "SRVID=s2" cookie. |
| 6 | # haproxy removes it. |
| 7 | # The server replies with "SRVID=S1" after having checked that |
| 8 | # no cookies were sent by haproxy. |
| 9 | # haproxy replies "SRVID=server-one" to the client. |
| 10 | # We log the HTTP request to a syslog server and check their "--II" |
| 11 | # (invalid, insert) flags. |
| 12 | |
| 13 | syslog S1 -level notice { |
Frédéric Lécaille | c11ec4a | 2018-12-14 20:07:57 +0100 | [diff] [blame] | 14 | recv info |
| 15 | expect ~ "[^:\\[ ]\\[${h1_pid}\\]: .* fe1 be1/srv1 .* --II .* \"GET / HTTP/1\\.1\"" |
| 16 | } -start |
| 17 | |
| 18 | server s1 { |
| 19 | rxreq |
| 20 | expect req.http.cookie == <undef> |
| 21 | txresp -hdr "Cookie: SRVID=S1" |
| 22 | } -start |
| 23 | |
| 24 | haproxy h1 -conf { |
| 25 | global |
| 26 | log ${S1_addr}:${S1_port} len 2048 local0 debug err |
| 27 | |
| 28 | defaults |
| 29 | mode http |
Frédéric Lécaille | c11ec4a | 2018-12-14 20:07:57 +0100 | [diff] [blame] | 30 | option httplog |
Willy Tarreau | f673923 | 2021-11-18 17:46:22 +0100 | [diff] [blame^] | 31 | timeout client "${HAPROXY_TEST_TIMEOUT-5s}" |
| 32 | timeout server "${HAPROXY_TEST_TIMEOUT-5s}" |
| 33 | timeout connect "${HAPROXY_TEST_TIMEOUT-5s}" |
Frédéric Lécaille | c11ec4a | 2018-12-14 20:07:57 +0100 | [diff] [blame] | 34 | log global |
| 35 | |
| 36 | backend be1 |
| 37 | cookie SRVID insert indirect |
| 38 | server srv1 ${s1_addr}:${s1_port} cookie server-one |
| 39 | |
| 40 | frontend fe1 |
| 41 | option httplog |
| 42 | bind "fd@${fe1}" |
| 43 | use_backend be1 |
| 44 | } -start |
| 45 | |
| 46 | client c1 -connect ${h1_fe1_sock} { |
| 47 | txreq -hdr "Cookie: SRVID=s2" |
| 48 | rxresp |
| 49 | expect resp.http.Set-Cookie ~ "^SRVID=server-one;.*" |
| 50 | } -start |
| 51 | |
| 52 | |
| 53 | client c1 -wait |
| 54 | syslog S1 -wait |