OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef NET_HTTP2_DECODER_PAYLOAD_DECODERS_PAYLOAD_DECODER_BASE_TEST_UTIL_H_ | 5 #ifndef NET_HTTP2_DECODER_PAYLOAD_DECODERS_PAYLOAD_DECODER_BASE_TEST_UTIL_H_ |
6 #define NET_HTTP2_DECODER_PAYLOAD_DECODERS_PAYLOAD_DECODER_BASE_TEST_UTIL_H_ | 6 #define NET_HTTP2_DECODER_PAYLOAD_DECODERS_PAYLOAD_DECODER_BASE_TEST_UTIL_H_ |
7 | 7 |
8 // Base class for testing concrete payload decoder classes. | 8 // Base class for testing concrete payload decoder classes. |
9 | 9 |
10 #include <stddef.h> | 10 #include <stddef.h> |
11 | 11 |
12 #include <string> | 12 #include <string> |
13 | 13 |
14 #include "base/bind.h" | |
15 #include "base/bind_helpers.h" | |
16 #include "base/callback.h" | |
17 #include "base/logging.h" | 14 #include "base/logging.h" |
18 #include "base/strings/string_piece.h" | 15 #include "base/strings/string_piece.h" |
19 #include "net/http2/decoder/decode_buffer.h" | 16 #include "net/http2/decoder/decode_buffer.h" |
20 #include "net/http2/decoder/decode_status.h" | 17 #include "net/http2/decoder/decode_status.h" |
21 #include "net/http2/decoder/frame_decoder_state.h" | 18 #include "net/http2/decoder/frame_decoder_state.h" |
22 #include "net/http2/decoder/frame_parts.h" | 19 #include "net/http2/decoder/frame_parts.h" |
23 #include "net/http2/decoder/http2_frame_decoder_listener.h" | 20 #include "net/http2/decoder/http2_frame_decoder_listener.h" |
24 #include "net/http2/http2_constants.h" | 21 #include "net/http2/http2_constants.h" |
25 #include "net/http2/http2_constants_test_util.h" | 22 #include "net/http2/http2_constants_test_util.h" |
26 #include "net/http2/http2_structures.h" | 23 #include "net/http2/http2_structures.h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
116 // Base class for payload decoders of type Decoder, with corresponding test | 113 // Base class for payload decoders of type Decoder, with corresponding test |
117 // peer of type DecoderPeer, and using class Listener as the implementation | 114 // peer of type DecoderPeer, and using class Listener as the implementation |
118 // of Http2FrameDecoderListenerInterface to be used during decoding. | 115 // of Http2FrameDecoderListenerInterface to be used during decoding. |
119 // Typically Listener is a sub-class of FramePartsCollector. | 116 // Typically Listener is a sub-class of FramePartsCollector. |
120 // SupportedFrameType is set to false only for UnknownPayloadDecoder. | 117 // SupportedFrameType is set to false only for UnknownPayloadDecoder. |
121 template <class Decoder, | 118 template <class Decoder, |
122 class DecoderPeer, | 119 class DecoderPeer, |
123 class Listener, | 120 class Listener, |
124 bool SupportedFrameType = true> | 121 bool SupportedFrameType = true> |
125 class AbstractPayloadDecoderTest : public PayloadDecoderBaseTest { | 122 class AbstractPayloadDecoderTest : public PayloadDecoderBaseTest { |
126 public: | |
127 static bool SucceedingApproveSize(size_t size) { return true; } | |
128 | 123 |
129 protected: | 124 protected: |
130 // An ApproveSize function returns true to approve decoding the specified | 125 // An ApproveSize function returns true to approve decoding the specified |
131 // size of payload, else false to skip that size. Typically used for negative | 126 // size of payload, else false to skip that size. Typically used for negative |
132 // tests; for example, decoding a SETTINGS frame at all sizes except for | 127 // tests; for example, decoding a SETTINGS frame at all sizes except for |
133 // multiples of 6. | 128 // multiples of 6. |
134 typedef base::Callback<bool(size_t size)> ApproveSize; | 129 typedef std::function<bool(size_t size)> ApproveSize; |
135 | 130 |
136 AbstractPayloadDecoderTest() {} | 131 AbstractPayloadDecoderTest() {} |
137 | 132 |
138 // These tests are in setup rather than the constructor for two reasons: | 133 // These tests are in setup rather than the constructor for two reasons: |
139 // 1) Constructors are not allowed to fail, so gUnit documents that EXPECT_* | 134 // 1) Constructors are not allowed to fail, so gUnit documents that EXPECT_* |
140 // and ASSERT_* are not allowed in constructors, and should instead be in | 135 // and ASSERT_* are not allowed in constructors, and should instead be in |
141 // SetUp if they are needed before the body of the test is executed. | 136 // SetUp if they are needed before the body of the test is executed. |
142 // 2) To allow the sub-class constructor to make any desired modifications to | 137 // 2) To allow the sub-class constructor to make any desired modifications to |
143 // the DecoderPeer before these tests are executed; in particular, | 138 // the DecoderPeer before these tests are executed; in particular, |
144 // UnknownPayloadDecoderPeer has not got a fixed frame type, but it is | 139 // UnknownPayloadDecoderPeer has not got a fixed frame type, but it is |
145 // instead set during the test's constructor. | 140 // instead set during the test's constructor. |
146 void SetUp() override { | 141 void SetUp() override { |
147 PayloadDecoderBaseTest::SetUp(); | 142 PayloadDecoderBaseTest::SetUp(); |
148 | 143 |
149 // Confirm that DecoderPeer et al returns sensible values. Using auto as the | 144 // Confirm that DecoderPeer et al returns sensible values. Using auto as the |
150 // variable type so that no (narrowing) conversions take place that hide | 145 // variable type so that no (narrowing) conversions take place that hide |
151 // problems; i.e. if someone changes KnownFlagsMaskForFrameType so that it | 146 // problems; i.e. if someone changes KnownFlagsMaskForFrameType so that it |
152 // doesn't return a uint8, and has bits above the low-order 8 bits set, this | 147 // doesn't return a uint8, and has bits above the low-order 8 bits set, this |
153 // bit of paranoia should detect the problem before we get too far. | 148 // bit of paranoia should detect the problem before we get too far. |
154 auto frame_type = DecoderPeer::FrameType(); | 149 auto frame_type = DecoderPeer::FrameType(); |
155 if (SupportedFrameType) { | 150 if (SupportedFrameType) { |
James Synge
2017/01/05 21:39:06
I don't recall if we discussed this, but why is th
Bence
2017/01/06 01:42:40
This was changed server side at change 134543154.
| |
156 EXPECT_TRUE(IsSupportedHttp2FrameType(frame_type)) << frame_type; | 151 EXPECT_TRUE(IsSupportedHttp2FrameType(frame_type)) << frame_type; |
157 } else { | 152 } else { |
158 EXPECT_FALSE(IsSupportedHttp2FrameType(frame_type)) << frame_type; | 153 EXPECT_FALSE(IsSupportedHttp2FrameType(frame_type)) << frame_type; |
159 } | 154 } |
160 | 155 |
161 auto known_flags = KnownFlagsMaskForFrameType(frame_type); | 156 auto known_flags = KnownFlagsMaskForFrameType(frame_type); |
162 EXPECT_EQ(known_flags, known_flags & 0xff); | 157 EXPECT_EQ(known_flags, known_flags & 0xff); |
163 | 158 |
164 auto flags_to_avoid = DecoderPeer::FlagsAffectingPayloadDecoding(); | 159 auto flags_to_avoid = DecoderPeer::FlagsAffectingPayloadDecoding(); |
165 EXPECT_EQ(flags_to_avoid, flags_to_avoid & known_flags); | 160 EXPECT_EQ(flags_to_avoid, flags_to_avoid & known_flags); |
(...skipping 23 matching lines...) Expand all Loading... | |
189 DVLOG(2) << "StartDecodingPayload, db->Remaining=" << db->Remaining(); | 184 DVLOG(2) << "StartDecodingPayload, db->Remaining=" << db->Remaining(); |
190 return payload_decoder_.StartDecodingPayload(mutable_state(), db); | 185 return payload_decoder_.StartDecodingPayload(mutable_state(), db); |
191 } | 186 } |
192 | 187 |
193 // Resume decoding the payload. | 188 // Resume decoding the payload. |
194 DecodeStatus ResumeDecodingPayload(DecodeBuffer* db) override { | 189 DecodeStatus ResumeDecodingPayload(DecodeBuffer* db) override { |
195 DVLOG(2) << "ResumeDecodingPayload, db->Remaining=" << db->Remaining(); | 190 DVLOG(2) << "ResumeDecodingPayload, db->Remaining=" << db->Remaining(); |
196 return payload_decoder_.ResumeDecodingPayload(mutable_state(), db); | 191 return payload_decoder_.ResumeDecodingPayload(mutable_state(), db); |
197 } | 192 } |
198 | 193 |
199 // Wrap |validator| in another one which will check that we've reached the | |
200 // expected state of kDecodeError with OnFrameSizeError having been called by | |
201 AssertionResult ValidatorForDecodePayloadAndValidateSeveralWays( | |
202 const FrameParts& expected) { | |
203 VERIFY_FALSE(listener_.IsInProgress()); | |
204 VERIFY_EQ(1u, listener_.size()); | |
205 VERIFY_AND_RETURN_SUCCESS(expected.VerifyEquals(*listener_.frame(0))); | |
206 } | |
207 | 194 |
208 // Decode one frame's payload and confirm that the listener recorded the | 195 // Decode one frame's payload and confirm that the listener recorded the |
209 // expected FrameParts instance, and only FrameParts instance. The payload | 196 // expected FrameParts instance, and only FrameParts instance. The payload |
210 // will be decoded several times with different partitionings of the payload, | 197 // will be decoded several times with different partitionings of the payload, |
211 // and after each the validator will be called. | 198 // and after each the validator will be called. |
212 AssertionResult DecodePayloadAndValidateSeveralWays( | 199 AssertionResult DecodePayloadAndValidateSeveralWays( |
213 base::StringPiece payload, | 200 base::StringPiece payload, |
214 const FrameParts& expected) { | 201 const FrameParts& expected) { |
202 NoArgValidator validator = [&expected, this]() -> AssertionResult { | |
James Synge
2017/01/05 21:39:06
auto validator?
Bence
2017/01/06 01:42:40
../../net/http2/decoder/payload_decoders/payload_d
| |
203 VERIFY_FALSE(listener_.IsInProgress()); | |
204 VERIFY_EQ(1u, listener_.size()); | |
205 VERIFY_AND_RETURN_SUCCESS(expected.VerifyEquals(*listener_.frame(0))); | |
206 }; | |
215 return PayloadDecoderBaseTest::DecodePayloadAndValidateSeveralWays( | 207 return PayloadDecoderBaseTest::DecodePayloadAndValidateSeveralWays( |
216 payload, this->ValidateDoneAndEmpty(base::Bind( | 208 payload, ValidateDoneAndEmpty(validator)); |
217 &AbstractPayloadDecoderTest:: | |
218 ValidatorForDecodePayloadAndValidateSeveralWays, | |
219 base::Unretained(this), base::ConstRef(expected)))); | |
220 } | |
221 | |
222 // Wrap |validator| in another one which will check that we've reached the | |
223 // expected state of kDecodeError with OnFrameSizeError having been called by | |
224 // the payload decoder. | |
225 AssertionResult ValidatorForVerifyDetectsFrameSizeError( | |
226 const Http2FrameHeader& header, | |
227 const Validator& validator, | |
228 const DecodeBuffer& input, | |
229 DecodeStatus status) { | |
230 DVLOG(2) << "VerifyDetectsFrameSizeError validator; status=" << status | |
231 << "; input.Remaining=" << input.Remaining(); | |
232 VERIFY_EQ(DecodeStatus::kDecodeError, status); | |
233 VERIFY_FALSE(listener_.IsInProgress()); | |
234 VERIFY_EQ(1u, listener_.size()); | |
235 const FrameParts* frame = listener_.frame(0); | |
236 VERIFY_EQ(header, frame->frame_header); | |
237 VERIFY_TRUE(frame->has_frame_size_error); | |
238 // Verify did not get OnPaddingTooLong, as we should only ever produce | |
239 // one of these two errors for a single frame. | |
240 VERIFY_FALSE(frame->opt_missing_length); | |
241 return validator.Run(input, status); | |
242 } | 209 } |
243 | 210 |
244 // Decode one frame's payload, expecting that the final status will be | 211 // Decode one frame's payload, expecting that the final status will be |
245 // kDecodeError, and that OnFrameSizeError will have been called on the | 212 // kDecodeError, and that OnFrameSizeError will have been called on the |
246 // listener. The payload will be decoded several times with different | 213 // listener. The payload will be decoded several times with different |
247 // partitionings of the payload. The type WrappedValidator is either | 214 // partitionings of the payload. The type WrappedValidator is either |
248 // RandomDecoderTest::Validator, RandomDecoderTest::NoArgValidator or | 215 // RandomDecoderTest::Validator, RandomDecoderTest::NoArgValidator or |
249 // std::nullptr_t (not extra validation). | 216 // std::nullptr_t (not extra validation). |
250 template <typename WrappedValidator> | 217 template <typename WrappedValidator> |
251 ::testing::AssertionResult VerifyDetectsFrameSizeError( | 218 ::testing::AssertionResult VerifyDetectsFrameSizeError( |
252 base::StringPiece payload, | 219 base::StringPiece payload, |
253 const Http2FrameHeader& header, | 220 const Http2FrameHeader& header, |
254 WrappedValidator wrapped_validator) { | 221 WrappedValidator wrapped_validator) { |
255 set_frame_header(header); | 222 set_frame_header(header); |
256 // If wrapped_validator is not a RandomDecoderTest::Validator, make it so. | 223 // If wrapped_validator is not a RandomDecoderTest::Validator, make it so. |
257 Validator validator = this->ToValidator(wrapped_validator); | 224 Validator validator = ToValidator(wrapped_validator); |
225 // And wrap that validator in another which will check that we've reached | |
226 // the expected state of kDecodeError with OnFrameSizeError having been | |
227 // called by the payload decoder. | |
228 validator = [header, validator, this]( | |
229 const DecodeBuffer& input, | |
230 DecodeStatus status) -> ::testing::AssertionResult { | |
231 DVLOG(2) << "VerifyDetectsFrameSizeError validator; status=" << status | |
232 << "; input.Remaining=" << input.Remaining(); | |
233 VERIFY_EQ(DecodeStatus::kDecodeError, status); | |
234 VERIFY_FALSE(listener_.IsInProgress()); | |
235 VERIFY_EQ(1u, listener_.size()); | |
236 const FrameParts* frame = listener_.frame(0); | |
237 VERIFY_EQ(header, frame->frame_header); | |
238 VERIFY_TRUE(frame->has_frame_size_error); | |
239 // Verify did not get OnPaddingTooLong, as we should only ever produce | |
240 // one of these two errors for a single frame. | |
241 VERIFY_FALSE(frame->opt_missing_length); | |
242 return validator(input, status); | |
243 }; | |
258 VERIFY_AND_RETURN_SUCCESS( | 244 VERIFY_AND_RETURN_SUCCESS( |
259 PayloadDecoderBaseTest::DecodePayloadAndValidateSeveralWays( | 245 PayloadDecoderBaseTest::DecodePayloadAndValidateSeveralWays(payload, |
260 payload, base::Bind(&AbstractPayloadDecoderTest:: | 246 validator)); |
261 ValidatorForVerifyDetectsFrameSizeError, | |
262 base::Unretained(this), base::ConstRef(header), | |
263 base::ConstRef(validator)))); | |
264 } | 247 } |
265 | 248 |
266 // Confirm that we get OnFrameSizeError when trying to decode unpadded_payload | 249 // Confirm that we get OnFrameSizeError when trying to decode unpadded_payload |
267 // at all sizes from zero to unpadded_payload.size(), except those sizes not | 250 // at all sizes from zero to unpadded_payload.size(), except those sizes not |
268 // approved by approve_size. | 251 // approved by approve_size. |
269 // If total_pad_length is greater than zero, then that amount of padding | 252 // If total_pad_length is greater than zero, then that amount of padding |
270 // is added to the payload (including the Pad Length field). | 253 // is added to the payload (including the Pad Length field). |
271 // The flags will be required_flags, PADDED if total_pad_length > 0, and some | 254 // The flags will be required_flags, PADDED if total_pad_length > 0, and some |
272 // randomly selected flag bits not excluded by FlagsAffectingPayloadDecoding. | 255 // randomly selected flag bits not excluded by FlagsAffectingPayloadDecoding. |
273 ::testing::AssertionResult VerifyDetectsMultipleFrameSizeErrors( | 256 ::testing::AssertionResult VerifyDetectsMultipleFrameSizeErrors( |
(...skipping 18 matching lines...) Expand all Loading... | |
292 } else { | 275 } else { |
293 required_flags |= Http2FrameFlag::FLAG_PADDED; | 276 required_flags |= Http2FrameFlag::FLAG_PADDED; |
294 } | 277 } |
295 } else { | 278 } else { |
296 VERIFY_EQ(0, total_pad_length); | 279 VERIFY_EQ(0, total_pad_length); |
297 } | 280 } |
298 | 281 |
299 bool validated = false; | 282 bool validated = false; |
300 for (size_t real_payload_size = 0; | 283 for (size_t real_payload_size = 0; |
301 real_payload_size <= unpadded_payload.size(); ++real_payload_size) { | 284 real_payload_size <= unpadded_payload.size(); ++real_payload_size) { |
302 if (!approve_size.Run(real_payload_size)) { | 285 if (approve_size != nullptr && !approve_size(real_payload_size)) { |
303 continue; | 286 continue; |
304 } | 287 } |
305 VLOG(1) << "real_payload_size=" << real_payload_size; | 288 VLOG(1) << "real_payload_size=" << real_payload_size; |
306 uint8_t flags = required_flags | RandFlags(); | 289 uint8_t flags = required_flags | RandFlags(); |
307 Http2FrameBuilder fb; | 290 Http2FrameBuilder fb; |
308 if (total_pad_length > 0) { | 291 if (total_pad_length > 0) { |
309 // total_pad_length_ includes the size of the Pad Length field, and thus | 292 // total_pad_length_ includes the size of the Pad Length field, and thus |
310 // ranges from 0 (no PADDED flag) to 256 (Pad Length == 255). | 293 // ranges from 0 (no PADDED flag) to 256 (Pad Length == 255). |
311 fb.AppendUInt8(total_pad_length - 1); | 294 fb.AppendUInt8(total_pad_length - 1); |
312 } | 295 } |
313 // Append a subset of the unpadded_payload, which the decoder should | 296 // Append a subset of the unpadded_payload, which the decoder should |
314 // determine is not a valid amount. | 297 // determine is not a valid amount. |
315 fb.Append(unpadded_payload.substr(0, real_payload_size)); | 298 fb.Append(unpadded_payload.substr(0, real_payload_size)); |
316 if (total_pad_length > 0) { | 299 if (total_pad_length > 0) { |
317 fb.AppendZeroes(total_pad_length - 1); | 300 fb.AppendZeroes(total_pad_length - 1); |
318 } | 301 } |
319 // We choose a random stream id because the payload decoders aren't | 302 // We choose a random stream id because the payload decoders aren't |
320 // checking stream ids. | 303 // checking stream ids. |
321 uint32_t stream_id = RandStreamId(); | 304 uint32_t stream_id = RandStreamId(); |
322 Http2FrameHeader header(fb.size(), frame_type, flags, stream_id); | 305 Http2FrameHeader header(fb.size(), frame_type, flags, stream_id); |
323 VERIFY_SUCCESS(VerifyDetectsFrameSizeError( | 306 VERIFY_SUCCESS(VerifyDetectsFrameSizeError(fb.buffer(), header, nullptr)); |
324 fb.buffer(), header, base::Bind(&SucceedingValidator))); | |
325 validated = true; | 307 validated = true; |
326 } | 308 } |
327 VERIFY_TRUE(validated); | 309 VERIFY_TRUE(validated); |
328 return ::testing::AssertionSuccess(); | 310 return ::testing::AssertionSuccess(); |
329 } | 311 } |
330 | 312 |
331 // As above, but for frames without padding. | 313 // As above, but for frames without padding. |
332 ::testing::AssertionResult VerifyDetectsFrameSizeError( | 314 ::testing::AssertionResult VerifyDetectsFrameSizeError( |
333 uint8_t required_flags, | 315 uint8_t required_flags, |
334 base::StringPiece unpadded_payload, | 316 base::StringPiece unpadded_payload, |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
399 uint8_t RandFlags() { | 381 uint8_t RandFlags() { |
400 uint8_t flags = Base::RandFlags(); | 382 uint8_t flags = Base::RandFlags(); |
401 if (IsPadded()) { | 383 if (IsPadded()) { |
402 flags |= Http2FrameFlag::FLAG_PADDED; | 384 flags |= Http2FrameFlag::FLAG_PADDED; |
403 } else { | 385 } else { |
404 flags &= ~Http2FrameFlag::FLAG_PADDED; | 386 flags &= ~Http2FrameFlag::FLAG_PADDED; |
405 } | 387 } |
406 return flags; | 388 return flags; |
407 } | 389 } |
408 | 390 |
409 static ::testing::AssertionResult ValidatorForVerifyDetectsPaddingTooLong( | |
410 const Http2FrameHeader& header, | |
411 int expected_missing_length, | |
412 const Listener& listener, | |
413 const DecodeBuffer& input, | |
414 DecodeStatus status) { | |
415 VERIFY_EQ(DecodeStatus::kDecodeError, status); | |
416 VERIFY_FALSE(listener.IsInProgress()); | |
417 VERIFY_EQ(1u, listener.size()); | |
418 const FrameParts* frame = listener.frame(0); | |
419 VERIFY_EQ(header, frame->frame_header); | |
420 VERIFY_TRUE(frame->opt_missing_length); | |
421 VERIFY_EQ(expected_missing_length, frame->opt_missing_length.value()); | |
422 // Verify did not get OnFrameSizeError. | |
423 VERIFY_FALSE(frame->has_frame_size_error); | |
424 return ::testing::AssertionSuccess(); | |
425 } | |
426 | 391 |
427 // Verify that we get OnPaddingTooLong when decoding payload, and that the | 392 // Verify that we get OnPaddingTooLong when decoding payload, and that the |
428 // amount of missing padding is as specified. header.IsPadded must be true, | 393 // amount of missing padding is as specified. header.IsPadded must be true, |
429 // and the payload must be empty or the PadLength field must be too large. | 394 // and the payload must be empty or the PadLength field must be too large. |
430 ::testing::AssertionResult VerifyDetectsPaddingTooLong( | 395 ::testing::AssertionResult VerifyDetectsPaddingTooLong( |
431 base::StringPiece payload, | 396 base::StringPiece payload, |
432 const Http2FrameHeader& header, | 397 const Http2FrameHeader& header, |
433 int expected_missing_length) { | 398 int expected_missing_length) { |
434 set_frame_header(header); | 399 set_frame_header(header); |
435 auto& listener = listener_; | 400 auto& listener = listener_; |
401 Validator validator = [header, expected_missing_length, &listener]( | |
402 const DecodeBuffer& input, | |
403 DecodeStatus status) -> ::testing::AssertionResult { | |
404 VERIFY_EQ(DecodeStatus::kDecodeError, status); | |
405 VERIFY_FALSE(listener.IsInProgress()); | |
406 VERIFY_EQ(1u, listener.size()); | |
407 const FrameParts* frame = listener.frame(0); | |
408 VERIFY_EQ(header, frame->frame_header); | |
409 VERIFY_TRUE(frame->opt_missing_length); | |
410 VERIFY_EQ(expected_missing_length, frame->opt_missing_length.value()); | |
411 // Verify did not get OnFrameSizeError. | |
412 VERIFY_FALSE(frame->has_frame_size_error); | |
413 return ::testing::AssertionSuccess(); | |
414 }; | |
436 VERIFY_AND_RETURN_SUCCESS( | 415 VERIFY_AND_RETURN_SUCCESS( |
437 PayloadDecoderBaseTest::DecodePayloadAndValidateSeveralWays( | 416 PayloadDecoderBaseTest::DecodePayloadAndValidateSeveralWays(payload, |
438 payload, base::Bind(&AbstractPaddablePayloadDecoderTest:: | 417 validator)); |
439 ValidatorForVerifyDetectsPaddingTooLong, | |
440 header, expected_missing_length, | |
441 base::ConstRef(listener)))); | |
442 } | 418 } |
443 | 419 |
444 // Verifies that we get OnPaddingTooLong for a padded frame payload whose | 420 // Verifies that we get OnPaddingTooLong for a padded frame payload whose |
445 // (randomly selected) payload length is less than total_pad_length_. | 421 // (randomly selected) payload length is less than total_pad_length_. |
446 // Flags will be selected at random, except PADDED will be set and | 422 // Flags will be selected at random, except PADDED will be set and |
447 // flags_to_avoid will not be set. The stream id is selected at random. | 423 // flags_to_avoid will not be set. The stream id is selected at random. |
448 ::testing::AssertionResult VerifyDetectsPaddingTooLong() { | 424 ::testing::AssertionResult VerifyDetectsPaddingTooLong() { |
449 uint8_t flags = RandFlags() | Http2FrameFlag::FLAG_PADDED; | 425 uint8_t flags = RandFlags() | Http2FrameFlag::FLAG_PADDED; |
450 | 426 |
451 // Create an all padding payload for total_pad_length_. | 427 // Create an all padding payload for total_pad_length_. |
(...skipping 25 matching lines...) Expand all Loading... | |
477 // total_pad_length_ includes the size of the Pad Length field, and thus | 453 // total_pad_length_ includes the size of the Pad Length field, and thus |
478 // ranges from 0 (no PADDED flag) to 256 (Pad Length == 255). | 454 // ranges from 0 (no PADDED flag) to 256 (Pad Length == 255). |
479 const size_t total_pad_length_; | 455 const size_t total_pad_length_; |
480 Http2FrameBuilder frame_builder_; | 456 Http2FrameBuilder frame_builder_; |
481 }; | 457 }; |
482 | 458 |
483 } // namespace test | 459 } // namespace test |
484 } // namespace net | 460 } // namespace net |
485 | 461 |
486 #endif // NET_HTTP2_DECODER_PAYLOAD_DECODERS_PAYLOAD_DECODER_BASE_TEST_UTIL_H_ | 462 #endif // NET_HTTP2_DECODER_PAYLOAD_DECODERS_PAYLOAD_DECODER_BASE_TEST_UTIL_H_ |
OLD | NEW |