Patrick Gansterer | 8e36651 | 2020-04-22 16:47:57 +0200 | [diff] [blame] | 1 | varnishtest "HMAC converter Test" |
| 2 | |
| 3 | #REQUIRE_VERSION=2.2 |
| 4 | #REQUIRE_OPTION=OPENSSL |
| 5 | |
| 6 | feature ignore_unknown_macro |
| 7 | |
| 8 | server s1 { |
| 9 | rxreq |
| 10 | txresp |
| 11 | } -repeat 2 -start |
| 12 | |
| 13 | haproxy h1 -conf { |
| 14 | defaults |
| 15 | mode http |
Willy Tarreau | f673923 | 2021-11-18 17:46:22 +0100 | [diff] [blame] | 16 | timeout connect "${HAPROXY_TEST_TIMEOUT-5s}" |
| 17 | timeout client "${HAPROXY_TEST_TIMEOUT-5s}" |
| 18 | timeout server "${HAPROXY_TEST_TIMEOUT-5s}" |
Patrick Gansterer | 8e36651 | 2020-04-22 16:47:57 +0200 | [diff] [blame] | 19 | |
| 20 | frontend fe |
| 21 | bind "fd@${fe}" |
| 22 | |
| 23 | #### requests |
| 24 | http-request set-var(txn.hash) req.hdr(hash) |
| 25 | http-request set-var(txn.key) str(my_super_secret_long_key),base64 |
| 26 | |
| 27 | http-response set-header SHA1-short "%[var(txn.hash),hmac(sha1,a2V5),hex,lower]" |
| 28 | http-response set-header SHA1-long "%[var(txn.hash),hmac(sha1,txn.key),hex,lower]" |
| 29 | http-response set-header SHA256-short "%[var(txn.hash),hmac(sha256,a2V5),hex,lower]" |
| 30 | http-response set-header SHA256-long "%[var(txn.hash),hmac(sha256,txn.key),hex,lower]" |
| 31 | |
| 32 | default_backend be |
| 33 | |
| 34 | backend be |
| 35 | server s1 ${s1_addr}:${s1_port} |
| 36 | } -start |
| 37 | |
| 38 | client c1 -connect ${h1_fe_sock} { |
| 39 | txreq -url "/" \ |
| 40 | -hdr "Hash: 1" |
| 41 | rxresp |
| 42 | expect resp.status == 200 |
| 43 | expect resp.http.sha1-short == "e23feb105f9622241bf23db1638cd2b4208b1f53" |
| 44 | expect resp.http.sha1-long == "87b10ddcf39e26f6bd7c3b0e38e0125997b255be" |
| 45 | expect resp.http.sha256-short == "6da91fb91517be1f5cdcf3af91d7d40c717dd638a306157606fb2e584f7ae926" |
| 46 | expect resp.http.sha256-long == "2fb3de6a462c54d1803f946b52202f3a8cd46548ffb3f789b4ac11a4361ffef2" |
| 47 | txreq -url "/" \ |
| 48 | -hdr "Hash: 2" |
| 49 | rxresp |
| 50 | expect resp.status == 200 |
| 51 | expect resp.http.sha1-short == "311219c4a80c5ef81b1cee5505236c1d0ab1922c" |
| 52 | expect resp.http.sha1-long == "c5758af565ba4b87b3db49c8b32d4a94d430cb78" |
| 53 | expect resp.http.sha256-short == "ae7b3ee87b8c9214f714df1c2042c7a985b9d711e9938a063937ad1636775a88" |
| 54 | expect resp.http.sha256-long == "c073191a2ebf29f510444b92c187d62199d84b58f58dceeadb91994c170a9a16" |
| 55 | } -run |