pike.git / src / post_modules / HPack / testsuite.in

version» Context lines:

pike.git/src/post_modules/HPack/testsuite.in:1: + dnl -*- coding: utf-8; -*- + START_MARKER    -  + test_compile_error( H ) + test_compile_error( S ) + test_do( add_constant( "H", String.hex2string ) ) + test_do( add_constant( "S", String.string2hex ) ) +  + dnl First some tests that the huffman codec works. +  + dnl string + define(test_huffman_simple, [[ +  test_eq(Standards.HPack.huffman_decode(Standards.HPack.huffman_encode([[$1]])),[[$1]]) + ]]) +  + dnl string, huffman_hex + define(test_huffman_low, [[ +  test_eq(S(Standards.HPack.huffman_encode([[$1]])), [[$2 - " " - "\n" - "\t"]]) +  test_eq(Standards.HPack.huffman_decode(H([[$2]])), [[$1]]) +  test_huffman_simple([[$1]]) + ]]) +  + dnl text, huffman_hex + define(test_huffman, [[ +  test_huffman_low([["$1"]], [[#"$2"]]) + ]]) +  + dnl The test vectors from RFC 7541 appendix C: +  + dnl RFC 7541 C.4.1 + test_huffman([[www.example.com]], [[f1e3 c2e5 f23a 6ba0 ab90 f4ff]]) +  + dnl RFC 7541 C.4.2 + test_huffman([[no-cache]], [[a8eb 1064 9cbf]]) +  + dnl RFC 7541 C.4.3 + test_huffman([[custom-key]], [[25a8 49e9 5ba9 7d7f]]) + test_huffman([[custom-value]], [[25a8 49e9 5bb8 e8b4 bf]]) +  + dnl RFC 7541 C.6.1 + test_huffman([[302]], [[6402]]) + test_huffman([[private]], [[aec3 771a 4b]]) + test_huffman([[Mon, 21 Oct 2013 20:13:21 GMT]], +  [[d07a be94 1054 d444 a820 0595 040b 8166 e082 a62d 1bff]]) + test_huffman([[https://www.example.com]], +  [[9d29 ad17 1863 c78f 0b97 c8e9 ae82 ae43 d3]]) +  + dnl RFC 7541 C.6.2 + test_huffman([[307]], [[640e ff]]) +  + dnl RFC 7541 C.6.3 + test_huffman([[Mon, 21 Oct 2013 20:13:22 GMT]], +  [[d07a be94 1054 d444 a820 0595 040b 8166 e084 a62d 1bff]]) + test_huffman([[gzip]], [[9bd9 ab]]) + test_huffman([[foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1]], +  [[94e7 821d d7f2 e6c7 b335 dfdf cd5b 3960 +  d5af 2708 7f36 72c1 ab27 0fb5 291f 9587 +  3160 65c0 03ed 4ee5 b106 3d50 07]]) +  + dnl RFC 7541 doesn't contain any vectors that contain characters that + dnl encode to more than one byte, so add one of our own. + dnl This string used to trigger a buffering bug in the encoder. + test_huffman_low(H("c5206920e56120e4206520f62e"), +  "ffffe4a194ffff38d4ffffa542a9fffffa57") +  + dnl Test that all characters are both encodable and decodeable. + test_huffman_simple([[(string)enumerate(256)]]) +  + dnl Test that we don't have any strange special cases. + test_do(add_constant("test_data", random_string(8192))) + test_huffman_simple([[test_data]]) +  + test_do(add_constant("test_data")); +  + dnl Then some tests of encoding and decoding full HPack. +  + test_do([[add_constant("D", Standards.HPack.Context(256));]]) + test_do([[add_constant("E", Standards.HPack.Context(256));]]) + test_do([[add_constant("F", Standards.HPack.Context(256));]]) +  + dnl ref-encoding, header-array + define(test_hpack, [[ +  test_equal(D->decode(H([[$1]])), [[$2]]) +  test_equal(F->decode(E->encode([[$2]])), [[$2]]) + ]]) +  + dnl RFC 7541 C.2.1 + test_hpack("400a 6375 7374 6f6d 2d6b 6579 0d63 7573 746f 6d2d 6865 6164 6572", +  [[({ ({ "custom-key", "custom-header" }) })]]) +  + dnl RFC 7541 C.2.2 + test_hpack("040c 2f73 616d 706c 652f 7061 7468", +  [[({ ({ ":path", "/sample/path" }) })]]) +  + dnl RFC 7541 C.2.3 + test_hpack("1008 7061 7373 776f 7264 0673 6563 7265 74", +  [[({ ({ "password", "secret", Standards.HPack.HEADER_NEVER_INDEXED }) })]]) +  + dnl RFC 7541 C.2.4 + test_hpack("82", +  [[({ ({ ":method", "GET" }) })]]) +  + dnl RFC 7541 C.3.1 + test_hpack("8286 8441 0f77 7777 2e65 7861 6d70 6c65 2e63 6f6d", +  [[({ ({ ":method", "GET" }), +  ({ ":scheme", "http" }), +  ({ ":path", "/" }), +  ({ ":authority", "www.example.com" }) })]]) +  + dnl RFC 7541 C.3.2 + test_hpack("8286 84be 5808 6e6f 2d63 6163 6865", +  [[({ ({ ":method", "GET" }), +  ({ ":scheme", "http" }), +  ({ ":path", "/" }), +  ({ ":authority", "www.example.com" }), +  ({ "cache-control", "no-cache" }) })]]) +  + dnl RFC 7541 C.3.3 + test_hpack("8287 85bf 400a 6375 7374 6f6d 2d6b 6579 0c63 7573 746f 6d2d 7661 6c75 65", +  [[({ ({ ":method", "GET" }), +  ({ ":scheme", "https" }), +  ({ ":path", "/index.html" }), +  ({ ":authority", "www.example.com" }), +  ({ "custom-key", "custom-value" }) })]]) +  + dnl RFC 7541 C.4.1 + test_hpack("8286 8441 8cf1 e3c2 e5f2 3a6b a0ab 90f4 ff", +  [[({ ({ ":method", "GET" }), +  ({ ":scheme", "http" }), +  ({ ":path", "/" }), +  ({ ":authority", "www.example.com" }) })]]) +  + dnl RFC 7541 C.4.2 + test_hpack("8286 84be 5886 a8eb 1064 9cbf", +  [[({ ({ ":method", "GET" }), +  ({ ":scheme", "http" }), +  ({ ":path", "/" }), +  ({ ":authority", "www.example.com" }), +  ({ "cache-control", "no-cache" }) })]]) +  + dnl RFC 7541 C.4.3 + test_hpack("8287 85bf 4088 25a8 49e9 5ba9 7d7f 8925 a849 e95b b8e8 b4bf", +  [[({ ({ ":method", "GET" }), +  ({ ":scheme", "https" }), +  ({ ":path", "/index.html" }), +  ({ ":authority", "www.example.com" }), +  ({ "custom-key", "custom-value" }) })]]) +  + dnl RFC 7541 C.5.1 + test_hpack("4803 3330 3258 0770 7269 7661 7465 611d" +  "4d6f 6e2c 2032 3120 4f63 7420 3230 3133" +  "2032 303a 3133 3a32 3120 474d 546e 1768" +  "7474 7073 3a2f 2f77 7777 2e65 7861 6d70" +  "6c65 2e63 6f6d", +  [[({ ({ ":status", "302" }), +  ({ "cache-control", "private" }), +  ({ "date", "Mon, 21 Oct 2013 20:13:21 GMT" }), +  ({ "location", "https://www.example.com" }) })]]) +  + dnl RFC 7541 C.5.2 + test_hpack("4803 3330 37c1 c0bf", +  [[({ ({ ":status", "307" }), +  ({ "cache-control", "private" }), +  ({ "date", "Mon, 21 Oct 2013 20:13:21 GMT" }), +  ({ "location", "https://www.example.com" }) })]]) +  + dnl RFC 7541 C.5.3 + test_hpack("88c1 611d 4d6f 6e2c 2032 3120 4f63 7420" +  "3230 3133 2032 303a 3133 3a32 3220 474d" +  "54c0 5a04 677a 6970 7738 666f 6f3d 4153" +  "444a 4b48 514b 425a 584f 5157 454f 5049" +  "5541 5851 5745 4f49 553b 206d 6178 2d61" +  "6765 3d33 3630 303b 2076 6572 7369 6f6e" +  "3d31", +  [[({ ({ ":status", "200" }), +  ({ "cache-control", "private" }), +  ({ "date", "Mon, 21 Oct 2013 20:13:22 GMT" }), +  ({ "location", "https://www.example.com" }), +  ({ "content-encoding", "gzip" }), +  ({ "set-cookie", +  "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1" }) })]]) +  + dnl RFC 7541 C.6.1 + test_hpack("4882 6402 5885 aec3 771a 4b61 96d0 7abe" +  "9410 54d4 44a8 2005 9504 0b81 66e0 82a6" +  "2d1b ff6e 919d 29ad 1718 63c7 8f0b 97c8" +  "e9ae 82ae 43d3", +  [[({ ({ ":status", "302" }), +  ({ "cache-control", "private" }), +  ({ "date", "Mon, 21 Oct 2013 20:13:21 GMT" }), +  ({ "location", "https://www.example.com" }) })]]) +  + dnl RFC 7541 C.6.2 + test_hpack("4883 640e ffc1 c0bf", +  [[({ ({ ":status", "307" }), +  ({ "cache-control", "private" }), +  ({ "date", "Mon, 21 Oct 2013 20:13:21 GMT" }), +  ({ "location", "https://www.example.com" }) })]]) +  + dnl RFC 7541 C.6.3 + test_hpack("88c1 6196 d07a be94 1054 d444 a820 0595" +  "040b 8166 e084 a62d 1bff c05a 839b d9ab" +  "77ad 94e7 821d d7f2 e6c7 b335 dfdf cd5b" +  "3960 d5af 2708 7f36 72c1 ab27 0fb5 291f" +  "9587 3160 65c0 03ed 4ee5 b106 3d50 07", +  [[({ ({ ":status", "200" }), +  ({ "cache-control", "private" }), +  ({ "date", "Mon, 21 Oct 2013 20:13:22 GMT" }), +  ({ "location", "https://www.example.com" }), +  ({ "content-encoding", "gzip" }), +  ({ "set-cookie", +  "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1" }) })]]) +  +  + test_do(add_constant("F")) + test_do(add_constant("E")) + test_do(add_constant("D")) + test_do(add_constant("S")) + test_do(add_constant("H")) +  + END_MARKER   Newline at end of file added.