summaryrefslogtreecommitdiffstats
path: root/reg-tests/log/last_rule.vtc
blob: f2b89e491830d4c03955e46232f8c19266c49699 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
varnishtest "Verify logging of last final rule"

feature cmd "$HAPROXY_PROGRAM -cc 'version_atleast(2.6-dev0)'"
feature ignore_unknown_macro

server s1 {
    rxreq
    txresp
} -repeat 15 -start

syslog Slg_1 -level info {
    recv
    # /trqacc1
    expect ~ "[^:\\[ ]\\[${h1_pid}\\]: .* lr=.*/h1/cfg:30"
    recv
    expect ~ "[^:\\[ ]\\[${h1_pid}\\]: .* lr=.*/h1/cfg:31"
    recv
    expect ~ "[^:\\[ ]\\[${h1_pid}\\]: .* lr=.*/h1/cfg:32"
    recv
    # /trsacc1
    expect ~ "[^:\\[ ]\\[${h1_pid}\\]: .* lr=.*/h1/cfg:36"
    recv
    expect ~ "[^:\\[ ]\\[${h1_pid}\\]: .* lr=.*/h1/cfg:37"
    recv
    expect ~ "[^:\\[ ]\\[${h1_pid}\\]: .* lr=.*/h1/cfg:38"
    recv
    # /hrqvar
    expect ~ "[^:\\[ ]\\[${h1_pid}\\]: .* lr=.*-:-"
    recv
    expect ~ "[^:\\[ ]\\[${h1_pid}\\]: .* lr=.*/h1/cfg:41"
    recv
    expect ~ "[^:\\[ ]\\[${h1_pid}\\]: .* lr=.*/h1/cfg:42"
    recv
    expect ~ "[^:\\[ ]\\[${h1_pid}\\]: .* lr=.*/h1/cfg:43"
    recv
    expect ~ "[^:\\[ ]\\[${h1_pid}\\]: .* lr=.*/h1/cfg:44"
    recv
    # /hrsacc1
    expect ~ "[^:\\[ ]\\[${h1_pid}\\]: .* lr=.*/h1/cfg:46"
    recv
    expect ~ "[^:\\[ ]\\[${h1_pid}\\]: .* lr=.*/h1/cfg:47"
    recv
    expect ~ "[^:\\[ ]\\[${h1_pid}\\]: .* lr=.*/h1/cfg:48"
    recv
    expect ~ "[^:\\[ ]\\[${h1_pid}\\]: .* lr=.*/h1/cfg:49"
} -start

haproxy h1 -conf {
    global
        nbthread 1

    defaults
        mode http
        option httplog
	option http-server-close
        timeout connect "${HAPROXY_TEST_TIMEOUT-5s}"
        timeout client  "${HAPROXY_TEST_TIMEOUT-5s}"
        timeout server  "${HAPROXY_TEST_TIMEOUT-5s}"

    frontend fe1
        bind "fd@${fe_1}"
        log ${Slg_1_addr}:${Slg_1_port} local0
        log-format "ci:%cp [%tr] lr=%[last_rule_file]:%[last_rule_line]"
        default_backend be

    backend be
        # handle these URLs:
	#  /trqacc1, /trqrej1, /trqrej2, /trsacc1, /trsrej1, /trsrej2
	#  /hrqvar, /hrqacc1, /hrqred1, /hrqrej1, /hrqrej2,
	#  /hrsacc1, /hrsred1, /hrsrej1, /hrsrej2

	tcp-response inspect-delay 100ms
        tcp-request  content set-var(txn.path) path  # must have no effect
        tcp-request  content accept if { var(txn.path) -m beg /trqacc1 /hrqrej1 }
        tcp-request  content reject if { var(txn.path) -m beg /trqrej1 }
        tcp-request  content reject if { var(txn.path) -m beg /trqrej2 }

	tcp-response content reject unless WAIT_END
        tcp-response content set-var(txn.foo) var(txn.path) # must have no effect
        tcp-response content accept if { var(txn.path) -m beg /trsacc1 /hrsrej1 }
        tcp-response content reject if { var(txn.path) -m beg /trsrej1 }
        tcp-response content reject if { var(txn.path) -m beg /trsrej2 }

        http-request set-var(txn.bar) var(txn.path) if { path_beg /hrqvar }  # must have no effect
        http-request allow if { var(txn.path) -m beg /hrqacc1 /hrsrej2 }
        http-request redirect location / if { var(txn.path) -m beg /hrqred1 }
        http-request deny if { var(txn.path) -m beg /hrqrej1 } # accepted by tcp-rq above
        http-request deny if { var(txn.path) -m beg /hrqrej2 }

        http-response allow if { var(txn.path) -m beg /hrsacc1 }
        http-response redirect location / if { var(txn.path) -m beg /hrsred1 }
        http-response deny if { var(txn.path) -m beg /hrsrej1 } # accepted by tcp-rs above
        http-response deny if { var(txn.path) -m beg /hrsrej2 } # accepted by http-rq above
        http-response deny if { var(txn.path) -m beg /hrsrej3 }

        server app1 ${s1_addr}:${s1_port}
} -start

client c1 -connect ${h1_fe_1_sock} {
    txreq -url /trqacc1
    rxresp

    txreq -url /trqrej1
    expect_close
} -run

# The following client are started in background and synchronized
client c2 -connect ${h1_fe_1_sock} {
    txreq -url /trqrej2
    expect_close
} -run

client c3 -connect ${h1_fe_1_sock} {
    txreq -url /trsacc1
    rxresp
    expect resp.status == 200

    txreq -url /trsrej1
    expect_close
} -run

client c4 -connect ${h1_fe_1_sock} {
    txreq -url /trsrej2
    expect_close
} -run

client c5 -connect ${h1_fe_1_sock} {
    txreq -url /hrqvar
    rxresp
    expect resp.status == 200

    txreq -url /hrqacc1
    rxresp
    expect resp.status == 200

    txreq -url /hrqred1
    rxresp
    expect resp.status == 302

    txreq -url /hrqrej1
    rxresp
    expect resp.status == 403

    txreq -url /hrqrej2
    rxresp
    expect resp.status == 403

    txreq -url /hrsacc1
    rxresp
    expect resp.status == 200

    txreq -url /hrsred1
    rxresp
    expect resp.status == 302

    txreq -url /hrsrej1
    rxresp
    expect resp.status == 502

    txreq -url /hrsrej2
    rxresp
    expect resp.status == 502
} -run

syslog Slg_1 -wait