summaryrefslogtreecommitdiffstats
path: root/reg-tests/converter/hmac.vtc
blob: 230a44d6d03d2d0842b66471bdd9cd3c3f7f9b62 (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
varnishtest "HMAC converter Test"

#REQUIRE_VERSION=2.2
#REQUIRE_OPTION=OPENSSL

feature ignore_unknown_macro

server s1 {
	rxreq
	txresp -hdr "Connection: close"
} -repeat 2 -start

haproxy h1 -conf {
    defaults
	mode http
	timeout connect "${HAPROXY_TEST_TIMEOUT-5s}"
	timeout client  "${HAPROXY_TEST_TIMEOUT-5s}"
	timeout server  "${HAPROXY_TEST_TIMEOUT-5s}"

    frontend fe
	bind "fd@${fe}"

	#### requests
	http-request  set-var(txn.hash) req.hdr(hash)
	http-request  set-var(txn.key) str(my_super_secret_long_key),base64

	http-response set-header SHA1-short   "%[var(txn.hash),hmac(sha1,a2V5),hex,lower]"
	http-response set-header SHA1-long   "%[var(txn.hash),hmac(sha1,txn.key),hex,lower]"
	http-response set-header SHA256-short   "%[var(txn.hash),hmac(sha256,a2V5),hex,lower]"
	http-response set-header SHA256-long   "%[var(txn.hash),hmac(sha256,txn.key),hex,lower]"

	default_backend be

    backend be
	server s1 ${s1_addr}:${s1_port}
} -start

client c1 -connect ${h1_fe_sock} {
	txreq -url "/" \
	  -hdr "Hash: 1"
	rxresp
	expect resp.status == 200
	expect resp.http.sha1-short == "e23feb105f9622241bf23db1638cd2b4208b1f53"
	expect resp.http.sha1-long == "87b10ddcf39e26f6bd7c3b0e38e0125997b255be"
	expect resp.http.sha256-short == "6da91fb91517be1f5cdcf3af91d7d40c717dd638a306157606fb2e584f7ae926"
	expect resp.http.sha256-long == "2fb3de6a462c54d1803f946b52202f3a8cd46548ffb3f789b4ac11a4361ffef2"
	txreq -url "/" \
	  -hdr "Hash: 2"
	rxresp
	expect resp.status == 200
	expect resp.http.sha1-short == "311219c4a80c5ef81b1cee5505236c1d0ab1922c"
	expect resp.http.sha1-long == "c5758af565ba4b87b3db49c8b32d4a94d430cb78"
	expect resp.http.sha256-short == "ae7b3ee87b8c9214f714df1c2042c7a985b9d711e9938a063937ad1636775a88"
	expect resp.http.sha256-long == "c073191a2ebf29f510444b92c187d62199d84b58f58dceeadb91994c170a9a16"
} -run