Marcin Deranek | da0264a | 2021-07-13 14:08:56 +0200 | [diff] [blame] | 1 | varnishtest "be2hex converter Test" |
| 2 | |
| 3 | feature cmd "$HAPROXY_PROGRAM -cc 'version_atleast(2.5-dev0)'" |
| 4 | feature ignore_unknown_macro |
| 5 | |
| 6 | server s1 { |
| 7 | rxreq |
| 8 | txresp |
| 9 | } -repeat 3 -start |
| 10 | |
| 11 | haproxy h1 -conf { |
| 12 | defaults |
| 13 | mode http |
Willy Tarreau | f673923 | 2021-11-18 17:46:22 +0100 | [diff] [blame] | 14 | timeout connect "${HAPROXY_TEST_TIMEOUT-5s}" |
| 15 | timeout client "${HAPROXY_TEST_TIMEOUT-5s}" |
| 16 | timeout server "${HAPROXY_TEST_TIMEOUT-5s}" |
Marcin Deranek | da0264a | 2021-07-13 14:08:56 +0200 | [diff] [blame] | 17 | |
| 18 | frontend fe |
| 19 | bind "fd@${fe}" |
| 20 | |
| 21 | #### requests |
| 22 | http-request set-var(txn.input) req.hdr(input) |
| 23 | |
| 24 | http-response set-header be2hex "%[var(txn.input),be2hex,lower]" |
| 25 | http-response set-header be2hex-1 "%[var(txn.input),be2hex(:,1),lower]" |
| 26 | http-response set-header be2hex-2 "%[var(txn.input),be2hex(--,3),lower]" |
| 27 | http-response set-header be2hex-3 "%[var(txn.input),be2hex(.,3,1),lower]" |
| 28 | |
| 29 | default_backend be |
| 30 | |
| 31 | backend be |
| 32 | server s1 ${s1_addr}:${s1_port} |
| 33 | } -start |
| 34 | |
| 35 | client c1 -connect ${h1_fe_sock} { |
| 36 | txreq -url "/" \ |
| 37 | -hdr "input:" |
| 38 | rxresp |
| 39 | expect resp.status == 200 |
| 40 | expect resp.http.be2hex == "" |
| 41 | expect resp.http.be2hex-1 == "" |
| 42 | expect resp.http.be2hex-2 == "" |
| 43 | expect resp.http.be2hex-3 == "" |
| 44 | txreq -url "/" \ |
| 45 | -hdr "input: 0123456789" |
| 46 | rxresp |
| 47 | expect resp.status == 200 |
| 48 | expect resp.http.be2hex == "30313233343536373839" |
| 49 | expect resp.http.be2hex-1 == "30:31:32:33:34:35:36:37:38:39" |
| 50 | expect resp.http.be2hex-2 == "303132--333435--363738--39" |
| 51 | expect resp.http.be2hex-3 == "303132.333435.363738" |
| 52 | txreq -url "/" \ |
| 53 | -hdr "input: abcdefghijklmnopqrstuvwxyz" |
| 54 | rxresp |
| 55 | expect resp.status == 200 |
| 56 | expect resp.http.be2hex == "6162636465666768696a6b6c6d6e6f707172737475767778797a" |
| 57 | expect resp.http.be2hex-1 == "61:62:63:64:65:66:67:68:69:6a:6b:6c:6d:6e:6f:70:71:72:73:74:75:76:77:78:79:7a" |
| 58 | expect resp.http.be2hex-2 == "616263--646566--676869--6a6b6c--6d6e6f--707172--737475--767778--797a" |
| 59 | expect resp.http.be2hex-3 == "616263.646566.676869.6a6b6c.6d6e6f.707172.737475.767778" |
| 60 | } -run |