Tim Duesterhus | d437630 | 2019-06-17 12:41:44 +0200 | [diff] [blame] | 1 | varnishtest "sha2 converter Test" |
| 2 | |
| 3 | #REQUIRE_VERSION=2.1 |
| 4 | #REQUIRE_OPTION=OPENSSL |
| 5 | |
| 6 | feature ignore_unknown_macro |
| 7 | |
| 8 | server s1 { |
| 9 | rxreq |
| 10 | txresp |
Tim Duesterhus | cd37324 | 2019-12-17 12:31:20 +0100 | [diff] [blame] | 11 | } -repeat 2 -start |
Tim Duesterhus | d437630 | 2019-06-17 12:41:44 +0200 | [diff] [blame] | 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}" |
Tim Duesterhus | d437630 | 2019-06-17 12:41:44 +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 | |
| 26 | http-response set-header SHA2 "%[var(txn.hash),sha2,hex,lower]" |
| 27 | http-response set-header SHA2-224 "%[var(txn.hash),sha2(224),hex,lower]" |
| 28 | http-response set-header SHA2-256 "%[var(txn.hash),sha2(256),hex,lower]" |
| 29 | http-response set-header SHA2-384 "%[var(txn.hash),sha2(384),hex,lower]" |
| 30 | http-response set-header SHA2-512 "%[var(txn.hash),sha2(512),hex,lower]" |
Tim Duesterhus | d437630 | 2019-06-17 12:41:44 +0200 | [diff] [blame] | 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.sha2 == "6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b" |
| 44 | expect resp.http.sha2-224 == "e25388fde8290dc286a6164fa2d97e551b53498dcbf7bc378eb1f178" |
| 45 | expect resp.http.sha2-256 == "6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b" |
| 46 | expect resp.http.sha2-384 == "47f05d367b0c32e438fb63e6cf4a5f35c2aa2f90dc7543f8a41a0f95ce8a40a313ab5cf36134a2068c4c969cb50db776" |
| 47 | expect resp.http.sha2-512 == "4dff4ea340f0a823f15d3f4f01ab62eae0e5da579ccb851f8db9dfe84c58b2b37b89903a740e1ee172da793a6e79d560e5f7f9bd058a12a280433ed6fa46510a" |
Tim Duesterhus | d437630 | 2019-06-17 12:41:44 +0200 | [diff] [blame] | 48 | txreq -url "/" \ |
| 49 | -hdr "Hash: 2" |
| 50 | rxresp |
| 51 | expect resp.status == 200 |
| 52 | expect resp.http.sha2 == "d4735e3a265e16eee03f59718b9b5d03019c07d8b6c51f90da3a666eec13ab35" |
| 53 | expect resp.http.sha2-224 == "58b2aaa0bfae7acc021b3260e941117b529b2e69de878fd7d45c61a9" |
| 54 | expect resp.http.sha2-256 == "d4735e3a265e16eee03f59718b9b5d03019c07d8b6c51f90da3a666eec13ab35" |
| 55 | expect resp.http.sha2-384 == "d063457705d66d6f016e4cdd747db3af8d70ebfd36badd63de6c8ca4a9d8bfb5d874e7fbd750aa804dcaddae7eeef51e" |
| 56 | expect resp.http.sha2-512 == "40b244112641dd78dd4f93b6c9190dd46e0099194d5a44257b7efad6ef9ff4683da1eda0244448cb343aa688f5d3efd7314dafe580ac0bcbf115aeca9e8dc114" |
Tim Duesterhus | d437630 | 2019-06-17 12:41:44 +0200 | [diff] [blame] | 57 | } -run |