blob: f1afe9ecbe5d288b60022fb4687c91ef656359cc [file] [log] [blame]
Frédéric Lécaillec11ec4a2018-12-14 20:07:57 +01001varnishtest "HTTP cookie basic test"
2feature 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
13syslog S1 -level notice {
Frédéric Lécaillec11ec4a2018-12-14 20:07:57 +010014 recv info
15 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: .* fe1 be1/srv1 .* --II .* \"GET / HTTP/1\\.1\""
16} -start
17
18server s1 {
19 rxreq
20 expect req.http.cookie == <undef>
21 txresp -hdr "Cookie: SRVID=S1"
22} -start
23
24haproxy h1 -conf {
25 global
26 log ${S1_addr}:${S1_port} len 2048 local0 debug err
27
28 defaults
29 mode http
Christopher Faulet8f161482018-12-19 11:49:39 +010030 ${no-htx} option http-use-htx
Frédéric Lécaillec11ec4a2018-12-14 20:07:57 +010031 option httplog
32 timeout client 1s
33 timeout server 1s
34 timeout connect 1s
35 log global
36
37 backend be1
38 cookie SRVID insert indirect
39 server srv1 ${s1_addr}:${s1_port} cookie server-one
40
41 frontend fe1
42 option httplog
43 bind "fd@${fe1}"
44 use_backend be1
45} -start
46
47client c1 -connect ${h1_fe1_sock} {
48 txreq -hdr "Cookie: SRVID=s2"
49 rxresp
50 expect resp.http.Set-Cookie ~ "^SRVID=server-one;.*"
51} -start
52
53
54client c1 -wait
55syslog S1 -wait