| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
#include "h2_test_helper.h" |
| 6 |
|
| 7 |
#include <aws/http/private/h2_decoder.h> |
| 8 |
|
| 9 |
struct fixture { |
| 10 |
struct aws_allocator *allocator; |
| 11 |
struct h2_decode_tester decode; |
| 12 |
|
| 13 |
|
| 14 |
bool one_byte_at_a_time; |
| 15 |
|
| 16 |
bool is_server; |
| 17 |
bool skip_connection_preface; |
| 18 |
}; |
| 19 |
|
| 20 |
static int s_fixture_init(struct fixture *fixture, struct aws_allocator *allocator) { |
| 21 |
fixture->allocator = allocator; |
| 22 |
|
| 23 |
struct h2_decode_tester_options options = { |
| 24 |
.alloc = allocator, |
| 25 |
.is_server = fixture->is_server, |
| 26 |
.skip_connection_preface = fixture->skip_connection_preface, |
| 27 |
}; |
| 28 |
ASSERT_SUCCESS(h2_decode_tester_init(&fixture->decode, &options)); |
| 29 |
|
| 30 |
return AWS_OP_SUCCESS; |
| 31 |
} |
| 32 |
|
| 33 |
static void s_fixture_clean_up(struct fixture *fixture) { |
| 34 |
h2_decode_tester_clean_up(&fixture->decode); |
| 35 |
} |
| 36 |
|
| 37 |
static int s_fixture_test_setup(struct aws_allocator *allocator, void *ctx) { |
| 38 |
aws_http_library_init(allocator); |
| 39 |
|
| 40 |
struct fixture *fixture = ctx; |
| 41 |
ASSERT_SUCCESS(s_fixture_init(fixture, allocator)); |
| 42 |
return AWS_OP_SUCCESS; |
| 43 |
} |
| 44 |
|
| 45 |
static int s_fixture_test_teardown(struct aws_allocator *allocator, int setup_result, void *ctx) { |
| 46 |
(void)allocator; |
| 47 |
if (setup_result) { |
| 48 |
return AWS_OP_ERR; |
| 49 |
} |
| 50 |
|
| 51 |
struct fixture *fixture = ctx; |
| 52 |
s_fixture_clean_up(fixture); |
| 53 |
aws_http_library_clean_up(); |
| 54 |
return AWS_OP_SUCCESS; |
| 55 |
} |
| 56 |
|
| 57 |
|
| 58 |
#define TEST_CASE(NAME) \ |
| 59 |
static struct fixture s_fixture_##NAME; \ |
| 60 |
AWS_TEST_CASE_FIXTURE(NAME, s_fixture_test_setup, s_test_##NAME, s_fixture_test_teardown, &s_fixture_##NAME); \ |
| 61 |
static int s_test_##NAME(struct aws_allocator *allocator, void *ctx) |
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
#define H2_DECODER_TEST_CASE_IMPL(NAME, IS_SERVER, SKIP_PREFACE) \ |
| 67 |
static struct fixture s_fixture_##NAME = { \ |
| 68 |
.is_server = (IS_SERVER), \ |
| 69 |
.skip_connection_preface = (SKIP_PREFACE), \ |
| 70 |
}; \ |
| 71 |
AWS_TEST_CASE_FIXTURE(NAME, s_fixture_test_setup, s_test_##NAME, s_fixture_test_teardown, &s_fixture_##NAME); \ |
| 72 |
static struct fixture s_fixture_##NAME##_one_byte_at_a_time = { \ |
| 73 |
.one_byte_at_a_time = true, \ |
| 74 |
.is_server = (IS_SERVER), \ |
| 75 |
.skip_connection_preface = (SKIP_PREFACE), \ |
| 76 |
}; \ |
| 77 |
AWS_TEST_CASE_FIXTURE( \ |
| 78 |
NAME##_one_byte_at_a_time, \ |
| 79 |
s_fixture_test_setup, \ |
| 80 |
s_test_##NAME, \ |
| 81 |
s_fixture_test_teardown, \ |
| 82 |
&s_fixture_##NAME##_one_byte_at_a_time) \ |
| 83 |
static int s_test_##NAME(struct aws_allocator *allocator, void *ctx) |
| 84 |
|
| 85 |
#define H2_DECODER_ON_CLIENT_TEST(NAME) H2_DECODER_TEST_CASE_IMPL(NAME, false , true ) |
| 86 |
#define H2_DECODER_ON_SERVER_TEST(NAME) H2_DECODER_TEST_CASE_IMPL(NAME, true , true ) |
| 87 |
#define H2_DECODER_ON_CLIENT_PREFACE_TEST(NAME) H2_DECODER_TEST_CASE_IMPL(NAME, false, false) |
| 88 |
#define H2_DECODER_ON_SERVER_PREFACE_TEST(NAME) H2_DECODER_TEST_CASE_IMPL(NAME, true, false) |
| 89 |
|
| 90 |
|
| 91 |
TEST_CASE(h2_decoder_sanity_check) { |
| 92 |
(void)allocator; |
| 93 |
struct fixture *fixture = ctx; |
| 94 |
ASSERT_NOT_NULL(fixture); |
| 95 |
return AWS_OP_SUCCESS; |
| 96 |
} |
| 97 |
|
| 98 |
|
| 99 |
static struct aws_h2err s_decode_all(struct fixture *fixture, struct aws_byte_cursor input) { |
| 100 |
if (fixture->one_byte_at_a_time) { |
| 101 |
|
| 102 |
while (input.len) { |
| 103 |
struct aws_byte_cursor one_byte = aws_byte_cursor_advance(&input, 1); |
| 104 |
struct aws_h2err err = aws_h2_decode(fixture->decode.decoder, &one_byte); |
| 105 |
if (aws_h2err_failed(err)) { |
| 106 |
return err; |
| 107 |
} |
| 108 |
AWS_FATAL_ASSERT(0 == one_byte.len); |
| 109 |
} |
| 110 |
|
| 111 |
} else { |
| 112 |
|
| 113 |
struct aws_h2err err = aws_h2_decode(fixture->decode.decoder, &input); |
| 114 |
if (aws_h2err_failed(err)) { |
| 115 |
return err; |
| 116 |
} |
| 117 |
AWS_FATAL_ASSERT(0 == input.len); |
| 118 |
} |
| 119 |
|
| 120 |
return AWS_H2ERR_SUCCESS; |
| 121 |
} |
| 122 |
|
| 123 |
|
| 124 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_data) { |
| 125 |
(void)allocator; |
| 126 |
struct fixture *fixture = ctx; |
| 127 |
|
| 128 |
|
| 129 |
uint8_t input[] = { |
| 130 |
0x00, 0x00, 0x05, |
| 131 |
AWS_H2_FRAME_T_DATA, |
| 132 |
AWS_H2_FRAME_F_END_STREAM, |
| 133 |
0x76, 0x54, 0x32, 0x10, |
| 134 |
|
| 135 |
'h', 'e', 'l', 'l', 'o', |
| 136 |
}; |
| 137 |
|
| 138 |
|
| 139 |
ASSERT_H2ERR_SUCCESS(s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 140 |
|
| 141 |
|
| 142 |
struct h2_decoded_frame *frame = h2_decode_tester_latest_frame(&fixture->decode); |
| 143 |
ASSERT_SUCCESS(h2_decoded_frame_check_finished(frame, AWS_H2_FRAME_T_DATA, 0x76543210 )); |
| 144 |
ASSERT_UINT_EQUALS(5, frame->data_payload_len); |
| 145 |
ASSERT_TRUE(frame->end_stream); |
| 146 |
ASSERT_TRUE(aws_byte_buf_eq_c_str(&frame->data, "hello")); |
| 147 |
return AWS_OP_SUCCESS; |
| 148 |
} |
| 149 |
|
| 150 |
|
| 151 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_data_padded) { |
| 152 |
(void)allocator; |
| 153 |
struct fixture *fixture = ctx; |
| 154 |
|
| 155 |
|
| 156 |
uint8_t input[] = { |
| 157 |
0x00, 0x00, 0x08, |
| 158 |
AWS_H2_FRAME_T_DATA, |
| 159 |
AWS_H2_FRAME_F_PADDED, |
| 160 |
0x76, 0x54, 0x32, 0x10, |
| 161 |
|
| 162 |
0x02, |
| 163 |
'h', 'e', 'l', 'l', 'o', |
| 164 |
0x00, 0x00, |
| 165 |
}; |
| 166 |
|
| 167 |
|
| 168 |
ASSERT_H2ERR_SUCCESS(s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 169 |
|
| 170 |
|
| 171 |
struct h2_decoded_frame *frame = h2_decode_tester_latest_frame(&fixture->decode); |
| 172 |
ASSERT_SUCCESS(h2_decoded_frame_check_finished(frame, AWS_H2_FRAME_T_DATA, 0x76543210 )); |
| 173 |
ASSERT_UINT_EQUALS(8, frame->data_payload_len); |
| 174 |
ASSERT_FALSE(frame->end_stream); |
| 175 |
ASSERT_TRUE(aws_byte_buf_eq_c_str(&frame->data, "hello")); |
| 176 |
return AWS_OP_SUCCESS; |
| 177 |
} |
| 178 |
|
| 179 |
|
| 180 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_data_pad_length_zero) { |
| 181 |
(void)allocator; |
| 182 |
struct fixture *fixture = ctx; |
| 183 |
|
| 184 |
|
| 185 |
uint8_t input[] = { |
| 186 |
0x00, 0x00, 0x06, |
| 187 |
AWS_H2_FRAME_T_DATA, |
| 188 |
AWS_H2_FRAME_F_PADDED | AWS_H2_FRAME_F_END_STREAM, |
| 189 |
0x76, 0x54, 0x32, 0x10, |
| 190 |
|
| 191 |
0x00, |
| 192 |
'h', 'e', 'l', 'l', 'o', |
| 193 |
|
| 194 |
}; |
| 195 |
|
| 196 |
|
| 197 |
ASSERT_H2ERR_SUCCESS(s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 198 |
|
| 199 |
|
| 200 |
struct h2_decoded_frame *frame = h2_decode_tester_latest_frame(&fixture->decode); |
| 201 |
ASSERT_SUCCESS(h2_decoded_frame_check_finished(frame, AWS_H2_FRAME_T_DATA, 0x76543210 )); |
| 202 |
ASSERT_UINT_EQUALS(6, frame->data_payload_len); |
| 203 |
ASSERT_TRUE(frame->end_stream); |
| 204 |
ASSERT_TRUE(aws_byte_buf_eq_c_str(&frame->data, "hello")); |
| 205 |
return AWS_OP_SUCCESS; |
| 206 |
} |
| 207 |
|
| 208 |
|
| 209 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_data_empty) { |
| 210 |
(void)allocator; |
| 211 |
struct fixture *fixture = ctx; |
| 212 |
|
| 213 |
|
| 214 |
uint8_t input[] = { |
| 215 |
0x00, 0x00, 0x00, |
| 216 |
AWS_H2_FRAME_T_DATA, |
| 217 |
AWS_H2_FRAME_F_END_STREAM, |
| 218 |
0x76, 0x54, 0x32, 0x10, |
| 219 |
|
| 220 |
|
| 221 |
}; |
| 222 |
|
| 223 |
|
| 224 |
ASSERT_H2ERR_SUCCESS(s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 225 |
|
| 226 |
|
| 227 |
ASSERT_UINT_EQUALS(1, h2_decode_tester_frame_count(&fixture->decode)); |
| 228 |
struct h2_decoded_frame *frame = h2_decode_tester_latest_frame(&fixture->decode); |
| 229 |
ASSERT_SUCCESS(h2_decoded_frame_check_finished(frame, AWS_H2_FRAME_T_DATA, 0x76543210 )); |
| 230 |
ASSERT_TRUE(frame->data.len == 0); |
| 231 |
ASSERT_TRUE(frame->end_stream); |
| 232 |
|
| 233 |
return AWS_OP_SUCCESS; |
| 234 |
} |
| 235 |
|
| 236 |
|
| 237 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_data_empty_padded) { |
| 238 |
(void)allocator; |
| 239 |
struct fixture *fixture = ctx; |
| 240 |
|
| 241 |
|
| 242 |
uint8_t input[] = { |
| 243 |
0x00, 0x00, 0x03, |
| 244 |
AWS_H2_FRAME_T_DATA, |
| 245 |
AWS_H2_FRAME_F_PADDED, |
| 246 |
0x76, 0x54, 0x32, 0x10, |
| 247 |
|
| 248 |
0x02, |
| 249 |
|
| 250 |
0x00, 0x00, |
| 251 |
}; |
| 252 |
|
| 253 |
|
| 254 |
ASSERT_H2ERR_SUCCESS(s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 255 |
|
| 256 |
|
| 257 |
struct h2_decoded_frame *frame = h2_decode_tester_latest_frame(&fixture->decode); |
| 258 |
ASSERT_SUCCESS(h2_decoded_frame_check_finished(frame, AWS_H2_FRAME_T_DATA, 0x76543210 )); |
| 259 |
ASSERT_UINT_EQUALS(3, frame->data_payload_len); |
| 260 |
ASSERT_FALSE(frame->end_stream); |
| 261 |
ASSERT_TRUE(aws_byte_buf_eq_c_str(&frame->data, "")); |
| 262 |
return AWS_OP_SUCCESS; |
| 263 |
} |
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_data_ignores_unknown_flags) { |
| 268 |
(void)allocator; |
| 269 |
struct fixture *fixture = ctx; |
| 270 |
|
| 271 |
|
| 272 |
uint8_t input[] = { |
| 273 |
0x00, 0x00, 0x08, |
| 274 |
AWS_H2_FRAME_T_DATA, |
| 275 |
0xFF, |
| 276 |
0x76, 0x54, 0x32, 0x10, |
| 277 |
|
| 278 |
0x02, |
| 279 |
'h', 'e', 'l', 'l', 'o', |
| 280 |
0x00, 0x00, |
| 281 |
}; |
| 282 |
|
| 283 |
|
| 284 |
ASSERT_H2ERR_SUCCESS(s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 285 |
|
| 286 |
|
| 287 |
struct h2_decoded_frame *frame = h2_decode_tester_latest_frame(&fixture->decode); |
| 288 |
ASSERT_SUCCESS(h2_decoded_frame_check_finished(frame, AWS_H2_FRAME_T_DATA, 0x76543210 )); |
| 289 |
ASSERT_UINT_EQUALS(8, frame->data_payload_len); |
| 290 |
ASSERT_TRUE(frame->end_stream); |
| 291 |
ASSERT_TRUE(aws_byte_buf_eq_c_str(&frame->data, "hello")); |
| 292 |
return AWS_OP_SUCCESS; |
| 293 |
} |
| 294 |
|
| 295 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_data_payload_max_size_update) { |
| 296 |
(void)allocator; |
| 297 |
struct fixture *fixture = ctx; |
| 298 |
|
| 299 |
|
| 300 |
aws_h2_decoder_set_setting_max_frame_size(fixture->decode.decoder, 16500); |
| 301 |
|
| 302 |
uint8_t input[16509] = { |
| 303 |
0x00, 0x40, 0x74, |
| 304 |
AWS_H2_FRAME_T_DATA, |
| 305 |
AWS_H2_FRAME_F_END_STREAM, |
| 306 |
0x76, 0x54, 0x32, 0x10, |
| 307 |
|
| 308 |
}; |
| 309 |
|
| 310 |
|
| 311 |
char expected[16500]; |
| 312 |
for (int i = 9; i < 16509; i++) { |
| 313 |
input[i] = 'a'; |
| 314 |
expected[i - 9] = 'a'; |
| 315 |
} |
| 316 |
struct aws_byte_cursor expected_cursor = aws_byte_cursor_from_array(expected, sizeof(expected)); |
| 317 |
|
| 318 |
ASSERT_H2ERR_SUCCESS(s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 319 |
|
| 320 |
|
| 321 |
struct h2_decoded_frame *frame = h2_decode_tester_latest_frame(&fixture->decode); |
| 322 |
ASSERT_SUCCESS(h2_decoded_frame_check_finished(frame, AWS_H2_FRAME_T_DATA, 0x76543210 )); |
| 323 |
ASSERT_UINT_EQUALS(16500, frame->data_payload_len); |
| 324 |
ASSERT_TRUE(frame->end_stream); |
| 325 |
ASSERT_TRUE(aws_byte_cursor_eq_byte_buf(&expected_cursor, &frame->data)); |
| 326 |
return AWS_OP_SUCCESS; |
| 327 |
} |
| 328 |
|
| 329 |
|
| 330 |
|
| 331 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_err_data_payload_exceed_max_size) { |
| 332 |
(void)allocator; |
| 333 |
struct fixture *fixture = ctx; |
| 334 |
|
| 335 |
|
| 336 |
|
| 337 |
uint8_t input[16509] = { |
| 338 |
0x00, 0x40, 0x74, |
| 339 |
AWS_H2_FRAME_T_DATA, |
| 340 |
AWS_H2_FRAME_F_END_STREAM, |
| 341 |
0x76, 0x54, 0x32, 0x10, |
| 342 |
|
| 343 |
}; |
| 344 |
|
| 345 |
|
| 346 |
ASSERT_H2ERR_ERROR( |
| 347 |
AWS_HTTP2_ERR_FRAME_SIZE_ERROR, s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 348 |
|
| 349 |
return AWS_OP_SUCCESS; |
| 350 |
} |
| 351 |
|
| 352 |
|
| 353 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_err_data_requires_stream_id) { |
| 354 |
(void)allocator; |
| 355 |
struct fixture *fixture = ctx; |
| 356 |
|
| 357 |
|
| 358 |
uint8_t input[] = { |
| 359 |
0x00, 0x00, 0x05, |
| 360 |
AWS_H2_FRAME_T_DATA, |
| 361 |
AWS_H2_FRAME_F_END_STREAM, |
| 362 |
0x00, 0x00, 0x00, 0x00, |
| 363 |
|
| 364 |
'h', 'e', 'l', 'l', 'o', |
| 365 |
}; |
| 366 |
|
| 367 |
|
| 368 |
ASSERT_H2ERR_ERROR( |
| 369 |
AWS_HTTP2_ERR_PROTOCOL_ERROR, s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 370 |
|
| 371 |
return AWS_OP_SUCCESS; |
| 372 |
} |
| 373 |
|
| 374 |
|
| 375 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_err_payload_too_small_for_pad_length) { |
| 376 |
(void)allocator; |
| 377 |
struct fixture *fixture = ctx; |
| 378 |
|
| 379 |
|
| 380 |
uint8_t input[] = { |
| 381 |
0x00, 0x00, 0x00, |
| 382 |
AWS_H2_FRAME_T_DATA, |
| 383 |
AWS_H2_FRAME_F_PADDED, |
| 384 |
0x76, 0x54, 0x32, 0x10, |
| 385 |
|
| 386 |
|
| 387 |
|
| 388 |
|
| 389 |
}; |
| 390 |
|
| 391 |
|
| 392 |
ASSERT_H2ERR_ERROR( |
| 393 |
AWS_HTTP2_ERR_FRAME_SIZE_ERROR, s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 394 |
return AWS_OP_SUCCESS; |
| 395 |
} |
| 396 |
|
| 397 |
|
| 398 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_stream_id_ignores_reserved_bit) { |
| 399 |
(void)allocator; |
| 400 |
struct fixture *fixture = ctx; |
| 401 |
|
| 402 |
|
| 403 |
uint8_t input[] = { |
| 404 |
0x00, 0x00, 0x05, |
| 405 |
AWS_H2_FRAME_T_DATA, |
| 406 |
AWS_H2_FRAME_F_END_STREAM, |
| 407 |
0xFF, 0xFF, 0xFF, 0xFF, |
| 408 |
|
| 409 |
'h', 'e', 'l', 'l', 'o', |
| 410 |
}; |
| 411 |
|
| 412 |
|
| 413 |
ASSERT_H2ERR_SUCCESS(s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 414 |
|
| 415 |
|
| 416 |
struct h2_decoded_frame *frame = h2_decode_tester_latest_frame(&fixture->decode); |
| 417 |
ASSERT_SUCCESS(h2_decoded_frame_check_finished(frame, AWS_H2_FRAME_T_DATA, 0x7FFFFFFF )); |
| 418 |
ASSERT_UINT_EQUALS(5, frame->data_payload_len); |
| 419 |
ASSERT_TRUE(frame->end_stream); |
| 420 |
ASSERT_TRUE(aws_byte_buf_eq_c_str(&frame->data, "hello")); |
| 421 |
return AWS_OP_SUCCESS; |
| 422 |
} |
| 423 |
|
| 424 |
static int s_check_header( |
| 425 |
struct h2_decoded_frame *frame, |
| 426 |
size_t header_idx, |
| 427 |
const char *name, |
| 428 |
const char *value, |
| 429 |
enum aws_http_header_compression compression) { |
| 430 |
|
| 431 |
struct aws_http_header header_field; |
| 432 |
ASSERT_SUCCESS(aws_http_headers_get_index(frame->headers, header_idx, &header_field)); |
| 433 |
|
| 434 |
ASSERT_BIN_ARRAYS_EQUALS(name, strlen(name), header_field.name.ptr, header_field.name.len); |
| 435 |
ASSERT_BIN_ARRAYS_EQUALS(value, strlen(value), header_field.value.ptr, header_field.value.len); |
| 436 |
ASSERT_INT_EQUALS(compression, header_field.compression); |
| 437 |
return AWS_OP_SUCCESS; |
| 438 |
} |
| 439 |
|
| 440 |
|
| 441 |
|
| 442 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_headers) { |
| 443 |
(void)allocator; |
| 444 |
struct fixture *fixture = ctx; |
| 445 |
|
| 446 |
|
| 447 |
uint8_t input[] = { |
| 448 |
0x00, 0x00, 11, |
| 449 |
AWS_H2_FRAME_T_HEADERS, |
| 450 |
AWS_H2_FRAME_F_END_HEADERS | AWS_H2_FRAME_F_END_STREAM, |
| 451 |
0x76, 0x54, 0x32, 0x10, |
| 452 |
|
| 453 |
0x48, 0x03, '3', '0', '2', |
| 454 |
0x7a, 0x04, 't', 'e', 's', 't' |
| 455 |
}; |
| 456 |
|
| 457 |
|
| 458 |
|
| 459 |
ASSERT_H2ERR_SUCCESS(s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 460 |
|
| 461 |
|
| 462 |
struct h2_decoded_frame *frame = h2_decode_tester_latest_frame(&fixture->decode); |
| 463 |
ASSERT_SUCCESS(h2_decoded_frame_check_finished(frame, AWS_H2_FRAME_T_HEADERS, 0x76543210 )); |
| 464 |
ASSERT_FALSE(frame->headers_malformed); |
| 465 |
ASSERT_UINT_EQUALS(2, aws_http_headers_count(frame->headers)); |
| 466 |
ASSERT_SUCCESS(s_check_header(frame, 0, ":status", "302", AWS_HTTP_HEADER_COMPRESSION_USE_CACHE)); |
| 467 |
ASSERT_SUCCESS(s_check_header(frame, 1, "user-agent", "test", AWS_HTTP_HEADER_COMPRESSION_USE_CACHE)); |
| 468 |
ASSERT_INT_EQUALS(AWS_HTTP_HEADER_BLOCK_MAIN, frame->header_block_type); |
| 469 |
ASSERT_TRUE(frame->end_stream); |
| 470 |
return AWS_OP_SUCCESS; |
| 471 |
} |
| 472 |
|
| 473 |
|
| 474 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_headers_padded) { |
| 475 |
(void)allocator; |
| 476 |
struct fixture *fixture = ctx; |
| 477 |
|
| 478 |
|
| 479 |
uint8_t input[] = { |
| 480 |
0x00, 0x00, 0x08, |
| 481 |
AWS_H2_FRAME_T_HEADERS, |
| 482 |
AWS_H2_FRAME_F_PADDED | AWS_H2_FRAME_F_END_HEADERS, |
| 483 |
0x76, 0x54, 0x32, 0x10, |
| 484 |
|
| 485 |
0x02, |
| 486 |
0x48, 0x03, '3', '0', '2', |
| 487 |
0x00, 0x00, |
| 488 |
}; |
| 489 |
|
| 490 |
|
| 491 |
|
| 492 |
ASSERT_H2ERR_SUCCESS(s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 493 |
|
| 494 |
|
| 495 |
struct h2_decoded_frame *frame = h2_decode_tester_latest_frame(&fixture->decode); |
| 496 |
ASSERT_SUCCESS(h2_decoded_frame_check_finished(frame, AWS_H2_FRAME_T_HEADERS, 0x76543210 )); |
| 497 |
ASSERT_FALSE(frame->headers_malformed); |
| 498 |
ASSERT_UINT_EQUALS(1, aws_http_headers_count(frame->headers)); |
| 499 |
ASSERT_SUCCESS(s_check_header(frame, 0, ":status", "302", AWS_HTTP_HEADER_COMPRESSION_USE_CACHE)); |
| 500 |
ASSERT_INT_EQUALS(AWS_HTTP_HEADER_BLOCK_MAIN, frame->header_block_type); |
| 501 |
return AWS_OP_SUCCESS; |
| 502 |
} |
| 503 |
|
| 504 |
|
| 505 |
|
| 506 |
|
| 507 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_headers_priority) { |
| 508 |
(void)allocator; |
| 509 |
struct fixture *fixture = ctx; |
| 510 |
|
| 511 |
|
| 512 |
uint8_t input[] = { |
| 513 |
0x00, 0x00, 10, |
| 514 |
AWS_H2_FRAME_T_HEADERS, |
| 515 |
AWS_H2_FRAME_F_END_HEADERS | AWS_H2_FRAME_F_PRIORITY, |
| 516 |
0x76, 0x54, 0x32, 0x10, |
| 517 |
|
| 518 |
0x81, 0x23, 0x45, 0x67, |
| 519 |
0x09, |
| 520 |
0x48, 0x03, '3', '0', '2' |
| 521 |
}; |
| 522 |
|
| 523 |
|
| 524 |
|
| 525 |
ASSERT_H2ERR_SUCCESS(s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 526 |
|
| 527 |
|
| 528 |
struct h2_decoded_frame *frame = h2_decode_tester_latest_frame(&fixture->decode); |
| 529 |
ASSERT_SUCCESS(h2_decoded_frame_check_finished(frame, AWS_H2_FRAME_T_HEADERS, 0x76543210 )); |
| 530 |
ASSERT_FALSE(frame->headers_malformed); |
| 531 |
ASSERT_UINT_EQUALS(1, aws_http_headers_count(frame->headers)); |
| 532 |
ASSERT_SUCCESS(s_check_header(frame, 0, ":status", "302", AWS_HTTP_HEADER_COMPRESSION_USE_CACHE)); |
| 533 |
ASSERT_INT_EQUALS(AWS_HTTP_HEADER_BLOCK_MAIN, frame->header_block_type); |
| 534 |
return AWS_OP_SUCCESS; |
| 535 |
} |
| 536 |
|
| 537 |
|
| 538 |
|
| 539 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_headers_ignores_unknown_flags) { |
| 540 |
(void)allocator; |
| 541 |
struct fixture *fixture = ctx; |
| 542 |
|
| 543 |
|
| 544 |
uint8_t input[] = { |
| 545 |
0x00, 0x00, 13, |
| 546 |
AWS_H2_FRAME_T_HEADERS, |
| 547 |
0xFF, |
| 548 |
0x76, 0x54, 0x32, 0x10, |
| 549 |
|
| 550 |
0x02, |
| 551 |
0x81, 0x23, 0x45, 0x67, |
| 552 |
0x09, |
| 553 |
0x48, 0x03, '3', '0', '2', |
| 554 |
0x00, 0x00 |
| 555 |
}; |
| 556 |
|
| 557 |
|
| 558 |
|
| 559 |
ASSERT_H2ERR_SUCCESS(s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 560 |
|
| 561 |
|
| 562 |
struct h2_decoded_frame *frame = h2_decode_tester_latest_frame(&fixture->decode); |
| 563 |
ASSERT_SUCCESS(h2_decoded_frame_check_finished(frame, AWS_H2_FRAME_T_HEADERS, 0x76543210 )); |
| 564 |
ASSERT_FALSE(frame->headers_malformed); |
| 565 |
ASSERT_UINT_EQUALS(1, aws_http_headers_count(frame->headers)); |
| 566 |
ASSERT_SUCCESS(s_check_header(frame, 0, ":status", "302", AWS_HTTP_HEADER_COMPRESSION_USE_CACHE)); |
| 567 |
ASSERT_INT_EQUALS(AWS_HTTP_HEADER_BLOCK_MAIN, frame->header_block_type); |
| 568 |
ASSERT_TRUE(frame->end_stream); |
| 569 |
return AWS_OP_SUCCESS; |
| 570 |
} |
| 571 |
|
| 572 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_headers_response_informational) { |
| 573 |
(void)allocator; |
| 574 |
struct fixture *fixture = ctx; |
| 575 |
|
| 576 |
|
| 577 |
uint8_t input[] = { |
| 578 |
0x00, 0x00, 0x05, |
| 579 |
AWS_H2_FRAME_T_HEADERS, |
| 580 |
AWS_H2_FRAME_F_END_HEADERS, |
| 581 |
0x76, 0x54, 0x32, 0x10, |
| 582 |
|
| 583 |
0x48, 0x03, '1', '0', '0', |
| 584 |
}; |
| 585 |
|
| 586 |
|
| 587 |
|
| 588 |
ASSERT_H2ERR_SUCCESS(s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 589 |
|
| 590 |
|
| 591 |
struct h2_decoded_frame *frame = h2_decode_tester_latest_frame(&fixture->decode); |
| 592 |
ASSERT_SUCCESS(h2_decoded_frame_check_finished(frame, AWS_H2_FRAME_T_HEADERS, 0x76543210 )); |
| 593 |
ASSERT_FALSE(frame->headers_malformed); |
| 594 |
ASSERT_UINT_EQUALS(1, aws_http_headers_count(frame->headers)); |
| 595 |
ASSERT_SUCCESS(s_check_header(frame, 0, ":status", "100", AWS_HTTP_HEADER_COMPRESSION_USE_CACHE)); |
| 596 |
ASSERT_INT_EQUALS(AWS_HTTP_HEADER_BLOCK_INFORMATIONAL, frame->header_block_type); |
| 597 |
ASSERT_FALSE(frame->end_stream); |
| 598 |
return AWS_OP_SUCCESS; |
| 599 |
} |
| 600 |
|
| 601 |
|
| 602 |
H2_DECODER_ON_SERVER_TEST(h2_decoder_headers_request) { |
| 603 |
(void)allocator; |
| 604 |
struct fixture *fixture = ctx; |
| 605 |
|
| 606 |
|
| 607 |
uint8_t input[] = { |
| 608 |
0x00, 0x00, 21, |
| 609 |
AWS_H2_FRAME_T_HEADERS, |
| 610 |
AWS_H2_FRAME_F_END_HEADERS | AWS_H2_FRAME_F_END_STREAM, |
| 611 |
0x00, 0x00, 0x00, 0x01, |
| 612 |
|
| 613 |
0x82, |
| 614 |
0x86, |
| 615 |
0x41, 10, 'a', 'm', 'a', 'z', 'o', 'n', '.', 'c', 'o', 'm', |
| 616 |
0x84, |
| 617 |
0x7a, 0x04, 't', 'e', 's', 't' |
| 618 |
}; |
| 619 |
|
| 620 |
|
| 621 |
|
| 622 |
ASSERT_H2ERR_SUCCESS(s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 623 |
|
| 624 |
|
| 625 |
struct h2_decoded_frame *frame = h2_decode_tester_latest_frame(&fixture->decode); |
| 626 |
ASSERT_SUCCESS(h2_decoded_frame_check_finished(frame, AWS_H2_FRAME_T_HEADERS, 1 )); |
| 627 |
ASSERT_FALSE(frame->headers_malformed); |
| 628 |
ASSERT_UINT_EQUALS(5, aws_http_headers_count(frame->headers)); |
| 629 |
ASSERT_SUCCESS(s_check_header(frame, 0, ":method", "GET", AWS_HTTP_HEADER_COMPRESSION_USE_CACHE)); |
| 630 |
ASSERT_SUCCESS(s_check_header(frame, 1, ":scheme", "http", AWS_HTTP_HEADER_COMPRESSION_USE_CACHE)); |
| 631 |
ASSERT_SUCCESS(s_check_header(frame, 2, ":authority", "amazon.com", AWS_HTTP_HEADER_COMPRESSION_USE_CACHE)); |
| 632 |
ASSERT_SUCCESS(s_check_header(frame, 3, ":path", "/", AWS_HTTP_HEADER_COMPRESSION_USE_CACHE)); |
| 633 |
ASSERT_SUCCESS(s_check_header(frame, 4, "user-agent", "test", AWS_HTTP_HEADER_COMPRESSION_USE_CACHE)); |
| 634 |
ASSERT_INT_EQUALS(AWS_HTTP_HEADER_BLOCK_MAIN, frame->header_block_type); |
| 635 |
ASSERT_TRUE(frame->end_stream); |
| 636 |
return AWS_OP_SUCCESS; |
| 637 |
} |
| 638 |
|
| 639 |
H2_DECODER_ON_SERVER_TEST(h2_decoder_headers_cookies) { |
| 640 |
(void)allocator; |
| 641 |
struct fixture *fixture = ctx; |
| 642 |
|
| 643 |
|
| 644 |
uint8_t input[] = { |
| 645 |
|
| 646 |
0x00, 0x00, 0x06, |
| 647 |
AWS_H2_FRAME_T_HEADERS, |
| 648 |
AWS_H2_FRAME_F_END_STREAM, |
| 649 |
0x76, 0x54, 0x32, 0x10, |
| 650 |
|
| 651 |
0x82, |
| 652 |
0x60, 0x03, 'a', '=', 'b', |
| 653 |
|
| 654 |
|
| 655 |
0x00, 0x00, 16, |
| 656 |
AWS_H2_FRAME_T_CONTINUATION, |
| 657 |
AWS_H2_FRAME_F_END_HEADERS, |
| 658 |
0x76, 0x54, 0x32, 0x10, |
| 659 |
|
| 660 |
0x7a, 0x04, 't', 'e', 's', 't', |
| 661 |
0x60, 0x03, 'c', '=', 'd', |
| 662 |
0x60, 0x03, 'e', '=', 'f', |
| 663 |
}; |
| 664 |
|
| 665 |
|
| 666 |
|
| 667 |
ASSERT_H2ERR_SUCCESS(s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 668 |
|
| 669 |
|
| 670 |
struct h2_decoded_frame *frame = h2_decode_tester_latest_frame(&fixture->decode); |
| 671 |
ASSERT_SUCCESS(h2_decoded_frame_check_finished(frame, AWS_H2_FRAME_T_HEADERS, 0x76543210 )); |
| 672 |
ASSERT_FALSE(frame->headers_malformed); |
| 673 |
|
| 674 |
ASSERT_UINT_EQUALS(3, aws_http_headers_count(frame->headers)); |
| 675 |
ASSERT_SUCCESS(s_check_header(frame, 0, ":method", "GET", AWS_HTTP_HEADER_COMPRESSION_USE_CACHE)); |
| 676 |
ASSERT_SUCCESS(s_check_header(frame, 1, "user-agent", "test", AWS_HTTP_HEADER_COMPRESSION_USE_CACHE)); |
| 677 |
ASSERT_SUCCESS(s_check_header(frame, 2, "cookie", "a=b; c=d; e=f", AWS_HTTP_HEADER_COMPRESSION_USE_CACHE)); |
| 678 |
ASSERT_INT_EQUALS(AWS_HTTP_HEADER_BLOCK_MAIN, frame->header_block_type); |
| 679 |
ASSERT_TRUE(frame->end_stream); |
| 680 |
|
| 681 |
return AWS_OP_SUCCESS; |
| 682 |
} |
| 683 |
|
| 684 |
|
| 685 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_headers_trailer) { |
| 686 |
(void)allocator; |
| 687 |
struct fixture *fixture = ctx; |
| 688 |
|
| 689 |
|
| 690 |
uint8_t input[] = { |
| 691 |
0x00, 0x00, 0x06, |
| 692 |
AWS_H2_FRAME_T_HEADERS, |
| 693 |
AWS_H2_FRAME_F_END_HEADERS | AWS_H2_FRAME_F_END_STREAM, |
| 694 |
0x76, 0x54, 0x32, 0x10, |
| 695 |
|
| 696 |
0x7a, 0x04, 't', 'e', 's', 't' |
| 697 |
}; |
| 698 |
|
| 699 |
|
| 700 |
|
| 701 |
ASSERT_H2ERR_SUCCESS(s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 702 |
|
| 703 |
|
| 704 |
struct h2_decoded_frame *frame = h2_decode_tester_latest_frame(&fixture->decode); |
| 705 |
ASSERT_SUCCESS(h2_decoded_frame_check_finished(frame, AWS_H2_FRAME_T_HEADERS, 0x76543210 )); |
| 706 |
ASSERT_FALSE(frame->headers_malformed); |
| 707 |
ASSERT_UINT_EQUALS(1, aws_http_headers_count(frame->headers)); |
| 708 |
ASSERT_SUCCESS(s_check_header(frame, 0, "user-agent", "test", AWS_HTTP_HEADER_COMPRESSION_USE_CACHE)); |
| 709 |
ASSERT_INT_EQUALS(AWS_HTTP_HEADER_BLOCK_TRAILING, frame->header_block_type); |
| 710 |
ASSERT_TRUE(frame->end_stream); |
| 711 |
return AWS_OP_SUCCESS; |
| 712 |
} |
| 713 |
|
| 714 |
|
| 715 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_headers_empty_trailer) { |
| 716 |
(void)allocator; |
| 717 |
struct fixture *fixture = ctx; |
| 718 |
|
| 719 |
|
| 720 |
uint8_t input[] = { |
| 721 |
0x00, 0x00, 0x00, |
| 722 |
AWS_H2_FRAME_T_HEADERS, |
| 723 |
AWS_H2_FRAME_F_END_HEADERS | AWS_H2_FRAME_F_END_STREAM, |
| 724 |
0x76, 0x54, 0x32, 0x10, |
| 725 |
|
| 726 |
}; |
| 727 |
|
| 728 |
|
| 729 |
|
| 730 |
ASSERT_H2ERR_SUCCESS(s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 731 |
|
| 732 |
|
| 733 |
struct h2_decoded_frame *frame = h2_decode_tester_latest_frame(&fixture->decode); |
| 734 |
ASSERT_SUCCESS(h2_decoded_frame_check_finished(frame, AWS_H2_FRAME_T_HEADERS, 0x76543210 )); |
| 735 |
ASSERT_FALSE(frame->headers_malformed); |
| 736 |
ASSERT_UINT_EQUALS(0, aws_http_headers_count(frame->headers)); |
| 737 |
ASSERT_INT_EQUALS(AWS_HTTP_HEADER_BLOCK_TRAILING, frame->header_block_type); |
| 738 |
ASSERT_TRUE(frame->end_stream); |
| 739 |
return AWS_OP_SUCCESS; |
| 740 |
} |
| 741 |
|
| 742 |
|
| 743 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_err_headers_requires_stream_id) { |
| 744 |
(void)allocator; |
| 745 |
struct fixture *fixture = ctx; |
| 746 |
|
| 747 |
|
| 748 |
uint8_t input[] = { |
| 749 |
0x00, 0x00, 0x05, |
| 750 |
AWS_H2_FRAME_T_HEADERS, |
| 751 |
AWS_H2_FRAME_F_END_HEADERS | AWS_H2_FRAME_F_END_STREAM, |
| 752 |
0x00, 0x00, 0x00, 0x00, |
| 753 |
|
| 754 |
0x48, 0x03, '3', '0', '2' |
| 755 |
}; |
| 756 |
|
| 757 |
|
| 758 |
|
| 759 |
ASSERT_H2ERR_ERROR( |
| 760 |
AWS_HTTP2_ERR_PROTOCOL_ERROR, s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 761 |
|
| 762 |
return AWS_OP_SUCCESS; |
| 763 |
} |
| 764 |
|
| 765 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_err_headers_payload_too_small_for_padding) { |
| 766 |
(void)allocator; |
| 767 |
struct fixture *fixture = ctx; |
| 768 |
|
| 769 |
|
| 770 |
uint8_t input[] = { |
| 771 |
0x00, 0x00, 0x00, |
| 772 |
AWS_H2_FRAME_T_HEADERS, |
| 773 |
AWS_H2_FRAME_F_END_HEADERS | AWS_H2_FRAME_F_PRIORITY | AWS_H2_FRAME_F_PADDED | AWS_H2_FRAME_F_END_STREAM, |
| 774 |
0x76, 0x54, 0x32, 0x10, |
| 775 |
|
| 776 |
0x02, |
| 777 |
0x81, 0x23, 0x45, 0x67, |
| 778 |
0x09, |
| 779 |
0x48, 0x03, '3', '0', '2', |
| 780 |
0x00, 0x00 |
| 781 |
}; |
| 782 |
|
| 783 |
|
| 784 |
|
| 785 |
ASSERT_H2ERR_ERROR( |
| 786 |
AWS_HTTP2_ERR_FRAME_SIZE_ERROR, s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 787 |
|
| 788 |
return AWS_OP_SUCCESS; |
| 789 |
} |
| 790 |
|
| 791 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_err_headers_payload_too_small_for_priority) { |
| 792 |
(void)allocator; |
| 793 |
struct fixture *fixture = ctx; |
| 794 |
|
| 795 |
|
| 796 |
uint8_t input[] = { |
| 797 |
0x00, 0x00, 0x05, |
| 798 |
AWS_H2_FRAME_T_HEADERS, |
| 799 |
AWS_H2_FRAME_F_END_HEADERS | AWS_H2_FRAME_F_PRIORITY | AWS_H2_FRAME_F_PADDED | AWS_H2_FRAME_F_END_STREAM, |
| 800 |
0x76, 0x54, 0x32, 0x10, |
| 801 |
|
| 802 |
0x02, |
| 803 |
0x81, 0x23, 0x45, 0x67, |
| 804 |
0x09, |
| 805 |
0x48, 0x03, '3', '0', '2', |
| 806 |
0x00, 0x00 |
| 807 |
}; |
| 808 |
|
| 809 |
|
| 810 |
|
| 811 |
ASSERT_H2ERR_ERROR( |
| 812 |
AWS_HTTP2_ERR_FRAME_SIZE_ERROR, s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 813 |
|
| 814 |
return AWS_OP_SUCCESS; |
| 815 |
} |
| 816 |
|
| 817 |
|
| 818 |
|
| 819 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_malformed_headers_blank_name) { |
| 820 |
(void)allocator; |
| 821 |
struct fixture *fixture = ctx; |
| 822 |
|
| 823 |
|
| 824 |
uint8_t input[] = { |
| 825 |
0x00, 0x00, 0x09, |
| 826 |
AWS_H2_FRAME_T_HEADERS, |
| 827 |
AWS_H2_FRAME_F_END_HEADERS | AWS_H2_FRAME_F_END_STREAM, |
| 828 |
0x76, 0x54, 0x32, 0x10, |
| 829 |
|
| 830 |
0x48, 0x03, '3', '0', '2', |
| 831 |
0x40, 0x00, 0x01, 'a', |
| 832 |
}; |
| 833 |
|
| 834 |
|
| 835 |
|
| 836 |
ASSERT_H2ERR_SUCCESS(s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 837 |
|
| 838 |
|
| 839 |
struct h2_decoded_frame *frame = h2_decode_tester_latest_frame(&fixture->decode); |
| 840 |
ASSERT_SUCCESS(h2_decoded_frame_check_finished(frame, AWS_H2_FRAME_T_HEADERS, 0x76543210 )); |
| 841 |
ASSERT_TRUE(frame->headers_malformed); |
| 842 |
|
| 843 |
ASSERT_TRUE(frame->end_stream); |
| 844 |
return AWS_OP_SUCCESS; |
| 845 |
} |
| 846 |
|
| 847 |
|
| 848 |
|
| 849 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_malformed_headers_illegal_name) { |
| 850 |
(void)allocator; |
| 851 |
struct fixture *fixture = ctx; |
| 852 |
|
| 853 |
|
| 854 |
uint8_t input[] = { |
| 855 |
0x00, 0x00, 10, |
| 856 |
AWS_H2_FRAME_T_HEADERS, |
| 857 |
AWS_H2_FRAME_F_END_HEADERS | AWS_H2_FRAME_F_END_STREAM, |
| 858 |
0x76, 0x54, 0x32, 0x10, |
| 859 |
|
| 860 |
0x48, 0x03, '3', '0', '2', |
| 861 |
0x40, 0x01, ',', 0x01, 'a', |
| 862 |
}; |
| 863 |
|
| 864 |
|
| 865 |
|
| 866 |
ASSERT_H2ERR_SUCCESS(s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 867 |
|
| 868 |
|
| 869 |
struct h2_decoded_frame *frame = h2_decode_tester_latest_frame(&fixture->decode); |
| 870 |
ASSERT_SUCCESS(h2_decoded_frame_check_finished(frame, AWS_H2_FRAME_T_HEADERS, 0x76543210 )); |
| 871 |
ASSERT_TRUE(frame->headers_malformed); |
| 872 |
|
| 873 |
ASSERT_TRUE(frame->end_stream); |
| 874 |
return AWS_OP_SUCCESS; |
| 875 |
} |
| 876 |
|
| 877 |
|
| 878 |
|
| 879 |
H2_DECODER_ON_SERVER_TEST(h2_decoder_malformed_headers_response_to_server) { |
| 880 |
(void)allocator; |
| 881 |
struct fixture *fixture = ctx; |
| 882 |
|
| 883 |
|
| 884 |
uint8_t input[] = { |
| 885 |
0x00, 0x00, 0x05, |
| 886 |
AWS_H2_FRAME_T_HEADERS, |
| 887 |
AWS_H2_FRAME_F_END_HEADERS | AWS_H2_FRAME_F_END_STREAM, |
| 888 |
0x76, 0x54, 0x32, 0x10, |
| 889 |
|
| 890 |
0x48, 0x03, '3', '0', '2', |
| 891 |
}; |
| 892 |
|
| 893 |
|
| 894 |
|
| 895 |
ASSERT_H2ERR_SUCCESS(s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 896 |
|
| 897 |
|
| 898 |
struct h2_decoded_frame *frame = h2_decode_tester_latest_frame(&fixture->decode); |
| 899 |
ASSERT_SUCCESS(h2_decoded_frame_check_finished(frame, AWS_H2_FRAME_T_HEADERS, 0x76543210 )); |
| 900 |
ASSERT_TRUE(frame->headers_malformed); |
| 901 |
|
| 902 |
ASSERT_TRUE(frame->end_stream); |
| 903 |
return AWS_OP_SUCCESS; |
| 904 |
} |
| 905 |
|
| 906 |
|
| 907 |
|
| 908 |
|
| 909 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_malformed_headers_request_to_client) { |
| 910 |
(void)allocator; |
| 911 |
struct fixture *fixture = ctx; |
| 912 |
|
| 913 |
|
| 914 |
uint8_t input[] = { |
| 915 |
0x00, 0x00, 0x03, |
| 916 |
AWS_H2_FRAME_T_HEADERS, |
| 917 |
AWS_H2_FRAME_F_END_HEADERS | AWS_H2_FRAME_F_END_STREAM, |
| 918 |
0x00, 0x00, 0x00, 0x01, |
| 919 |
|
| 920 |
0x82, |
| 921 |
0x86, |
| 922 |
0x84, |
| 923 |
}; |
| 924 |
|
| 925 |
|
| 926 |
|
| 927 |
ASSERT_H2ERR_SUCCESS(s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 928 |
|
| 929 |
|
| 930 |
struct h2_decoded_frame *frame = h2_decode_tester_latest_frame(&fixture->decode); |
| 931 |
ASSERT_SUCCESS(h2_decoded_frame_check_finished(frame, AWS_H2_FRAME_T_HEADERS, 1 )); |
| 932 |
ASSERT_TRUE(frame->headers_malformed); |
| 933 |
|
| 934 |
ASSERT_TRUE(frame->end_stream); |
| 935 |
return AWS_OP_SUCCESS; |
| 936 |
} |
| 937 |
|
| 938 |
|
| 939 |
|
| 940 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_malformed_headers_mixed_pseudoheaders) { |
| 941 |
(void)allocator; |
| 942 |
struct fixture *fixture = ctx; |
| 943 |
|
| 944 |
|
| 945 |
uint8_t input[] = { |
| 946 |
0x00, 0x00, 0x06, |
| 947 |
AWS_H2_FRAME_T_HEADERS, |
| 948 |
AWS_H2_FRAME_F_END_HEADERS | AWS_H2_FRAME_F_END_STREAM, |
| 949 |
0x00, 0x00, 0x00, 0x01, |
| 950 |
|
| 951 |
0x82, |
| 952 |
0x48, 0x03, '3', '0', '2', |
| 953 |
}; |
| 954 |
|
| 955 |
|
| 956 |
|
| 957 |
ASSERT_H2ERR_SUCCESS(s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 958 |
|
| 959 |
|
| 960 |
struct h2_decoded_frame *frame = h2_decode_tester_latest_frame(&fixture->decode); |
| 961 |
ASSERT_SUCCESS(h2_decoded_frame_check_finished(frame, AWS_H2_FRAME_T_HEADERS, 1 )); |
| 962 |
ASSERT_TRUE(frame->headers_malformed); |
| 963 |
|
| 964 |
ASSERT_TRUE(frame->end_stream); |
| 965 |
return AWS_OP_SUCCESS; |
| 966 |
} |
| 967 |
|
| 968 |
|
| 969 |
|
| 970 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_malformed_headers_late_pseudoheaders) { |
| 971 |
(void)allocator; |
| 972 |
struct fixture *fixture = ctx; |
| 973 |
|
| 974 |
|
| 975 |
uint8_t input[] = { |
| 976 |
0x00, 0x00, 11, |
| 977 |
AWS_H2_FRAME_T_HEADERS, |
| 978 |
AWS_H2_FRAME_F_END_HEADERS | AWS_H2_FRAME_F_END_STREAM, |
| 979 |
0x00, 0x00, 0x00, 0x01, |
| 980 |
|
| 981 |
0x7a, 0x04, 't', 'e', 's', 't', |
| 982 |
0x48, 0x03, '3', '0', '2', |
| 983 |
}; |
| 984 |
|
| 985 |
|
| 986 |
|
| 987 |
ASSERT_H2ERR_SUCCESS(s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 988 |
|
| 989 |
|
| 990 |
struct h2_decoded_frame *frame = h2_decode_tester_latest_frame(&fixture->decode); |
| 991 |
ASSERT_SUCCESS(h2_decoded_frame_check_finished(frame, AWS_H2_FRAME_T_HEADERS, 1 )); |
| 992 |
ASSERT_TRUE(frame->headers_malformed); |
| 993 |
|
| 994 |
ASSERT_TRUE(frame->end_stream); |
| 995 |
return AWS_OP_SUCCESS; |
| 996 |
} |
| 997 |
|
| 998 |
|
| 999 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_malformed_headers_trailer_must_end_stream) { |
| 1000 |
(void)allocator; |
| 1001 |
struct fixture *fixture = ctx; |
| 1002 |
|
| 1003 |
|
| 1004 |
uint8_t input[] = { |
| 1005 |
0x00, 0x00, 0x00, |
| 1006 |
AWS_H2_FRAME_T_HEADERS, |
| 1007 |
AWS_H2_FRAME_F_END_HEADERS, |
| 1008 |
0x76, 0x54, 0x32, 0x10, |
| 1009 |
|
| 1010 |
}; |
| 1011 |
|
| 1012 |
|
| 1013 |
|
| 1014 |
ASSERT_H2ERR_SUCCESS(s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 1015 |
|
| 1016 |
|
| 1017 |
struct h2_decoded_frame *frame = h2_decode_tester_latest_frame(&fixture->decode); |
| 1018 |
ASSERT_SUCCESS(h2_decoded_frame_check_finished(frame, AWS_H2_FRAME_T_HEADERS, 0x76543210 )); |
| 1019 |
ASSERT_TRUE(frame->headers_malformed); |
| 1020 |
ASSERT_FALSE(frame->end_stream); |
| 1021 |
return AWS_OP_SUCCESS; |
| 1022 |
} |
| 1023 |
|
| 1024 |
|
| 1025 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_malformed_header_continues_hpack_parsing) { |
| 1026 |
(void)allocator; |
| 1027 |
struct fixture *fixture = ctx; |
| 1028 |
|
| 1029 |
|
| 1030 |
uint8_t input[] = { |
| 1031 |
|
| 1032 |
0x00, 0x00, 15, |
| 1033 |
AWS_H2_FRAME_T_HEADERS, |
| 1034 |
AWS_H2_FRAME_F_END_HEADERS, |
| 1035 |
0x00, 0x00, 0x00, 0x01, |
| 1036 |
|
| 1037 |
0x48, 0x03, '3', '0', '2', |
| 1038 |
0x40, 0x01, ',', 0x01, 'a', |
| 1039 |
0x40, 0x01, 'b', 0x01, 'c', |
| 1040 |
|
| 1041 |
|
| 1042 |
|
| 1043 |
|
| 1044 |
|
| 1045 |
|
| 1046 |
|
| 1047 |
|
| 1048 |
|
| 1049 |
0x00, 0x00, 2, |
| 1050 |
AWS_H2_FRAME_T_HEADERS, |
| 1051 |
AWS_H2_FRAME_F_END_HEADERS, |
| 1052 |
0x00, 0x00, 0x00, 0x03, |
| 1053 |
|
| 1054 |
0xc0, |
| 1055 |
0xbe, |
| 1056 |
}; |
| 1057 |
|
| 1058 |
|
| 1059 |
|
| 1060 |
ASSERT_H2ERR_SUCCESS(s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 1061 |
|
| 1062 |
|
| 1063 |
ASSERT_UINT_EQUALS(2, h2_decode_tester_frame_count(&fixture->decode)); |
| 1064 |
|
| 1065 |
|
| 1066 |
struct h2_decoded_frame *frame = h2_decode_tester_get_frame(&fixture->decode, 0); |
| 1067 |
ASSERT_SUCCESS(h2_decoded_frame_check_finished(frame, AWS_H2_FRAME_T_HEADERS, 1 )); |
| 1068 |
ASSERT_TRUE(frame->headers_malformed); |
| 1069 |
|
| 1070 |
|
| 1071 |
frame = h2_decode_tester_get_frame(&fixture->decode, 1); |
| 1072 |
ASSERT_SUCCESS(h2_decoded_frame_check_finished(frame, AWS_H2_FRAME_T_HEADERS, 3 )); |
| 1073 |
ASSERT_FALSE(frame->headers_malformed); |
| 1074 |
ASSERT_UINT_EQUALS(2, aws_http_headers_count(frame->headers)); |
| 1075 |
ASSERT_SUCCESS(s_check_header(frame, 0, ":status", "302", AWS_HTTP_HEADER_COMPRESSION_USE_CACHE)); |
| 1076 |
ASSERT_SUCCESS(s_check_header(frame, 1, "b", "c", AWS_HTTP_HEADER_COMPRESSION_USE_CACHE)); |
| 1077 |
ASSERT_INT_EQUALS(AWS_HTTP_HEADER_BLOCK_MAIN, frame->header_block_type); |
| 1078 |
|
| 1079 |
return AWS_OP_SUCCESS; |
| 1080 |
} |
| 1081 |
|
| 1082 |
|
| 1083 |
|
| 1084 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_continuation) { |
| 1085 |
(void)allocator; |
| 1086 |
struct fixture *fixture = ctx; |
| 1087 |
|
| 1088 |
|
| 1089 |
uint8_t input[] = { |
| 1090 |
|
| 1091 |
0x00, 0x00, 0x05, |
| 1092 |
AWS_H2_FRAME_T_HEADERS, |
| 1093 |
AWS_H2_FRAME_F_END_STREAM, |
| 1094 |
0x76, 0x54, 0x32, 0x10, |
| 1095 |
|
| 1096 |
0x48, 0x03, '3', '0', '2', |
| 1097 |
|
| 1098 |
|
| 1099 |
0x00, 0x00, 0x09, |
| 1100 |
AWS_H2_FRAME_T_CONTINUATION, |
| 1101 |
AWS_H2_FRAME_F_END_HEADERS, |
| 1102 |
0x76, 0x54, 0x32, 0x10, |
| 1103 |
|
| 1104 |
0x58, 0x07, 'p', 'r', 'i', 'v', 'a', 't', 'e', |
| 1105 |
}; |
| 1106 |
|
| 1107 |
|
| 1108 |
|
| 1109 |
ASSERT_H2ERR_SUCCESS(s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 1110 |
|
| 1111 |
|
| 1112 |
struct h2_decoded_frame *frame = h2_decode_tester_latest_frame(&fixture->decode); |
| 1113 |
ASSERT_SUCCESS(h2_decoded_frame_check_finished(frame, AWS_H2_FRAME_T_HEADERS, 0x76543210 )); |
| 1114 |
ASSERT_FALSE(frame->headers_malformed); |
| 1115 |
ASSERT_UINT_EQUALS(2, aws_http_headers_count(frame->headers)); |
| 1116 |
ASSERT_SUCCESS(s_check_header(frame, 0, ":status", "302", AWS_HTTP_HEADER_COMPRESSION_USE_CACHE)); |
| 1117 |
ASSERT_SUCCESS(s_check_header(frame, 1, "cache-control", "private", AWS_HTTP_HEADER_COMPRESSION_USE_CACHE)); |
| 1118 |
ASSERT_INT_EQUALS(AWS_HTTP_HEADER_BLOCK_MAIN, frame->header_block_type); |
| 1119 |
ASSERT_TRUE(frame->end_stream); |
| 1120 |
return AWS_OP_SUCCESS; |
| 1121 |
} |
| 1122 |
|
| 1123 |
|
| 1124 |
|
| 1125 |
|
| 1126 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_continuation_ignores_unknown_flags) { |
| 1127 |
(void)allocator; |
| 1128 |
struct fixture *fixture = ctx; |
| 1129 |
|
| 1130 |
|
| 1131 |
uint8_t input[] = { |
| 1132 |
|
| 1133 |
0x00, 0x00, 0x05, |
| 1134 |
AWS_H2_FRAME_T_HEADERS, |
| 1135 |
0x0, |
| 1136 |
0x76, 0x54, 0x32, 0x10, |
| 1137 |
|
| 1138 |
0x48, 0x03, '3', '0', '2', |
| 1139 |
|
| 1140 |
|
| 1141 |
0x00, 0x00, 0x09, |
| 1142 |
AWS_H2_FRAME_T_CONTINUATION, |
| 1143 |
0xFF, |
| 1144 |
0x76, 0x54, 0x32, 0x10, |
| 1145 |
|
| 1146 |
0x58, 0x07, 'p', 'r', 'i', 'v', 'a', 't', 'e', |
| 1147 |
}; |
| 1148 |
|
| 1149 |
|
| 1150 |
|
| 1151 |
ASSERT_H2ERR_SUCCESS(s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 1152 |
|
| 1153 |
|
| 1154 |
struct h2_decoded_frame *frame = h2_decode_tester_latest_frame(&fixture->decode); |
| 1155 |
ASSERT_SUCCESS(h2_decoded_frame_check_finished(frame, AWS_H2_FRAME_T_HEADERS, 0x76543210 )); |
| 1156 |
ASSERT_FALSE(frame->headers_malformed); |
| 1157 |
ASSERT_UINT_EQUALS(2, aws_http_headers_count(frame->headers)); |
| 1158 |
ASSERT_SUCCESS(s_check_header(frame, 0, ":status", "302", AWS_HTTP_HEADER_COMPRESSION_USE_CACHE)); |
| 1159 |
ASSERT_SUCCESS(s_check_header(frame, 1, "cache-control", "private", AWS_HTTP_HEADER_COMPRESSION_USE_CACHE)); |
| 1160 |
ASSERT_INT_EQUALS(AWS_HTTP_HEADER_BLOCK_MAIN, frame->header_block_type); |
| 1161 |
return AWS_OP_SUCCESS; |
| 1162 |
} |
| 1163 |
|
| 1164 |
|
| 1165 |
|
| 1166 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_continuation_header_field_spans_frames) { |
| 1167 |
(void)allocator; |
| 1168 |
struct fixture *fixture = ctx; |
| 1169 |
|
| 1170 |
|
| 1171 |
uint8_t input[] = { |
| 1172 |
|
| 1173 |
0x00, 0x00, 0x06, |
| 1174 |
AWS_H2_FRAME_T_HEADERS, |
| 1175 |
AWS_H2_FRAME_F_PADDED, |
| 1176 |
0x76, 0x54, 0x32, 0x10, |
| 1177 |
|
| 1178 |
0x02, |
| 1179 |
0x48, 0x03, '3', |
| 1180 |
0x00, 0x00, |
| 1181 |
|
| 1182 |
|
| 1183 |
0x00, 0x00, 0x02, |
| 1184 |
AWS_H2_FRAME_T_CONTINUATION, |
| 1185 |
AWS_H2_FRAME_F_END_HEADERS, |
| 1186 |
0x76, 0x54, 0x32, 0x10, |
| 1187 |
|
| 1188 |
'0', '2', |
| 1189 |
}; |
| 1190 |
|
| 1191 |
|
| 1192 |
|
| 1193 |
ASSERT_H2ERR_SUCCESS(s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 1194 |
|
| 1195 |
|
| 1196 |
struct h2_decoded_frame *frame = h2_decode_tester_latest_frame(&fixture->decode); |
| 1197 |
ASSERT_SUCCESS(h2_decoded_frame_check_finished(frame, AWS_H2_FRAME_T_HEADERS, 0x76543210 )); |
| 1198 |
ASSERT_FALSE(frame->headers_malformed); |
| 1199 |
ASSERT_UINT_EQUALS(1, aws_http_headers_count(frame->headers)); |
| 1200 |
ASSERT_SUCCESS(s_check_header(frame, 0, ":status", "302", AWS_HTTP_HEADER_COMPRESSION_USE_CACHE)); |
| 1201 |
ASSERT_INT_EQUALS(AWS_HTTP_HEADER_BLOCK_MAIN, frame->header_block_type); |
| 1202 |
ASSERT_FALSE(frame->end_stream); |
| 1203 |
return AWS_OP_SUCCESS; |
| 1204 |
} |
| 1205 |
|
| 1206 |
|
| 1207 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_continuation_many_frames) { |
| 1208 |
(void)allocator; |
| 1209 |
struct fixture *fixture = ctx; |
| 1210 |
|
| 1211 |
|
| 1212 |
uint8_t input[] = { |
| 1213 |
|
| 1214 |
0x00, 0x00, 0x05, |
| 1215 |
AWS_H2_FRAME_T_HEADERS, |
| 1216 |
AWS_H2_FRAME_F_END_STREAM, |
| 1217 |
0x76, 0x54, 0x32, 0x10, |
| 1218 |
|
| 1219 |
0x48, 0x03, '3', '0', '2', |
| 1220 |
|
| 1221 |
|
| 1222 |
0x00, 0x00, 0x09, |
| 1223 |
AWS_H2_FRAME_T_CONTINUATION, |
| 1224 |
0x0, |
| 1225 |
0x76, 0x54, 0x32, 0x10, |
| 1226 |
|
| 1227 |
0x58, 0x07, 'p', 'r', 'i', 'v', 'a', 't', 'e', |
| 1228 |
|
| 1229 |
|
| 1230 |
0x00, 0x00, 0x08, |
| 1231 |
AWS_H2_FRAME_T_CONTINUATION, |
| 1232 |
AWS_H2_FRAME_F_END_HEADERS, |
| 1233 |
0x76, 0x54, 0x32, 0x10, |
| 1234 |
|
| 1235 |
0x40, 0x02, 'h', 'i', 0x03, 'm', 'o', 'm', |
| 1236 |
}; |
| 1237 |
|
| 1238 |
|
| 1239 |
|
| 1240 |
ASSERT_H2ERR_SUCCESS(s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 1241 |
|
| 1242 |
|
| 1243 |
struct h2_decoded_frame *frame = h2_decode_tester_latest_frame(&fixture->decode); |
| 1244 |
ASSERT_SUCCESS(h2_decoded_frame_check_finished(frame, AWS_H2_FRAME_T_HEADERS, 0x76543210 )); |
| 1245 |
ASSERT_FALSE(frame->headers_malformed); |
| 1246 |
ASSERT_UINT_EQUALS(3, aws_http_headers_count(frame->headers)); |
| 1247 |
ASSERT_SUCCESS(s_check_header(frame, 0, ":status", "302", AWS_HTTP_HEADER_COMPRESSION_USE_CACHE)); |
| 1248 |
ASSERT_SUCCESS(s_check_header(frame, 1, "cache-control", "private", AWS_HTTP_HEADER_COMPRESSION_USE_CACHE)); |
| 1249 |
ASSERT_SUCCESS(s_check_header(frame, 2, "hi", "mom", AWS_HTTP_HEADER_COMPRESSION_USE_CACHE)); |
| 1250 |
ASSERT_INT_EQUALS(AWS_HTTP_HEADER_BLOCK_MAIN, frame->header_block_type); |
| 1251 |
ASSERT_TRUE(frame->end_stream); |
| 1252 |
return AWS_OP_SUCCESS; |
| 1253 |
} |
| 1254 |
|
| 1255 |
|
| 1256 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_continuation_empty_payloads) { |
| 1257 |
(void)allocator; |
| 1258 |
struct fixture *fixture = ctx; |
| 1259 |
|
| 1260 |
|
| 1261 |
uint8_t input[] = { |
| 1262 |
|
| 1263 |
0x00, 0x00, 0x00, |
| 1264 |
AWS_H2_FRAME_T_HEADERS, |
| 1265 |
AWS_H2_FRAME_F_END_STREAM, |
| 1266 |
0x76, 0x54, 0x32, 0x10, |
| 1267 |
|
| 1268 |
|
| 1269 |
|
| 1270 |
0x00, 0x00, 0x00, |
| 1271 |
AWS_H2_FRAME_T_CONTINUATION, |
| 1272 |
0x0, |
| 1273 |
0x76, 0x54, 0x32, 0x10, |
| 1274 |
|
| 1275 |
|
| 1276 |
|
| 1277 |
0x00, 0x00, 0x05, |
| 1278 |
AWS_H2_FRAME_T_CONTINUATION, |
| 1279 |
AWS_H2_FRAME_F_END_HEADERS, |
| 1280 |
0x76, 0x54, 0x32, 0x10, |
| 1281 |
|
| 1282 |
0x48, 0x03, '3', '0', '2', |
| 1283 |
}; |
| 1284 |
|
| 1285 |
|
| 1286 |
|
| 1287 |
ASSERT_H2ERR_SUCCESS(s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 1288 |
|
| 1289 |
|
| 1290 |
struct h2_decoded_frame *frame = h2_decode_tester_latest_frame(&fixture->decode); |
| 1291 |
ASSERT_SUCCESS(h2_decoded_frame_check_finished(frame, AWS_H2_FRAME_T_HEADERS, 0x76543210 )); |
| 1292 |
ASSERT_FALSE(frame->headers_malformed); |
| 1293 |
ASSERT_UINT_EQUALS(1, aws_http_headers_count(frame->headers)); |
| 1294 |
ASSERT_SUCCESS(s_check_header(frame, 0, ":status", "302", AWS_HTTP_HEADER_COMPRESSION_USE_CACHE)); |
| 1295 |
ASSERT_INT_EQUALS(AWS_HTTP_HEADER_BLOCK_MAIN, frame->header_block_type); |
| 1296 |
ASSERT_TRUE(frame->end_stream); |
| 1297 |
return AWS_OP_SUCCESS; |
| 1298 |
} |
| 1299 |
|
| 1300 |
|
| 1301 |
|
| 1302 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_err_continuation_frame_expected) { |
| 1303 |
(void)allocator; |
| 1304 |
struct fixture *fixture = ctx; |
| 1305 |
|
| 1306 |
|
| 1307 |
uint8_t input[] = { |
| 1308 |
|
| 1309 |
0x00, 0x00, 0x05, |
| 1310 |
AWS_H2_FRAME_T_HEADERS, |
| 1311 |
0x0, |
| 1312 |
0x76, 0x54, 0x32, 0x10, |
| 1313 |
|
| 1314 |
0x48, 0x03, '3', '0', '2', |
| 1315 |
|
| 1316 |
|
| 1317 |
0x00, 0x00, 0x05, |
| 1318 |
AWS_H2_FRAME_T_HEADERS, |
| 1319 |
0x0, |
| 1320 |
0x76, 0x54, 0x32, 0x12, |
| 1321 |
|
| 1322 |
0x48, 0x03, '3', '0', '2', |
| 1323 |
}; |
| 1324 |
|
| 1325 |
|
| 1326 |
|
| 1327 |
ASSERT_H2ERR_ERROR( |
| 1328 |
AWS_HTTP2_ERR_PROTOCOL_ERROR, s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 1329 |
|
| 1330 |
return AWS_OP_SUCCESS; |
| 1331 |
} |
| 1332 |
|
| 1333 |
|
| 1334 |
|
| 1335 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_err_continuation_frame_same_stream_expected) { |
| 1336 |
(void)allocator; |
| 1337 |
struct fixture *fixture = ctx; |
| 1338 |
|
| 1339 |
|
| 1340 |
uint8_t input[] = { |
| 1341 |
|
| 1342 |
0x00, 0x00, 0x05, |
| 1343 |
AWS_H2_FRAME_T_HEADERS, |
| 1344 |
AWS_H2_FRAME_F_END_STREAM, |
| 1345 |
0x76, 0x54, 0x32, 0x10, |
| 1346 |
|
| 1347 |
0x48, 0x03, '3', '0', '2', |
| 1348 |
|
| 1349 |
|
| 1350 |
0x00, 0x00, 0x09, |
| 1351 |
AWS_H2_FRAME_T_CONTINUATION, |
| 1352 |
AWS_H2_FRAME_F_END_HEADERS, |
| 1353 |
0x76, 0x54, 0x32, 0x12, |
| 1354 |
|
| 1355 |
0x58, 0x07, 'p', 'r', 'i', 'v', 'a', 't', 'e', |
| 1356 |
}; |
| 1357 |
|
| 1358 |
|
| 1359 |
|
| 1360 |
ASSERT_H2ERR_ERROR( |
| 1361 |
AWS_HTTP2_ERR_PROTOCOL_ERROR, s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 1362 |
|
| 1363 |
return AWS_OP_SUCCESS; |
| 1364 |
} |
| 1365 |
|
| 1366 |
|
| 1367 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_err_partial_header) { |
| 1368 |
(void)allocator; |
| 1369 |
struct fixture *fixture = ctx; |
| 1370 |
|
| 1371 |
|
| 1372 |
uint8_t input[] = { |
| 1373 |
|
| 1374 |
0x00, 0x00, 0x03, |
| 1375 |
AWS_H2_FRAME_T_HEADERS, |
| 1376 |
AWS_H2_FRAME_F_END_HEADERS, |
| 1377 |
0x76, 0x54, 0x32, 0x10, |
| 1378 |
|
| 1379 |
0x48, 0x03, '3', |
| 1380 |
}; |
| 1381 |
|
| 1382 |
|
| 1383 |
|
| 1384 |
ASSERT_H2ERR_ERROR( |
| 1385 |
AWS_HTTP2_ERR_COMPRESSION_ERROR, s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 1386 |
|
| 1387 |
return AWS_OP_SUCCESS; |
| 1388 |
} |
| 1389 |
|
| 1390 |
|
| 1391 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_err_bad_hpack_data) { |
| 1392 |
(void)allocator; |
| 1393 |
struct fixture *fixture = ctx; |
| 1394 |
|
| 1395 |
|
| 1396 |
uint8_t input[] = { |
| 1397 |
|
| 1398 |
0x00, 0x00, 32, |
| 1399 |
AWS_H2_FRAME_T_HEADERS, |
| 1400 |
AWS_H2_FRAME_F_END_HEADERS, |
| 1401 |
0x76, 0x54, 0x32, 0x10, |
| 1402 |
|
| 1403 |
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, |
| 1404 |
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, |
| 1405 |
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, |
| 1406 |
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, |
| 1407 |
}; |
| 1408 |
|
| 1409 |
|
| 1410 |
|
| 1411 |
ASSERT_H2ERR_ERROR( |
| 1412 |
AWS_HTTP2_ERR_COMPRESSION_ERROR, s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 1413 |
|
| 1414 |
return AWS_OP_SUCCESS; |
| 1415 |
} |
| 1416 |
|
| 1417 |
|
| 1418 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_priority) { |
| 1419 |
(void)allocator; |
| 1420 |
struct fixture *fixture = ctx; |
| 1421 |
|
| 1422 |
|
| 1423 |
uint8_t input[] = { |
| 1424 |
0x00, 0x00, 0x05, |
| 1425 |
AWS_H2_FRAME_T_PRIORITY, |
| 1426 |
0x00, |
| 1427 |
0x76, 0x54, 0x32, 0x10, |
| 1428 |
|
| 1429 |
0x81, 0x23, 0x45, 0x67, |
| 1430 |
0x09, |
| 1431 |
}; |
| 1432 |
|
| 1433 |
|
| 1434 |
ASSERT_H2ERR_SUCCESS(s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 1435 |
|
| 1436 |
|
| 1437 |
ASSERT_UINT_EQUALS(0, h2_decode_tester_frame_count(&fixture->decode)); |
| 1438 |
return AWS_OP_SUCCESS; |
| 1439 |
} |
| 1440 |
|
| 1441 |
|
| 1442 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_priority_ignores_unknown_flags) { |
| 1443 |
(void)allocator; |
| 1444 |
struct fixture *fixture = ctx; |
| 1445 |
|
| 1446 |
|
| 1447 |
uint8_t input[] = { |
| 1448 |
0x00, 0x00, 0x05, |
| 1449 |
AWS_H2_FRAME_T_PRIORITY, |
| 1450 |
0xFF, |
| 1451 |
0x76, 0x54, 0x32, 0x10, |
| 1452 |
|
| 1453 |
0x81, 0x23, 0x45, 0x67, |
| 1454 |
0x09, |
| 1455 |
}; |
| 1456 |
|
| 1457 |
|
| 1458 |
ASSERT_H2ERR_SUCCESS(s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 1459 |
|
| 1460 |
|
| 1461 |
ASSERT_UINT_EQUALS(0, h2_decode_tester_frame_count(&fixture->decode)); |
| 1462 |
return AWS_OP_SUCCESS; |
| 1463 |
} |
| 1464 |
|
| 1465 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_err_priority_requires_stream_id) { |
| 1466 |
(void)allocator; |
| 1467 |
struct fixture *fixture = ctx; |
| 1468 |
|
| 1469 |
|
| 1470 |
uint8_t input[] = { |
| 1471 |
0x00, 0x00, 0x05, |
| 1472 |
AWS_H2_FRAME_T_PRIORITY, |
| 1473 |
0x00, |
| 1474 |
0x00, 0x00, 0x00, 0x00, |
| 1475 |
|
| 1476 |
0x81, 0x23, 0x45, 0x67, |
| 1477 |
0x09, |
| 1478 |
}; |
| 1479 |
|
| 1480 |
|
| 1481 |
ASSERT_H2ERR_ERROR( |
| 1482 |
AWS_HTTP2_ERR_PROTOCOL_ERROR, s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 1483 |
|
| 1484 |
return AWS_OP_SUCCESS; |
| 1485 |
} |
| 1486 |
|
| 1487 |
|
| 1488 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_err_priority_payload_too_small) { |
| 1489 |
(void)allocator; |
| 1490 |
struct fixture *fixture = ctx; |
| 1491 |
|
| 1492 |
|
| 1493 |
uint8_t input[] = { |
| 1494 |
0x00, 0x00, 0x04, |
| 1495 |
AWS_H2_FRAME_T_PRIORITY, |
| 1496 |
0x00, |
| 1497 |
0x76, 0x54, 0x32, 0x10, |
| 1498 |
|
| 1499 |
0x81, 0x23, 0x45, 0x67, |
| 1500 |
|
| 1501 |
}; |
| 1502 |
|
| 1503 |
|
| 1504 |
ASSERT_H2ERR_ERROR( |
| 1505 |
AWS_HTTP2_ERR_FRAME_SIZE_ERROR, s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 1506 |
|
| 1507 |
return AWS_OP_SUCCESS; |
| 1508 |
} |
| 1509 |
|
| 1510 |
|
| 1511 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_err_priority_payload_too_large) { |
| 1512 |
(void)allocator; |
| 1513 |
struct fixture *fixture = ctx; |
| 1514 |
|
| 1515 |
|
| 1516 |
uint8_t input[] = { |
| 1517 |
0x00, 0x00, 0x06, |
| 1518 |
AWS_H2_FRAME_T_PRIORITY, |
| 1519 |
0x00, |
| 1520 |
0x76, 0x54, 0x32, 0x10, |
| 1521 |
|
| 1522 |
0x81, 0x23, 0x45, 0x67, |
| 1523 |
0x09, |
| 1524 |
0x00, |
| 1525 |
}; |
| 1526 |
|
| 1527 |
|
| 1528 |
ASSERT_H2ERR_ERROR( |
| 1529 |
AWS_HTTP2_ERR_FRAME_SIZE_ERROR, s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 1530 |
|
| 1531 |
return AWS_OP_SUCCESS; |
| 1532 |
} |
| 1533 |
|
| 1534 |
|
| 1535 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_rst_stream) { |
| 1536 |
(void)allocator; |
| 1537 |
struct fixture *fixture = ctx; |
| 1538 |
|
| 1539 |
|
| 1540 |
uint8_t input[] = { |
| 1541 |
0x00, 0x00, 0x04, |
| 1542 |
AWS_H2_FRAME_T_RST_STREAM, |
| 1543 |
0x00, |
| 1544 |
0x76, 0x54, 0x32, 0x10, |
| 1545 |
|
| 1546 |
0xFF, 0xEE, 0xDD, 0xCC, |
| 1547 |
}; |
| 1548 |
|
| 1549 |
|
| 1550 |
ASSERT_H2ERR_SUCCESS(s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 1551 |
|
| 1552 |
|
| 1553 |
ASSERT_UINT_EQUALS(1, h2_decode_tester_frame_count(&fixture->decode)); |
| 1554 |
struct h2_decoded_frame *frame = h2_decode_tester_latest_frame(&fixture->decode); |
| 1555 |
ASSERT_SUCCESS(h2_decoded_frame_check_finished(frame, AWS_H2_FRAME_T_RST_STREAM, 0x76543210 )); |
| 1556 |
ASSERT_UINT_EQUALS(0xFFEEDDCC, frame->error_code); |
| 1557 |
return AWS_OP_SUCCESS; |
| 1558 |
} |
| 1559 |
|
| 1560 |
|
| 1561 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_rst_stream_ignores_unknown_flags) { |
| 1562 |
(void)allocator; |
| 1563 |
struct fixture *fixture = ctx; |
| 1564 |
|
| 1565 |
|
| 1566 |
uint8_t input[] = { |
| 1567 |
0x00, 0x00, 0x04, |
| 1568 |
AWS_H2_FRAME_T_RST_STREAM, |
| 1569 |
0xFF, |
| 1570 |
0x76, 0x54, 0x32, 0x10, |
| 1571 |
|
| 1572 |
0xFF, 0xEE, 0xDD, 0xCC, |
| 1573 |
}; |
| 1574 |
|
| 1575 |
|
| 1576 |
ASSERT_H2ERR_SUCCESS(s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 1577 |
|
| 1578 |
|
| 1579 |
ASSERT_UINT_EQUALS(1, h2_decode_tester_frame_count(&fixture->decode)); |
| 1580 |
struct h2_decoded_frame *frame = h2_decode_tester_latest_frame(&fixture->decode); |
| 1581 |
ASSERT_SUCCESS(h2_decoded_frame_check_finished(frame, AWS_H2_FRAME_T_RST_STREAM, 0x76543210 )); |
| 1582 |
ASSERT_UINT_EQUALS(0xFFEEDDCC, frame->error_code); |
| 1583 |
return AWS_OP_SUCCESS; |
| 1584 |
} |
| 1585 |
|
| 1586 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_err_rst_stream_requires_stream_id) { |
| 1587 |
(void)allocator; |
| 1588 |
struct fixture *fixture = ctx; |
| 1589 |
|
| 1590 |
|
| 1591 |
uint8_t input[] = { |
| 1592 |
0x00, 0x00, 0x04, |
| 1593 |
AWS_H2_FRAME_T_RST_STREAM, |
| 1594 |
0x00, |
| 1595 |
0x00, 0x00, 0x00, 0x00, |
| 1596 |
|
| 1597 |
0xFF, 0xEE, 0xDD, 0xCC, |
| 1598 |
}; |
| 1599 |
|
| 1600 |
|
| 1601 |
ASSERT_H2ERR_ERROR( |
| 1602 |
AWS_HTTP2_ERR_PROTOCOL_ERROR, s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 1603 |
|
| 1604 |
return AWS_OP_SUCCESS; |
| 1605 |
} |
| 1606 |
|
| 1607 |
|
| 1608 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_err_rst_stream_payload_too_small) { |
| 1609 |
(void)allocator; |
| 1610 |
struct fixture *fixture = ctx; |
| 1611 |
|
| 1612 |
|
| 1613 |
uint8_t input[] = { |
| 1614 |
0x00, 0x00, 0x03, |
| 1615 |
AWS_H2_FRAME_T_RST_STREAM, |
| 1616 |
0x00, |
| 1617 |
0x76, 0x54, 0x32, 0x10, |
| 1618 |
|
| 1619 |
0xFF, 0xEE, 0xDD, |
| 1620 |
}; |
| 1621 |
|
| 1622 |
|
| 1623 |
ASSERT_H2ERR_ERROR( |
| 1624 |
AWS_HTTP2_ERR_FRAME_SIZE_ERROR, s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 1625 |
|
| 1626 |
return AWS_OP_SUCCESS; |
| 1627 |
} |
| 1628 |
|
| 1629 |
|
| 1630 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_err_rst_stream_payload_too_large) { |
| 1631 |
(void)allocator; |
| 1632 |
struct fixture *fixture = ctx; |
| 1633 |
|
| 1634 |
|
| 1635 |
uint8_t input[] = { |
| 1636 |
0x00, 0x00, 0x05, |
| 1637 |
AWS_H2_FRAME_T_RST_STREAM, |
| 1638 |
0x00, |
| 1639 |
0x76, 0x54, 0x32, 0x10, |
| 1640 |
|
| 1641 |
0xFF, 0xEE, 0xDD, 0xCC, |
| 1642 |
0x00, |
| 1643 |
}; |
| 1644 |
|
| 1645 |
|
| 1646 |
ASSERT_H2ERR_ERROR( |
| 1647 |
AWS_HTTP2_ERR_FRAME_SIZE_ERROR, s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 1648 |
|
| 1649 |
return AWS_OP_SUCCESS; |
| 1650 |
} |
| 1651 |
|
| 1652 |
|
| 1653 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_settings) { |
| 1654 |
(void)allocator; |
| 1655 |
struct fixture *fixture = ctx; |
| 1656 |
|
| 1657 |
|
| 1658 |
uint8_t input[] = { |
| 1659 |
0x00, 0x00, 12, |
| 1660 |
AWS_H2_FRAME_T_SETTINGS, |
| 1661 |
0x00, |
| 1662 |
0x00, 0x00, 0x00, 0x00, |
| 1663 |
|
| 1664 |
0x00, 0x05, |
| 1665 |
0x00, 0xFF, 0xFF, 0xFF, |
| 1666 |
0x00, 0x02, |
| 1667 |
0x00, 0x00, 0x00, 0x01, |
| 1668 |
}; |
| 1669 |
|
| 1670 |
|
| 1671 |
ASSERT_H2ERR_SUCCESS(s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 1672 |
|
| 1673 |
|
| 1674 |
ASSERT_UINT_EQUALS(1, h2_decode_tester_frame_count(&fixture->decode)); |
| 1675 |
struct h2_decoded_frame *frame = h2_decode_tester_latest_frame(&fixture->decode); |
| 1676 |
ASSERT_SUCCESS(h2_decoded_frame_check_finished(frame, AWS_H2_FRAME_T_SETTINGS, 0 )); |
| 1677 |
ASSERT_FALSE(frame->ack); |
| 1678 |
ASSERT_UINT_EQUALS(2, aws_array_list_length(&frame->settings)); |
| 1679 |
|
| 1680 |
struct aws_http2_setting setting; |
| 1681 |
aws_array_list_get_at(&frame->settings, &setting, 0); |
| 1682 |
ASSERT_UINT_EQUALS(0x0005, setting.id); |
| 1683 |
ASSERT_UINT_EQUALS(0x00FFFFFF, setting.value); |
| 1684 |
|
| 1685 |
aws_array_list_get_at(&frame->settings, &setting, 1); |
| 1686 |
ASSERT_UINT_EQUALS(0x0002, setting.id); |
| 1687 |
ASSERT_UINT_EQUALS(0x00000001, setting.value); |
| 1688 |
|
| 1689 |
return AWS_OP_SUCCESS; |
| 1690 |
} |
| 1691 |
|
| 1692 |
|
| 1693 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_settings_empty) { |
| 1694 |
(void)allocator; |
| 1695 |
struct fixture *fixture = ctx; |
| 1696 |
|
| 1697 |
|
| 1698 |
uint8_t input[] = { |
| 1699 |
0x00, 0x00, 0x00, |
| 1700 |
AWS_H2_FRAME_T_SETTINGS, |
| 1701 |
0x00, |
| 1702 |
0x00, 0x00, 0x00, 0x00, |
| 1703 |
|
| 1704 |
}; |
| 1705 |
|
| 1706 |
|
| 1707 |
ASSERT_H2ERR_SUCCESS(s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 1708 |
|
| 1709 |
|
| 1710 |
ASSERT_UINT_EQUALS(1, h2_decode_tester_frame_count(&fixture->decode)); |
| 1711 |
struct h2_decoded_frame *frame = h2_decode_tester_latest_frame(&fixture->decode); |
| 1712 |
ASSERT_SUCCESS(h2_decoded_frame_check_finished(frame, AWS_H2_FRAME_T_SETTINGS, 0 )); |
| 1713 |
ASSERT_FALSE(frame->ack); |
| 1714 |
ASSERT_UINT_EQUALS(0, aws_array_list_length(&frame->settings)); |
| 1715 |
|
| 1716 |
return AWS_OP_SUCCESS; |
| 1717 |
} |
| 1718 |
|
| 1719 |
|
| 1720 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_settings_ack) { |
| 1721 |
(void)allocator; |
| 1722 |
struct fixture *fixture = ctx; |
| 1723 |
|
| 1724 |
|
| 1725 |
uint8_t input[] = { |
| 1726 |
0x00, 0x00, 0x00, |
| 1727 |
AWS_H2_FRAME_T_SETTINGS, |
| 1728 |
AWS_H2_FRAME_F_ACK, |
| 1729 |
0x00, 0x00, 0x00, 0x00, |
| 1730 |
|
| 1731 |
}; |
| 1732 |
|
| 1733 |
|
| 1734 |
ASSERT_H2ERR_SUCCESS(s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 1735 |
|
| 1736 |
|
| 1737 |
ASSERT_UINT_EQUALS(1, h2_decode_tester_frame_count(&fixture->decode)); |
| 1738 |
struct h2_decoded_frame *frame = h2_decode_tester_latest_frame(&fixture->decode); |
| 1739 |
ASSERT_SUCCESS(h2_decoded_frame_check_finished(frame, AWS_H2_FRAME_T_SETTINGS, 0 )); |
| 1740 |
ASSERT_TRUE(frame->ack); |
| 1741 |
ASSERT_UINT_EQUALS(0, aws_array_list_length(&frame->settings)); |
| 1742 |
|
| 1743 |
return AWS_OP_SUCCESS; |
| 1744 |
} |
| 1745 |
|
| 1746 |
|
| 1747 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_settings_ignores_unknown_ids) { |
| 1748 |
(void)allocator; |
| 1749 |
struct fixture *fixture = ctx; |
| 1750 |
|
| 1751 |
|
| 1752 |
uint8_t input[] = { |
| 1753 |
0x00, 0x00, 18, |
| 1754 |
AWS_H2_FRAME_T_SETTINGS, |
| 1755 |
0x00, |
| 1756 |
0x00, 0x00, 0x00, 0x00, |
| 1757 |
|
| 1758 |
0x00, 0x00, |
| 1759 |
0x00, 0xFF, 0xFF, 0xFF, |
| 1760 |
0x00, 0x01, |
| 1761 |
0x00, 0x00, 0x00, 0x01, |
| 1762 |
0x00, AWS_HTTP2_SETTINGS_END_RANGE, |
| 1763 |
0x00, 0x00, 0x00, 0x01, |
| 1764 |
}; |
| 1765 |
|
| 1766 |
|
| 1767 |
ASSERT_H2ERR_SUCCESS(s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 1768 |
|
| 1769 |
|
| 1770 |
ASSERT_UINT_EQUALS(1, h2_decode_tester_frame_count(&fixture->decode)); |
| 1771 |
struct h2_decoded_frame *frame = h2_decode_tester_latest_frame(&fixture->decode); |
| 1772 |
ASSERT_SUCCESS(h2_decoded_frame_check_finished(frame, AWS_H2_FRAME_T_SETTINGS, 0 )); |
| 1773 |
ASSERT_FALSE(frame->ack); |
| 1774 |
ASSERT_UINT_EQUALS(1, aws_array_list_length(&frame->settings)); |
| 1775 |
|
| 1776 |
struct aws_http2_setting setting; |
| 1777 |
aws_array_list_get_at(&frame->settings, &setting, 0); |
| 1778 |
ASSERT_UINT_EQUALS(0x0001, setting.id); |
| 1779 |
ASSERT_UINT_EQUALS(0x00000001, setting.value); |
| 1780 |
|
| 1781 |
return AWS_OP_SUCCESS; |
| 1782 |
} |
| 1783 |
|
| 1784 |
|
| 1785 |
|
| 1786 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_settings_ignores_unknown_flags) { |
| 1787 |
(void)allocator; |
| 1788 |
struct fixture *fixture = ctx; |
| 1789 |
|
| 1790 |
|
| 1791 |
uint8_t input[] = { |
| 1792 |
0x00, 0x00, 0x00, |
| 1793 |
AWS_H2_FRAME_T_SETTINGS, |
| 1794 |
0xFF, |
| 1795 |
0x00, 0x00, 0x00, 0x00, |
| 1796 |
|
| 1797 |
}; |
| 1798 |
|
| 1799 |
|
| 1800 |
ASSERT_H2ERR_SUCCESS(s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 1801 |
|
| 1802 |
|
| 1803 |
ASSERT_UINT_EQUALS(1, h2_decode_tester_frame_count(&fixture->decode)); |
| 1804 |
struct h2_decoded_frame *frame = h2_decode_tester_latest_frame(&fixture->decode); |
| 1805 |
ASSERT_SUCCESS(h2_decoded_frame_check_finished(frame, AWS_H2_FRAME_T_SETTINGS, 0 )); |
| 1806 |
ASSERT_TRUE(frame->ack); |
| 1807 |
ASSERT_UINT_EQUALS(0, aws_array_list_length(&frame->settings)); |
| 1808 |
|
| 1809 |
return AWS_OP_SUCCESS; |
| 1810 |
} |
| 1811 |
|
| 1812 |
|
| 1813 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_err_settings_ack_with_data) { |
| 1814 |
(void)allocator; |
| 1815 |
struct fixture *fixture = ctx; |
| 1816 |
|
| 1817 |
|
| 1818 |
uint8_t input[] = { |
| 1819 |
0x00, 0x00, 0x06, |
| 1820 |
AWS_H2_FRAME_T_SETTINGS, |
| 1821 |
AWS_H2_FRAME_F_ACK, |
| 1822 |
0x00, 0x00, 0x00, 0x00, |
| 1823 |
|
| 1824 |
0x00, 0x05, |
| 1825 |
0x00, 0xFF, 0xFF, 0xFF, |
| 1826 |
}; |
| 1827 |
|
| 1828 |
|
| 1829 |
ASSERT_H2ERR_ERROR( |
| 1830 |
AWS_HTTP2_ERR_FRAME_SIZE_ERROR, s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 1831 |
|
| 1832 |
return AWS_OP_SUCCESS; |
| 1833 |
} |
| 1834 |
|
| 1835 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_err_settings_forbids_stream_id) { |
| 1836 |
(void)allocator; |
| 1837 |
struct fixture *fixture = ctx; |
| 1838 |
|
| 1839 |
|
| 1840 |
uint8_t input[] = { |
| 1841 |
0x00, 0x00, 12, |
| 1842 |
AWS_H2_FRAME_T_SETTINGS, |
| 1843 |
0x00, |
| 1844 |
0x00, 0x00, 0x00, 0x01, |
| 1845 |
|
| 1846 |
0x00, 0x05, |
| 1847 |
0x00, 0xFF, 0xFF, 0xFF, |
| 1848 |
0x00, 0x02, |
| 1849 |
0x00, 0x00, 0x00, 0x01, |
| 1850 |
}; |
| 1851 |
|
| 1852 |
|
| 1853 |
ASSERT_H2ERR_ERROR( |
| 1854 |
AWS_HTTP2_ERR_PROTOCOL_ERROR, s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 1855 |
|
| 1856 |
return AWS_OP_SUCCESS; |
| 1857 |
} |
| 1858 |
|
| 1859 |
|
| 1860 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_err_settings_payload_size) { |
| 1861 |
(void)allocator; |
| 1862 |
struct fixture *fixture = ctx; |
| 1863 |
|
| 1864 |
|
| 1865 |
uint8_t input[] = { |
| 1866 |
0x00, 0x00, 0x08, |
| 1867 |
AWS_H2_FRAME_T_SETTINGS, |
| 1868 |
0x00, |
| 1869 |
0x00, 0x00, 0x00, 0x00, |
| 1870 |
|
| 1871 |
0x00, 0x05, |
| 1872 |
0x00, 0xFF, 0xFF, 0xFF, |
| 1873 |
0x00, 0x02, |
| 1874 |
|
| 1875 |
}; |
| 1876 |
|
| 1877 |
|
| 1878 |
ASSERT_H2ERR_ERROR( |
| 1879 |
AWS_HTTP2_ERR_FRAME_SIZE_ERROR, s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 1880 |
|
| 1881 |
return AWS_OP_SUCCESS; |
| 1882 |
} |
| 1883 |
|
| 1884 |
|
| 1885 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_err_settings_invalid_values_enable_push) { |
| 1886 |
(void)allocator; |
| 1887 |
struct fixture *fixture = ctx; |
| 1888 |
|
| 1889 |
|
| 1890 |
uint8_t input[] = { |
| 1891 |
0x00, 0x00, 12, |
| 1892 |
AWS_H2_FRAME_T_SETTINGS, |
| 1893 |
0x00, |
| 1894 |
0x00, 0x00, 0x00, 0x00, |
| 1895 |
|
| 1896 |
0x00, 0x05, |
| 1897 |
0x00, 0xFF, 0xFF, 0xFF, |
| 1898 |
0x00, 0x02, |
| 1899 |
0x00, 0xFF, 0xFF, 0xFF, |
| 1900 |
}; |
| 1901 |
|
| 1902 |
|
| 1903 |
ASSERT_H2ERR_ERROR( |
| 1904 |
AWS_HTTP2_ERR_PROTOCOL_ERROR, s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 1905 |
|
| 1906 |
return AWS_OP_SUCCESS; |
| 1907 |
} |
| 1908 |
|
| 1909 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_err_settings_invalid_values_initial_window_size) { |
| 1910 |
(void)allocator; |
| 1911 |
struct fixture *fixture = ctx; |
| 1912 |
|
| 1913 |
|
| 1914 |
uint8_t input[] = { |
| 1915 |
0x00, 0x00, 12, |
| 1916 |
AWS_H2_FRAME_T_SETTINGS, |
| 1917 |
0x00, |
| 1918 |
0x00, 0x00, 0x00, 0x00, |
| 1919 |
|
| 1920 |
0x00, 0x05, |
| 1921 |
0x00, 0xFF, 0xFF, 0xFF, |
| 1922 |
0x00, 0x04, |
| 1923 |
0x80, 0xFF, 0xFF, 0xFF, |
| 1924 |
}; |
| 1925 |
|
| 1926 |
|
| 1927 |
ASSERT_H2ERR_ERROR( |
| 1928 |
AWS_HTTP2_ERR_FLOW_CONTROL_ERROR, s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 1929 |
|
| 1930 |
return AWS_OP_SUCCESS; |
| 1931 |
} |
| 1932 |
|
| 1933 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_err_settings_invalid_values_max_frame_size) { |
| 1934 |
(void)allocator; |
| 1935 |
struct fixture *fixture = ctx; |
| 1936 |
|
| 1937 |
|
| 1938 |
uint8_t input[] = { |
| 1939 |
0x00, 0x00, 12, |
| 1940 |
AWS_H2_FRAME_T_SETTINGS, |
| 1941 |
0x00, |
| 1942 |
0x00, 0x00, 0x00, 0x00, |
| 1943 |
|
| 1944 |
0x00, 0x05, |
| 1945 |
0x00, 0xFF, 0xFF, 0xFF, |
| 1946 |
0x00, 0x05, |
| 1947 |
0x00, 0x00, 0x00, 0x00, |
| 1948 |
}; |
| 1949 |
|
| 1950 |
|
| 1951 |
ASSERT_H2ERR_ERROR( |
| 1952 |
AWS_HTTP2_ERR_PROTOCOL_ERROR, s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 1953 |
|
| 1954 |
return AWS_OP_SUCCESS; |
| 1955 |
} |
| 1956 |
|
| 1957 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_push_promise) { |
| 1958 |
(void)allocator; |
| 1959 |
struct fixture *fixture = ctx; |
| 1960 |
|
| 1961 |
|
| 1962 |
uint8_t input[] = { |
| 1963 |
0x00, 0x00, 0x07, |
| 1964 |
AWS_H2_FRAME_T_PUSH_PROMISE, |
| 1965 |
AWS_H2_FRAME_F_END_HEADERS, |
| 1966 |
0x00, 0x00, 0x00, 0x01, |
| 1967 |
|
| 1968 |
0x80, 0x00, 0x00, 0x02, |
| 1969 |
0x82, |
| 1970 |
0x87, |
| 1971 |
0x85, |
| 1972 |
}; |
| 1973 |
|
| 1974 |
|
| 1975 |
|
| 1976 |
ASSERT_H2ERR_SUCCESS(s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 1977 |
|
| 1978 |
|
| 1979 |
struct h2_decoded_frame *frame = h2_decode_tester_latest_frame(&fixture->decode); |
| 1980 |
ASSERT_SUCCESS(h2_decoded_frame_check_finished(frame, AWS_H2_FRAME_T_PUSH_PROMISE, 0x1 )); |
| 1981 |
ASSERT_UINT_EQUALS(2, frame->promised_stream_id); |
| 1982 |
ASSERT_FALSE(frame->headers_malformed); |
| 1983 |
ASSERT_UINT_EQUALS(3, aws_http_headers_count(frame->headers)); |
| 1984 |
ASSERT_SUCCESS(s_check_header(frame, 0, ":method", "GET", AWS_HTTP_HEADER_COMPRESSION_USE_CACHE)); |
| 1985 |
ASSERT_SUCCESS(s_check_header(frame, 1, ":scheme", "https", AWS_HTTP_HEADER_COMPRESSION_USE_CACHE)); |
| 1986 |
ASSERT_SUCCESS(s_check_header(frame, 2, ":path", "/index.html", AWS_HTTP_HEADER_COMPRESSION_USE_CACHE)); |
| 1987 |
ASSERT_FALSE(frame->end_stream); |
| 1988 |
return AWS_OP_SUCCESS; |
| 1989 |
} |
| 1990 |
|
| 1991 |
|
| 1992 |
|
| 1993 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_push_promise_ignores_unknown_flags) { |
| 1994 |
(void)allocator; |
| 1995 |
struct fixture *fixture = ctx; |
| 1996 |
|
| 1997 |
|
| 1998 |
uint8_t input[] = { |
| 1999 |
0x00, 0x00, 10, |
| 2000 |
AWS_H2_FRAME_T_PUSH_PROMISE, |
| 2001 |
0xFF, |
| 2002 |
0x00, 0x00, 0x00, 0x01, |
| 2003 |
|
| 2004 |
0x02, |
| 2005 |
0x00, 0x00, 0x00, 0x02, |
| 2006 |
0x82, |
| 2007 |
0x87, |
| 2008 |
0x85, |
| 2009 |
0x00, 0x00, |
| 2010 |
}; |
| 2011 |
|
| 2012 |
|
| 2013 |
|
| 2014 |
ASSERT_H2ERR_SUCCESS(s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 2015 |
|
| 2016 |
|
| 2017 |
struct h2_decoded_frame *frame = h2_decode_tester_latest_frame(&fixture->decode); |
| 2018 |
ASSERT_SUCCESS(h2_decoded_frame_check_finished(frame, AWS_H2_FRAME_T_PUSH_PROMISE, 0x1 )); |
| 2019 |
ASSERT_UINT_EQUALS(2, frame->promised_stream_id); |
| 2020 |
ASSERT_FALSE(frame->headers_malformed); |
| 2021 |
ASSERT_UINT_EQUALS(3, aws_http_headers_count(frame->headers)); |
| 2022 |
ASSERT_SUCCESS(s_check_header(frame, 0, ":method", "GET", AWS_HTTP_HEADER_COMPRESSION_USE_CACHE)); |
| 2023 |
ASSERT_SUCCESS(s_check_header(frame, 1, ":scheme", "https", AWS_HTTP_HEADER_COMPRESSION_USE_CACHE)); |
| 2024 |
ASSERT_SUCCESS(s_check_header(frame, 2, ":path", "/index.html", AWS_HTTP_HEADER_COMPRESSION_USE_CACHE)); |
| 2025 |
ASSERT_FALSE(frame->end_stream); |
| 2026 |
return AWS_OP_SUCCESS; |
| 2027 |
} |
| 2028 |
|
| 2029 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_push_promise_continuation) { |
| 2030 |
(void)allocator; |
| 2031 |
struct fixture *fixture = ctx; |
| 2032 |
|
| 2033 |
|
| 2034 |
uint8_t input[] = { |
| 2035 |
|
| 2036 |
0x00, 0x00, 0x08, |
| 2037 |
AWS_H2_FRAME_T_PUSH_PROMISE, |
| 2038 |
AWS_H2_FRAME_F_PADDED, |
| 2039 |
0x00, 0x00, 0x00, 0x01, |
| 2040 |
|
| 2041 |
0x02, |
| 2042 |
0x00, 0x00, 0x00, 0x02, |
| 2043 |
0x82, |
| 2044 |
0x00, 0x00, |
| 2045 |
|
| 2046 |
|
| 2047 |
0x00, 0x00, 0x00, |
| 2048 |
AWS_H2_FRAME_T_CONTINUATION, |
| 2049 |
0x00, |
| 2050 |
0x00, 0x00, 0x00, 0x01, |
| 2051 |
|
| 2052 |
|
| 2053 |
|
| 2054 |
|
| 2055 |
0x00, 0x00, 0x02, |
| 2056 |
AWS_H2_FRAME_T_CONTINUATION, |
| 2057 |
AWS_H2_FRAME_F_END_HEADERS, |
| 2058 |
0x00, 0x00, 0x00, 0x01, |
| 2059 |
|
| 2060 |
0x87, |
| 2061 |
0x85, |
| 2062 |
}; |
| 2063 |
|
| 2064 |
|
| 2065 |
|
| 2066 |
ASSERT_H2ERR_SUCCESS(s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 2067 |
|
| 2068 |
|
| 2069 |
struct h2_decoded_frame *frame = h2_decode_tester_latest_frame(&fixture->decode); |
| 2070 |
ASSERT_SUCCESS(h2_decoded_frame_check_finished(frame, AWS_H2_FRAME_T_PUSH_PROMISE, 0x1 )); |
| 2071 |
ASSERT_UINT_EQUALS(2, frame->promised_stream_id); |
| 2072 |
ASSERT_FALSE(frame->headers_malformed); |
| 2073 |
ASSERT_UINT_EQUALS(3, aws_http_headers_count(frame->headers)); |
| 2074 |
ASSERT_SUCCESS(s_check_header(frame, 0, ":method", "GET", AWS_HTTP_HEADER_COMPRESSION_USE_CACHE)); |
| 2075 |
ASSERT_SUCCESS(s_check_header(frame, 1, ":scheme", "https", AWS_HTTP_HEADER_COMPRESSION_USE_CACHE)); |
| 2076 |
ASSERT_SUCCESS(s_check_header(frame, 2, ":path", "/index.html", AWS_HTTP_HEADER_COMPRESSION_USE_CACHE)); |
| 2077 |
ASSERT_FALSE(frame->end_stream); |
| 2078 |
return AWS_OP_SUCCESS; |
| 2079 |
} |
| 2080 |
|
| 2081 |
|
| 2082 |
|
| 2083 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_err_push_promise_continuation_expected) { |
| 2084 |
(void)allocator; |
| 2085 |
struct fixture *fixture = ctx; |
| 2086 |
|
| 2087 |
|
| 2088 |
uint8_t input[] = { |
| 2089 |
|
| 2090 |
0x00, 0x00, 0x07, |
| 2091 |
AWS_H2_FRAME_T_PUSH_PROMISE, |
| 2092 |
0x00, |
| 2093 |
0x00, 0x00, 0x00, 0x01, |
| 2094 |
|
| 2095 |
0x00, 0x00, 0x00, 0x02, |
| 2096 |
0x82, |
| 2097 |
0x87, |
| 2098 |
0x85, |
| 2099 |
|
| 2100 |
|
| 2101 |
0x00, 0x00, 0x05, |
| 2102 |
AWS_H2_FRAME_T_DATA, |
| 2103 |
AWS_H2_FRAME_F_END_STREAM, |
| 2104 |
0x00, 0x00, 0x00, 0x02, |
| 2105 |
|
| 2106 |
'h', 'e', 'l', 'l', 'o', |
| 2107 |
}; |
| 2108 |
|
| 2109 |
|
| 2110 |
|
| 2111 |
ASSERT_H2ERR_ERROR( |
| 2112 |
AWS_HTTP2_ERR_PROTOCOL_ERROR, s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 2113 |
|
| 2114 |
return AWS_OP_SUCCESS; |
| 2115 |
} |
| 2116 |
|
| 2117 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_err_push_promise_requires_stream_id) { |
| 2118 |
(void)allocator; |
| 2119 |
struct fixture *fixture = ctx; |
| 2120 |
|
| 2121 |
|
| 2122 |
uint8_t input[] = { |
| 2123 |
0x00, 0x00, 0x07, |
| 2124 |
AWS_H2_FRAME_T_PUSH_PROMISE, |
| 2125 |
AWS_H2_FRAME_F_END_HEADERS, |
| 2126 |
0x00, 0x00, 0x00, 0x00, |
| 2127 |
|
| 2128 |
0x00, 0x00, 0x00, 0x02, |
| 2129 |
0x82, |
| 2130 |
0x87, |
| 2131 |
0x85, |
| 2132 |
}; |
| 2133 |
|
| 2134 |
|
| 2135 |
|
| 2136 |
ASSERT_H2ERR_ERROR( |
| 2137 |
AWS_HTTP2_ERR_PROTOCOL_ERROR, s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 2138 |
|
| 2139 |
return AWS_OP_SUCCESS; |
| 2140 |
} |
| 2141 |
|
| 2142 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_malformed_push_promise_must_be_request_1) { |
| 2143 |
(void)allocator; |
| 2144 |
struct fixture *fixture = ctx; |
| 2145 |
|
| 2146 |
|
| 2147 |
uint8_t input[] = { |
| 2148 |
0x00, 0x00, 0x09, |
| 2149 |
AWS_H2_FRAME_T_PUSH_PROMISE, |
| 2150 |
AWS_H2_FRAME_F_END_HEADERS, |
| 2151 |
0x00, 0x00, 0x00, 0x01, |
| 2152 |
|
| 2153 |
0x00, 0x00, 0x00, 0x02, |
| 2154 |
0x48, 0x03, '3', '0', '2', |
| 2155 |
}; |
| 2156 |
|
| 2157 |
|
| 2158 |
|
| 2159 |
ASSERT_H2ERR_SUCCESS(s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 2160 |
|
| 2161 |
|
| 2162 |
struct h2_decoded_frame *frame = h2_decode_tester_latest_frame(&fixture->decode); |
| 2163 |
ASSERT_SUCCESS(h2_decoded_frame_check_finished(frame, AWS_H2_FRAME_T_PUSH_PROMISE, 1 )); |
| 2164 |
ASSERT_UINT_EQUALS(2, frame->promised_stream_id); |
| 2165 |
ASSERT_TRUE(frame->headers_malformed); |
| 2166 |
return AWS_OP_SUCCESS; |
| 2167 |
} |
| 2168 |
|
| 2169 |
|
| 2170 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_malformed_push_promise_must_be_request_2) { |
| 2171 |
(void)allocator; |
| 2172 |
struct fixture *fixture = ctx; |
| 2173 |
|
| 2174 |
|
| 2175 |
uint8_t input[] = { |
| 2176 |
0x00, 0x00, 0x04, |
| 2177 |
AWS_H2_FRAME_T_PUSH_PROMISE, |
| 2178 |
AWS_H2_FRAME_F_END_HEADERS, |
| 2179 |
0x00, 0x00, 0x00, 0x01, |
| 2180 |
|
| 2181 |
0x00, 0x00, 0x00, 0x02, |
| 2182 |
|
| 2183 |
}; |
| 2184 |
|
| 2185 |
|
| 2186 |
|
| 2187 |
ASSERT_H2ERR_SUCCESS(s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 2188 |
|
| 2189 |
|
| 2190 |
struct h2_decoded_frame *frame = h2_decode_tester_latest_frame(&fixture->decode); |
| 2191 |
ASSERT_SUCCESS(h2_decoded_frame_check_finished(frame, AWS_H2_FRAME_T_PUSH_PROMISE, 1 )); |
| 2192 |
ASSERT_UINT_EQUALS(2, frame->promised_stream_id); |
| 2193 |
ASSERT_TRUE(frame->headers_malformed); |
| 2194 |
return AWS_OP_SUCCESS; |
| 2195 |
} |
| 2196 |
|
| 2197 |
|
| 2198 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_err_push_promise_requires_promised_stream_id) { |
| 2199 |
(void)allocator; |
| 2200 |
struct fixture *fixture = ctx; |
| 2201 |
|
| 2202 |
|
| 2203 |
uint8_t input[] = { |
| 2204 |
0x00, 0x00, 0x07, |
| 2205 |
AWS_H2_FRAME_T_PUSH_PROMISE, |
| 2206 |
AWS_H2_FRAME_F_END_HEADERS, |
| 2207 |
0x00, 0x00, 0x00, 0x01, |
| 2208 |
|
| 2209 |
0x00, 0x00, 0x00, 0x00, |
| 2210 |
0x82, |
| 2211 |
0x87, |
| 2212 |
0x85, |
| 2213 |
}; |
| 2214 |
|
| 2215 |
|
| 2216 |
|
| 2217 |
ASSERT_H2ERR_ERROR( |
| 2218 |
AWS_HTTP2_ERR_PROTOCOL_ERROR, s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 2219 |
|
| 2220 |
return AWS_OP_SUCCESS; |
| 2221 |
} |
| 2222 |
|
| 2223 |
|
| 2224 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_err_push_promise_with_enable_push_0) { |
| 2225 |
(void)allocator; |
| 2226 |
struct fixture *fixture = ctx; |
| 2227 |
|
| 2228 |
|
| 2229 |
uint8_t input[] = { |
| 2230 |
0x00, 0x00, 0x07, |
| 2231 |
AWS_H2_FRAME_T_PUSH_PROMISE, |
| 2232 |
AWS_H2_FRAME_F_END_HEADERS, |
| 2233 |
0x00, 0x00, 0x00, 0x01, |
| 2234 |
|
| 2235 |
0x00, 0x00, 0x00, 0x00, |
| 2236 |
0x82, |
| 2237 |
0x87, |
| 2238 |
0x85, |
| 2239 |
}; |
| 2240 |
|
| 2241 |
aws_h2_decoder_set_setting_enable_push(fixture->decode.decoder, (uint32_t)0); |
| 2242 |
|
| 2243 |
ASSERT_H2ERR_ERROR( |
| 2244 |
AWS_HTTP2_ERR_PROTOCOL_ERROR, s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 2245 |
|
| 2246 |
return AWS_OP_SUCCESS; |
| 2247 |
} |
| 2248 |
|
| 2249 |
|
| 2250 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_ping) { |
| 2251 |
(void)allocator; |
| 2252 |
struct fixture *fixture = ctx; |
| 2253 |
|
| 2254 |
|
| 2255 |
uint8_t input[] = { |
| 2256 |
0x00, 0x00, 0x08, |
| 2257 |
AWS_H2_FRAME_T_PING, |
| 2258 |
0x0, |
| 2259 |
0x00, 0x00, 0x00, 0x00, |
| 2260 |
|
| 2261 |
'p', 'i', 'n', 'g', 'p', 'o', 'n', 'g' |
| 2262 |
}; |
| 2263 |
|
| 2264 |
|
| 2265 |
ASSERT_H2ERR_SUCCESS(s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 2266 |
|
| 2267 |
|
| 2268 |
struct h2_decoded_frame *frame = h2_decode_tester_latest_frame(&fixture->decode); |
| 2269 |
ASSERT_SUCCESS(h2_decoded_frame_check_finished(frame, AWS_H2_FRAME_T_PING, 0x0 )); |
| 2270 |
ASSERT_BIN_ARRAYS_EQUALS("pingpong", AWS_HTTP2_PING_DATA_SIZE, frame->ping_opaque_data, AWS_HTTP2_PING_DATA_SIZE); |
| 2271 |
ASSERT_FALSE(frame->ack); |
| 2272 |
return AWS_OP_SUCCESS; |
| 2273 |
} |
| 2274 |
|
| 2275 |
|
| 2276 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_ping_ack) { |
| 2277 |
(void)allocator; |
| 2278 |
struct fixture *fixture = ctx; |
| 2279 |
|
| 2280 |
|
| 2281 |
uint8_t input[] = { |
| 2282 |
0x00, 0x00, 0x08, |
| 2283 |
AWS_H2_FRAME_T_PING, |
| 2284 |
0xFF, |
| 2285 |
0x00, 0x00, 0x00, 0x00, |
| 2286 |
|
| 2287 |
'p', 'i', 'n', 'g', 'p', 'o', 'n', 'g' |
| 2288 |
}; |
| 2289 |
|
| 2290 |
|
| 2291 |
ASSERT_H2ERR_SUCCESS(s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 2292 |
|
| 2293 |
|
| 2294 |
struct h2_decoded_frame *frame = h2_decode_tester_latest_frame(&fixture->decode); |
| 2295 |
ASSERT_SUCCESS(h2_decoded_frame_check_finished(frame, AWS_H2_FRAME_T_PING, 0x0 )); |
| 2296 |
ASSERT_BIN_ARRAYS_EQUALS("pingpong", AWS_HTTP2_PING_DATA_SIZE, frame->ping_opaque_data, AWS_HTTP2_PING_DATA_SIZE); |
| 2297 |
ASSERT_TRUE(frame->ack); |
| 2298 |
return AWS_OP_SUCCESS; |
| 2299 |
} |
| 2300 |
|
| 2301 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_err_ping_forbids_stream_id) { |
| 2302 |
(void)allocator; |
| 2303 |
struct fixture *fixture = ctx; |
| 2304 |
|
| 2305 |
|
| 2306 |
uint8_t input[] = { |
| 2307 |
0x00, 0x00, 0x08, |
| 2308 |
AWS_H2_FRAME_T_PING, |
| 2309 |
0x0, |
| 2310 |
0x00, 0x00, 0x00, 0x01, |
| 2311 |
|
| 2312 |
'p', 'i', 'n', 'g', 'p', 'o', 'n', 'g' |
| 2313 |
}; |
| 2314 |
|
| 2315 |
|
| 2316 |
ASSERT_H2ERR_ERROR( |
| 2317 |
AWS_HTTP2_ERR_PROTOCOL_ERROR, s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 2318 |
|
| 2319 |
return AWS_OP_SUCCESS; |
| 2320 |
} |
| 2321 |
|
| 2322 |
|
| 2323 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_err_ping_payload_too_small) { |
| 2324 |
(void)allocator; |
| 2325 |
struct fixture *fixture = ctx; |
| 2326 |
|
| 2327 |
|
| 2328 |
uint8_t input[] = { |
| 2329 |
0x00, 0x00, 0x00, |
| 2330 |
AWS_H2_FRAME_T_PING, |
| 2331 |
0x0, |
| 2332 |
0x00, 0x00, 0x00, 0x00, |
| 2333 |
|
| 2334 |
|
| 2335 |
}; |
| 2336 |
|
| 2337 |
|
| 2338 |
ASSERT_H2ERR_ERROR( |
| 2339 |
AWS_HTTP2_ERR_FRAME_SIZE_ERROR, s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 2340 |
|
| 2341 |
return AWS_OP_SUCCESS; |
| 2342 |
} |
| 2343 |
|
| 2344 |
|
| 2345 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_err_ping_payload_too_large) { |
| 2346 |
(void)allocator; |
| 2347 |
struct fixture *fixture = ctx; |
| 2348 |
|
| 2349 |
|
| 2350 |
uint8_t input[] = { |
| 2351 |
0x00, 0x00, 0x09, |
| 2352 |
AWS_H2_FRAME_T_PING, |
| 2353 |
0x0, |
| 2354 |
0x00, 0x00, 0x00, 0x00, |
| 2355 |
|
| 2356 |
'p', 'i', 'n', 'g', 'p', 'o', 'n', 'g', 0x00 |
| 2357 |
}; |
| 2358 |
|
| 2359 |
|
| 2360 |
ASSERT_H2ERR_ERROR( |
| 2361 |
AWS_HTTP2_ERR_FRAME_SIZE_ERROR, s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 2362 |
|
| 2363 |
return AWS_OP_SUCCESS; |
| 2364 |
} |
| 2365 |
|
| 2366 |
|
| 2367 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_goaway) { |
| 2368 |
(void)allocator; |
| 2369 |
struct fixture *fixture = ctx; |
| 2370 |
|
| 2371 |
|
| 2372 |
uint8_t input[] = { |
| 2373 |
0x00, 0x00, 11, |
| 2374 |
AWS_H2_FRAME_T_GOAWAY, |
| 2375 |
0xFF, |
| 2376 |
0x00, 0x00, 0x00, 0x00, |
| 2377 |
|
| 2378 |
0xFF, 0x00, 0x00, 0x01, |
| 2379 |
0xFE, 0xED, 0xBE, 0xEF, |
| 2380 |
'b', 'y', 'e' |
| 2381 |
}; |
| 2382 |
|
| 2383 |
|
| 2384 |
ASSERT_H2ERR_SUCCESS(s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 2385 |
|
| 2386 |
|
| 2387 |
struct h2_decoded_frame *frame = h2_decode_tester_latest_frame(&fixture->decode); |
| 2388 |
ASSERT_SUCCESS(h2_decoded_frame_check_finished(frame, AWS_H2_FRAME_T_GOAWAY, 0x0 )); |
| 2389 |
ASSERT_UINT_EQUALS(0x7F000001, frame->goaway_last_stream_id); |
| 2390 |
ASSERT_UINT_EQUALS(0xFEEDBEEF, frame->error_code); |
| 2391 |
ASSERT_BIN_ARRAYS_EQUALS("bye", 3, frame->data.buffer, frame->data.len); |
| 2392 |
|
| 2393 |
return AWS_OP_SUCCESS; |
| 2394 |
} |
| 2395 |
|
| 2396 |
|
| 2397 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_goaway_empty) { |
| 2398 |
(void)allocator; |
| 2399 |
struct fixture *fixture = ctx; |
| 2400 |
|
| 2401 |
|
| 2402 |
uint8_t input[] = { |
| 2403 |
0x00, 0x00, 0x08, |
| 2404 |
AWS_H2_FRAME_T_GOAWAY, |
| 2405 |
0x00, |
| 2406 |
0x00, 0x00, 0x00, 0x00, |
| 2407 |
|
| 2408 |
0xFF, 0x00, 0x00, 0x01, |
| 2409 |
0xFE, 0xED, 0xBE, 0xEF, |
| 2410 |
|
| 2411 |
}; |
| 2412 |
|
| 2413 |
|
| 2414 |
ASSERT_H2ERR_SUCCESS(s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 2415 |
|
| 2416 |
|
| 2417 |
struct h2_decoded_frame *frame = h2_decode_tester_latest_frame(&fixture->decode); |
| 2418 |
ASSERT_SUCCESS(h2_decoded_frame_check_finished(frame, AWS_H2_FRAME_T_GOAWAY, 0x0 )); |
| 2419 |
ASSERT_UINT_EQUALS(0x7F000001, frame->goaway_last_stream_id); |
| 2420 |
ASSERT_UINT_EQUALS(0xFEEDBEEF, frame->error_code); |
| 2421 |
ASSERT_BIN_ARRAYS_EQUALS("", 0, frame->data.buffer, frame->data.len); |
| 2422 |
|
| 2423 |
return AWS_OP_SUCCESS; |
| 2424 |
} |
| 2425 |
|
| 2426 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_err_goaway_forbids_stream_id) { |
| 2427 |
(void)allocator; |
| 2428 |
struct fixture *fixture = ctx; |
| 2429 |
|
| 2430 |
|
| 2431 |
uint8_t input[] = { |
| 2432 |
0x00, 0x00, 11, |
| 2433 |
AWS_H2_FRAME_T_GOAWAY, |
| 2434 |
0xFF, |
| 2435 |
0x00, 0x00, 0x00, 0x01, |
| 2436 |
|
| 2437 |
0xFF, 0x00, 0x00, 0x01, |
| 2438 |
0xFE, 0xED, 0xBE, 0xEF, |
| 2439 |
'b', 'y', 'e' |
| 2440 |
}; |
| 2441 |
|
| 2442 |
|
| 2443 |
ASSERT_H2ERR_ERROR( |
| 2444 |
AWS_HTTP2_ERR_PROTOCOL_ERROR, s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 2445 |
|
| 2446 |
return AWS_OP_SUCCESS; |
| 2447 |
} |
| 2448 |
|
| 2449 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_err_goaway_payload_too_small) { |
| 2450 |
(void)allocator; |
| 2451 |
struct fixture *fixture = ctx; |
| 2452 |
|
| 2453 |
|
| 2454 |
uint8_t input[] = { |
| 2455 |
0x00, 0x00, 0x00, |
| 2456 |
AWS_H2_FRAME_T_GOAWAY, |
| 2457 |
0x00, |
| 2458 |
0x00, 0x00, 0x00, 0x00, |
| 2459 |
|
| 2460 |
|
| 2461 |
|
| 2462 |
|
| 2463 |
}; |
| 2464 |
|
| 2465 |
|
| 2466 |
ASSERT_H2ERR_ERROR( |
| 2467 |
AWS_HTTP2_ERR_FRAME_SIZE_ERROR, s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 2468 |
|
| 2469 |
return AWS_OP_SUCCESS; |
| 2470 |
} |
| 2471 |
|
| 2472 |
|
| 2473 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_window_update_connection) { |
| 2474 |
(void)allocator; |
| 2475 |
struct fixture *fixture = ctx; |
| 2476 |
|
| 2477 |
|
| 2478 |
uint8_t input[] = { |
| 2479 |
0x00, 0x00, 0x04, |
| 2480 |
AWS_H2_FRAME_T_WINDOW_UPDATE, |
| 2481 |
0xFF, |
| 2482 |
0x00, 0x00, 0x00, 0x00, |
| 2483 |
|
| 2484 |
0xFF, 0x00, 0x00, 0x01, |
| 2485 |
}; |
| 2486 |
|
| 2487 |
|
| 2488 |
ASSERT_H2ERR_SUCCESS(s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 2489 |
|
| 2490 |
|
| 2491 |
struct h2_decoded_frame *frame = h2_decode_tester_latest_frame(&fixture->decode); |
| 2492 |
ASSERT_SUCCESS(h2_decoded_frame_check_finished(frame, AWS_H2_FRAME_T_WINDOW_UPDATE, 0x0 )); |
| 2493 |
ASSERT_UINT_EQUALS(0x7F000001, frame->window_size_increment); |
| 2494 |
|
| 2495 |
return AWS_OP_SUCCESS; |
| 2496 |
} |
| 2497 |
|
| 2498 |
|
| 2499 |
|
| 2500 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_window_update_stream) { |
| 2501 |
(void)allocator; |
| 2502 |
struct fixture *fixture = ctx; |
| 2503 |
|
| 2504 |
|
| 2505 |
uint8_t input[] = { |
| 2506 |
0x00, 0x00, 0x04, |
| 2507 |
AWS_H2_FRAME_T_WINDOW_UPDATE, |
| 2508 |
0x00, |
| 2509 |
0x00, 0x00, 0x00, 0x01, |
| 2510 |
|
| 2511 |
0xFF, 0x00, 0x00, 0x01, |
| 2512 |
}; |
| 2513 |
|
| 2514 |
|
| 2515 |
ASSERT_H2ERR_SUCCESS(s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 2516 |
|
| 2517 |
|
| 2518 |
struct h2_decoded_frame *frame = h2_decode_tester_latest_frame(&fixture->decode); |
| 2519 |
ASSERT_SUCCESS(h2_decoded_frame_check_finished(frame, AWS_H2_FRAME_T_WINDOW_UPDATE, 0x1 )); |
| 2520 |
ASSERT_UINT_EQUALS(0x7F000001, frame->window_size_increment); |
| 2521 |
|
| 2522 |
return AWS_OP_SUCCESS; |
| 2523 |
} |
| 2524 |
|
| 2525 |
|
| 2526 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_err_window_update_payload_too_small) { |
| 2527 |
(void)allocator; |
| 2528 |
struct fixture *fixture = ctx; |
| 2529 |
|
| 2530 |
|
| 2531 |
uint8_t input[] = { |
| 2532 |
0x00, 0x00, 0x00, |
| 2533 |
AWS_H2_FRAME_T_WINDOW_UPDATE, |
| 2534 |
0x00, |
| 2535 |
0x00, 0x00, 0x00, 0x01, |
| 2536 |
|
| 2537 |
|
| 2538 |
}; |
| 2539 |
|
| 2540 |
|
| 2541 |
ASSERT_H2ERR_ERROR( |
| 2542 |
AWS_HTTP2_ERR_FRAME_SIZE_ERROR, s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 2543 |
|
| 2544 |
return AWS_OP_SUCCESS; |
| 2545 |
} |
| 2546 |
|
| 2547 |
|
| 2548 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_err_window_update_payload_too_large) { |
| 2549 |
(void)allocator; |
| 2550 |
struct fixture *fixture = ctx; |
| 2551 |
|
| 2552 |
|
| 2553 |
uint8_t input[] = { |
| 2554 |
0x00, 0x00, 0x08, |
| 2555 |
AWS_H2_FRAME_T_WINDOW_UPDATE, |
| 2556 |
0x00, |
| 2557 |
0x00, 0x00, 0x00, 0x01, |
| 2558 |
|
| 2559 |
0x00, 0x00, 0x00, 0x01, |
| 2560 |
0x00, 0x00, 0x00, 0x02, |
| 2561 |
}; |
| 2562 |
|
| 2563 |
|
| 2564 |
ASSERT_H2ERR_ERROR( |
| 2565 |
AWS_HTTP2_ERR_FRAME_SIZE_ERROR, s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 2566 |
|
| 2567 |
return AWS_OP_SUCCESS; |
| 2568 |
} |
| 2569 |
|
| 2570 |
|
| 2571 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_unknown_frame_type_ignored) { |
| 2572 |
(void)allocator; |
| 2573 |
struct fixture *fixture = ctx; |
| 2574 |
|
| 2575 |
|
| 2576 |
uint8_t input[] = { |
| 2577 |
|
| 2578 |
0x00, 0x00, 0x04, |
| 2579 |
0xFF, |
| 2580 |
0x00, |
| 2581 |
0x00, 0x00, 0x00, 0x00, |
| 2582 |
0xFF, 0xFF, 0xFF, 0xFF, |
| 2583 |
|
| 2584 |
|
| 2585 |
0x00, 0x00, 0x04, |
| 2586 |
0xFF, |
| 2587 |
0xFF, |
| 2588 |
0xFF, 0xFF, 0xFF, 0xFF, |
| 2589 |
0xFF, 0xFF, 0xFF, 0xFF, |
| 2590 |
|
| 2591 |
|
| 2592 |
0x00, 0x00, 0x00, |
| 2593 |
0xFF, |
| 2594 |
0xFF, |
| 2595 |
0xFF, 0xFF, 0xFF, 0xFF, |
| 2596 |
|
| 2597 |
}; |
| 2598 |
|
| 2599 |
|
| 2600 |
ASSERT_H2ERR_SUCCESS(s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 2601 |
|
| 2602 |
|
| 2603 |
ASSERT_UINT_EQUALS(0, h2_decode_tester_frame_count(&fixture->decode)); |
| 2604 |
return AWS_OP_SUCCESS; |
| 2605 |
} |
| 2606 |
|
| 2607 |
static int s_get_finished_frame_i( |
| 2608 |
struct fixture *fixture, |
| 2609 |
size_t i, |
| 2610 |
enum aws_h2_frame_type type, |
| 2611 |
uint32_t stream_id, |
| 2612 |
struct h2_decoded_frame **out_frame) { |
| 2613 |
|
| 2614 |
ASSERT_TRUE(i < h2_decode_tester_frame_count(&fixture->decode)); |
| 2615 |
*out_frame = h2_decode_tester_get_frame(&fixture->decode, i); |
| 2616 |
ASSERT_SUCCESS(h2_decoded_frame_check_finished(*out_frame, type, stream_id)); |
| 2617 |
return AWS_OP_SUCCESS; |
| 2618 |
} |
| 2619 |
|
| 2620 |
|
| 2621 |
|
| 2622 |
H2_DECODER_ON_CLIENT_TEST(h2_decoder_many_frames_in_a_row) { |
| 2623 |
(void)allocator; |
| 2624 |
struct fixture *fixture = ctx; |
| 2625 |
|
| 2626 |
|
| 2627 |
uint8_t input[] = { |
| 2628 |
|
| 2629 |
0x00, 0x00, 0x05, |
| 2630 |
AWS_H2_FRAME_T_HEADERS, |
| 2631 |
0x00, |
| 2632 |
0x00, 0x00, 0x00, 0x01, |
| 2633 |
|
| 2634 |
0x48, 0x03, '3', '0', '2', |
| 2635 |
|
| 2636 |
|
| 2637 |
0x00, 0x00, 0x09, |
| 2638 |
AWS_H2_FRAME_T_CONTINUATION, |
| 2639 |
AWS_H2_FRAME_F_END_HEADERS, |
| 2640 |
0x00, 0x00, 0x00, 0x01, |
| 2641 |
|
| 2642 |
0x58, 0x07, 'p', 'r', 'i', 'v', 'a', 't', 'e', |
| 2643 |
|
| 2644 |
|
| 2645 |
0x00, 0x00, 0x00, |
| 2646 |
AWS_H2_FRAME_T_SETTINGS, |
| 2647 |
AWS_H2_FRAME_F_ACK, |
| 2648 |
0x00, 0x00, 0x00, 0x00, |
| 2649 |
|
| 2650 |
|
| 2651 |
0x00, 0x00, 0x05, |
| 2652 |
AWS_H2_FRAME_T_PUSH_PROMISE, |
| 2653 |
0x00, |
| 2654 |
0x00, 0x00, 0x00, 0x01, |
| 2655 |
|
| 2656 |
0x80, 0x00, 0x00, 0x02, |
| 2657 |
0x82, |
| 2658 |
|
| 2659 |
|
| 2660 |
0x00, 0x00, 0x02, |
| 2661 |
AWS_H2_FRAME_T_CONTINUATION, |
| 2662 |
AWS_H2_FRAME_F_END_HEADERS, |
| 2663 |
0x00, 0x00, 0x00, 0x01, |
| 2664 |
|
| 2665 |
0x87, |
| 2666 |
0x85, |
| 2667 |
|
| 2668 |
|
| 2669 |
0x00, 0x00, 0x05, |
| 2670 |
AWS_H2_FRAME_T_PRIORITY, |
| 2671 |
0x00, |
| 2672 |
0x00, 0x00, 0x00, 0x01, |
| 2673 |
|
| 2674 |
0x00, 0x00, 0x00, 0x02, |
| 2675 |
0x09, |
| 2676 |
|
| 2677 |
|
| 2678 |
0x00, 0x00, 0x04, |
| 2679 |
AWS_H2_FRAME_T_WINDOW_UPDATE, |
| 2680 |
0x00, |
| 2681 |
0x00, 0x00, 0x00, 0x00, |
| 2682 |
|
| 2683 |
0x00, 0x00, 0x00, 0x01, |
| 2684 |
|
| 2685 |
|
| 2686 |
0x00, 0x00, 0x01, |
| 2687 |
AWS_H2_FRAME_T_DATA, |
| 2688 |
AWS_H2_FRAME_F_END_STREAM, |
| 2689 |
0x00, 0x00, 0x00, 0x01, |
| 2690 |
|
| 2691 |
'h', |
| 2692 |
|
| 2693 |
|
| 2694 |
0x00, 0x00, 0x01, |
| 2695 |
0xFF, |
| 2696 |
0xFF, |
| 2697 |
0xFF, 0xFF, 0xFF, 0xFF, |
| 2698 |
|
| 2699 |
'z', |
| 2700 |
|
| 2701 |
|
| 2702 |
0x00, 0x00, 0x04, |
| 2703 |
AWS_H2_FRAME_T_RST_STREAM, |
| 2704 |
0x00, |
| 2705 |
0x00, 0x00, 0x00, 0x02, |
| 2706 |
|
| 2707 |
0xFF, 0xEE, 0xDD, 0xCC, |
| 2708 |
|
| 2709 |
|
| 2710 |
0x00, 0x00, 11, |
| 2711 |
AWS_H2_FRAME_T_GOAWAY, |
| 2712 |
0xFF, |
| 2713 |
0x00, 0x00, 0x00, 0x00, |
| 2714 |
|
| 2715 |
0x00, 0x00, 0x00, 0x01, |
| 2716 |
0xFE, 0xED, 0xBE, 0xEF, |
| 2717 |
'b', 'y', 'e', |
| 2718 |
|
| 2719 |
|
| 2720 |
0x00, 0x00, 0x08, |
| 2721 |
AWS_H2_FRAME_T_PING, |
| 2722 |
AWS_H2_FRAME_F_ACK, |
| 2723 |
0x00, 0x00, 0x00, 0x00, |
| 2724 |
|
| 2725 |
'p', 'i', 'n', 'g', 'p', 'o', 'n', 'g', |
| 2726 |
}; |
| 2727 |
|
| 2728 |
|
| 2729 |
ASSERT_H2ERR_SUCCESS(s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 2730 |
|
| 2731 |
size_t frame_i = 0; |
| 2732 |
struct h2_decoded_frame *frame; |
| 2733 |
|
| 2734 |
|
| 2735 |
ASSERT_SUCCESS(s_get_finished_frame_i(fixture, frame_i++, AWS_H2_FRAME_T_HEADERS, 0x1 , &frame)); |
| 2736 |
ASSERT_UINT_EQUALS(2, aws_http_headers_count(frame->headers)); |
| 2737 |
ASSERT_SUCCESS(s_check_header(frame, 0, ":status", "302", AWS_HTTP_HEADER_COMPRESSION_USE_CACHE)); |
| 2738 |
ASSERT_SUCCESS(s_check_header(frame, 1, "cache-control", "private", AWS_HTTP_HEADER_COMPRESSION_USE_CACHE)); |
| 2739 |
ASSERT_FALSE(frame->end_stream); |
| 2740 |
|
| 2741 |
|
| 2742 |
ASSERT_SUCCESS(s_get_finished_frame_i(fixture, frame_i++, AWS_H2_FRAME_T_SETTINGS, 0x0 , &frame)); |
| 2743 |
ASSERT_TRUE(frame->ack); |
| 2744 |
|
| 2745 |
|
| 2746 |
ASSERT_SUCCESS(s_get_finished_frame_i(fixture, frame_i++, AWS_H2_FRAME_T_PUSH_PROMISE, 0x1 , &frame)); |
| 2747 |
ASSERT_UINT_EQUALS(2, frame->promised_stream_id); |
| 2748 |
ASSERT_UINT_EQUALS(3, aws_http_headers_count(frame->headers)); |
| 2749 |
ASSERT_SUCCESS(s_check_header(frame, 0, ":method", "GET", AWS_HTTP_HEADER_COMPRESSION_USE_CACHE)); |
| 2750 |
ASSERT_SUCCESS(s_check_header(frame, 1, ":scheme", "https", AWS_HTTP_HEADER_COMPRESSION_USE_CACHE)); |
| 2751 |
ASSERT_SUCCESS(s_check_header(frame, 2, ":path", "/index.html", AWS_HTTP_HEADER_COMPRESSION_USE_CACHE)); |
| 2752 |
ASSERT_FALSE(frame->end_stream); |
| 2753 |
|
| 2754 |
|
| 2755 |
|
| 2756 |
|
| 2757 |
ASSERT_SUCCESS(s_get_finished_frame_i(fixture, frame_i++, AWS_H2_FRAME_T_WINDOW_UPDATE, 0x0 , &frame)); |
| 2758 |
ASSERT_UINT_EQUALS(0x1, frame->window_size_increment); |
| 2759 |
|
| 2760 |
|
| 2761 |
ASSERT_SUCCESS(s_get_finished_frame_i(fixture, frame_i++, AWS_H2_FRAME_T_DATA, 0x1 , &frame)); |
| 2762 |
ASSERT_BIN_ARRAYS_EQUALS("h", 1, frame->data.buffer, frame->data.len); |
| 2763 |
ASSERT_TRUE(frame->end_stream); |
| 2764 |
|
| 2765 |
|
| 2766 |
|
| 2767 |
|
| 2768 |
ASSERT_SUCCESS(s_get_finished_frame_i(fixture, frame_i++, AWS_H2_FRAME_T_RST_STREAM, 0x2 , &frame)); |
| 2769 |
ASSERT_UINT_EQUALS(0xFFEEDDCC, frame->error_code); |
| 2770 |
|
| 2771 |
|
| 2772 |
ASSERT_SUCCESS(s_get_finished_frame_i(fixture, frame_i++, AWS_H2_FRAME_T_GOAWAY, 0x0 , &frame)); |
| 2773 |
ASSERT_UINT_EQUALS(0x1, frame->goaway_last_stream_id); |
| 2774 |
ASSERT_UINT_EQUALS(0xFEEDBEEF, frame->error_code); |
| 2775 |
ASSERT_BIN_ARRAYS_EQUALS("bye", 3, frame->data.buffer, frame->data.len); |
| 2776 |
|
| 2777 |
|
| 2778 |
ASSERT_SUCCESS(s_get_finished_frame_i(fixture, frame_i++, AWS_H2_FRAME_T_PING, 0x0 , &frame)); |
| 2779 |
ASSERT_TRUE(frame->ack); |
| 2780 |
|
| 2781 |
|
| 2782 |
ASSERT_UINT_EQUALS(frame_i, h2_decode_tester_frame_count(&fixture->decode)); |
| 2783 |
|
| 2784 |
return AWS_OP_SUCCESS; |
| 2785 |
} |
| 2786 |
|
| 2787 |
|
| 2788 |
|
| 2789 |
H2_DECODER_ON_CLIENT_PREFACE_TEST(h2_decoder_preface_from_server) { |
| 2790 |
(void)allocator; |
| 2791 |
struct fixture *fixture = ctx; |
| 2792 |
|
| 2793 |
|
| 2794 |
uint8_t input[] = { |
| 2795 |
|
| 2796 |
0x00, 0x00, 0x00, |
| 2797 |
AWS_H2_FRAME_T_SETTINGS, |
| 2798 |
0x00, |
| 2799 |
0x00, 0x00, 0x00, 0x00, |
| 2800 |
|
| 2801 |
|
| 2802 |
0x00, 0x00, 0x08, |
| 2803 |
AWS_H2_FRAME_T_PING, |
| 2804 |
0x0, |
| 2805 |
0x00, 0x00, 0x00, 0x00, |
| 2806 |
'p', 'i', 'n', 'g', 'p', 'o', 'n', 'g' |
| 2807 |
}; |
| 2808 |
|
| 2809 |
|
| 2810 |
|
| 2811 |
ASSERT_H2ERR_SUCCESS(s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 2812 |
|
| 2813 |
|
| 2814 |
ASSERT_UINT_EQUALS(2, h2_decode_tester_frame_count(&fixture->decode)); |
| 2815 |
|
| 2816 |
struct h2_decoded_frame *frame; |
| 2817 |
ASSERT_SUCCESS(s_get_finished_frame_i(fixture, 0, AWS_H2_FRAME_T_SETTINGS, 0 , &frame)); |
| 2818 |
ASSERT_SUCCESS(s_get_finished_frame_i(fixture, 1, AWS_H2_FRAME_T_PING, 0 , &frame)); |
| 2819 |
|
| 2820 |
return AWS_OP_SUCCESS; |
| 2821 |
} |
| 2822 |
|
| 2823 |
|
| 2824 |
|
| 2825 |
H2_DECODER_ON_CLIENT_PREFACE_TEST(h2_decoder_err_bad_preface_from_server_1) { |
| 2826 |
(void)allocator; |
| 2827 |
struct fixture *fixture = ctx; |
| 2828 |
|
| 2829 |
|
| 2830 |
uint8_t input[] = { |
| 2831 |
|
| 2832 |
0x00, 0x00, 0x08, |
| 2833 |
AWS_H2_FRAME_T_PING, |
| 2834 |
0x0, |
| 2835 |
0x00, 0x00, 0x00, 0x00, |
| 2836 |
'p', 'i', 'n', 'g', 'p', 'o', 'n', 'g' |
| 2837 |
}; |
| 2838 |
|
| 2839 |
|
| 2840 |
|
| 2841 |
ASSERT_H2ERR_ERROR( |
| 2842 |
AWS_HTTP2_ERR_PROTOCOL_ERROR, s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 2843 |
|
| 2844 |
return AWS_OP_SUCCESS; |
| 2845 |
} |
| 2846 |
|
| 2847 |
|
| 2848 |
|
| 2849 |
H2_DECODER_ON_CLIENT_PREFACE_TEST(h2_decoder_err_bad_preface_from_server_2) { |
| 2850 |
(void)allocator; |
| 2851 |
struct fixture *fixture = ctx; |
| 2852 |
|
| 2853 |
|
| 2854 |
uint8_t input[] = { |
| 2855 |
|
| 2856 |
0x00, 0x00, 0x00, |
| 2857 |
AWS_H2_FRAME_T_SETTINGS, |
| 2858 |
AWS_H2_FRAME_F_ACK, |
| 2859 |
0x00, 0x00, 0x00, 0x00, |
| 2860 |
}; |
| 2861 |
|
| 2862 |
|
| 2863 |
|
| 2864 |
ASSERT_H2ERR_ERROR( |
| 2865 |
AWS_HTTP2_ERR_PROTOCOL_ERROR, s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 2866 |
|
| 2867 |
return AWS_OP_SUCCESS; |
| 2868 |
} |
| 2869 |
|
| 2870 |
|
| 2871 |
H2_DECODER_ON_CLIENT_PREFACE_TEST(h2_decoder_err_bad_preface_from_server_3) { |
| 2872 |
(void)allocator; |
| 2873 |
struct fixture *fixture = ctx; |
| 2874 |
|
| 2875 |
const struct aws_byte_cursor input = AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL("PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n"); |
| 2876 |
|
| 2877 |
|
| 2878 |
ASSERT_H2ERR_ERROR(AWS_HTTP2_ERR_PROTOCOL_ERROR, s_decode_all(fixture, input)); |
| 2879 |
|
| 2880 |
return AWS_OP_SUCCESS; |
| 2881 |
} |
| 2882 |
|
| 2883 |
|
| 2884 |
H2_DECODER_ON_SERVER_PREFACE_TEST(h2_decoder_preface_from_client) { |
| 2885 |
(void)allocator; |
| 2886 |
struct fixture *fixture = ctx; |
| 2887 |
|
| 2888 |
|
| 2889 |
uint8_t input[] = { |
| 2890 |
|
| 2891 |
'P','R','I',' ','*',' ','H','T','T','P','/','2','.','0','\r','\n','\r','\n','S','M','\r','\n','\r','\n', |
| 2892 |
|
| 2893 |
|
| 2894 |
0x00, 0x00, 0x00, |
| 2895 |
AWS_H2_FRAME_T_SETTINGS, |
| 2896 |
0x00, |
| 2897 |
0x00, 0x00, 0x00, 0x00, |
| 2898 |
|
| 2899 |
|
| 2900 |
0x00, 0x00, 0x08, |
| 2901 |
AWS_H2_FRAME_T_PING, |
| 2902 |
0x0, |
| 2903 |
0x00, 0x00, 0x00, 0x00, |
| 2904 |
'p', 'i', 'n', 'g', 'p', 'o', 'n', 'g' |
| 2905 |
}; |
| 2906 |
|
| 2907 |
|
| 2908 |
|
| 2909 |
ASSERT_H2ERR_SUCCESS(s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 2910 |
|
| 2911 |
|
| 2912 |
ASSERT_UINT_EQUALS(2, h2_decode_tester_frame_count(&fixture->decode)); |
| 2913 |
|
| 2914 |
struct h2_decoded_frame *frame; |
| 2915 |
ASSERT_SUCCESS(s_get_finished_frame_i(fixture, 0, AWS_H2_FRAME_T_SETTINGS, 0 , &frame)); |
| 2916 |
ASSERT_SUCCESS(s_get_finished_frame_i(fixture, 1, AWS_H2_FRAME_T_PING, 0 , &frame)); |
| 2917 |
|
| 2918 |
return AWS_OP_SUCCESS; |
| 2919 |
} |
| 2920 |
|
| 2921 |
|
| 2922 |
H2_DECODER_ON_SERVER_PREFACE_TEST(h2_decoder_err_bad_preface_from_client_1) { |
| 2923 |
(void)allocator; |
| 2924 |
struct fixture *fixture = ctx; |
| 2925 |
|
| 2926 |
|
| 2927 |
uint8_t input[] = { |
| 2928 |
|
| 2929 |
0x00, 0x00, 0x00, |
| 2930 |
AWS_H2_FRAME_T_SETTINGS, |
| 2931 |
0x00, |
| 2932 |
0x00, 0x00, 0x00, 0x00, |
| 2933 |
}; |
| 2934 |
|
| 2935 |
|
| 2936 |
|
| 2937 |
ASSERT_H2ERR_ERROR( |
| 2938 |
AWS_HTTP2_ERR_PROTOCOL_ERROR, s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 2939 |
|
| 2940 |
return AWS_OP_SUCCESS; |
| 2941 |
} |
| 2942 |
|
| 2943 |
|
| 2944 |
H2_DECODER_ON_SERVER_PREFACE_TEST(h2_decoder_err_bad_preface_from_client_2) { |
| 2945 |
(void)allocator; |
| 2946 |
struct fixture *fixture = ctx; |
| 2947 |
|
| 2948 |
|
| 2949 |
struct aws_byte_cursor input = aws_byte_cursor_from_c_str("GET / HTTP/1.0\r\n\r\n"); |
| 2950 |
|
| 2951 |
|
| 2952 |
ASSERT_H2ERR_ERROR(AWS_HTTP2_ERR_PROTOCOL_ERROR, s_decode_all(fixture, input)); |
| 2953 |
|
| 2954 |
return AWS_OP_SUCCESS; |
| 2955 |
} |
| 2956 |
|
| 2957 |
|
| 2958 |
H2_DECODER_ON_SERVER_PREFACE_TEST(h2_decoder_err_bad_preface_from_client_3) { |
| 2959 |
(void)allocator; |
| 2960 |
struct fixture *fixture = ctx; |
| 2961 |
|
| 2962 |
|
| 2963 |
uint8_t input[] = { |
| 2964 |
|
| 2965 |
'P','R','I',' ','*',' ','H','T','T','P','/','2','.','0','\r','\n','\r','\n','S','M','\r','\n','\r','\n', |
| 2966 |
|
| 2967 |
|
| 2968 |
0x00, 0x00, 0x08, |
| 2969 |
AWS_H2_FRAME_T_PING, |
| 2970 |
0x0, |
| 2971 |
0x00, 0x00, 0x00, 0x00, |
| 2972 |
|
| 2973 |
'p', 'i', 'n', 'g', 'p', 'o', 'n', 'g' |
| 2974 |
}; |
| 2975 |
|
| 2976 |
|
| 2977 |
|
| 2978 |
ASSERT_H2ERR_ERROR( |
| 2979 |
AWS_HTTP2_ERR_PROTOCOL_ERROR, s_decode_all(fixture, aws_byte_cursor_from_array(input, sizeof(input)))); |
| 2980 |
|
| 2981 |
return AWS_OP_SUCCESS; |
| 2982 |
} |