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 #include "net/http2/decoder/payload_decoders/altsvc_payload_decoder.h" | 5 #include "net/http2/decoder/payload_decoders/altsvc_payload_decoder.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/bind.h" | |
12 #include "base/logging.h" | 11 #include "base/logging.h" |
13 #include "net/http2/decoder/frame_parts.h" | 12 #include "net/http2/decoder/frame_parts.h" |
14 #include "net/http2/decoder/frame_parts_collector.h" | 13 #include "net/http2/decoder/frame_parts_collector.h" |
15 #include "net/http2/decoder/http2_frame_decoder_listener.h" | 14 #include "net/http2/decoder/http2_frame_decoder_listener.h" |
16 #include "net/http2/decoder/payload_decoders/payload_decoder_base_test_util.h" | 15 #include "net/http2/decoder/payload_decoders/payload_decoder_base_test_util.h" |
17 #include "net/http2/http2_constants.h" | 16 #include "net/http2/http2_constants.h" |
18 #include "net/http2/http2_structures_test_util.h" | 17 #include "net/http2/http2_structures_test_util.h" |
19 #include "net/http2/tools/http2_frame_builder.h" | 18 #include "net/http2/tools/http2_frame_builder.h" |
20 #include "net/http2/tools/http2_random.h" | 19 #include "net/http2/tools/http2_random.h" |
21 #include "net/http2/tools/random_decoder_test.h" | 20 #include "net/http2/tools/random_decoder_test.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 : public AbstractPayloadDecoderTest<AltSvcPayloadDecoder, | 80 : public AbstractPayloadDecoderTest<AltSvcPayloadDecoder, |
82 AltSvcPayloadDecoderPeer, | 81 AltSvcPayloadDecoderPeer, |
83 Listener> {}; | 82 Listener> {}; |
84 | 83 |
85 // Confirm we get an error if the payload is not long enough to hold | 84 // Confirm we get an error if the payload is not long enough to hold |
86 // Http2AltSvcFields and the indicated length of origin. | 85 // Http2AltSvcFields and the indicated length of origin. |
87 TEST_F(AltSvcPayloadDecoderTest, Truncated) { | 86 TEST_F(AltSvcPayloadDecoderTest, Truncated) { |
88 Http2FrameBuilder fb; | 87 Http2FrameBuilder fb; |
89 fb.Append(Http2AltSvcFields{0xffff}); // The longest possible origin length. | 88 fb.Append(Http2AltSvcFields{0xffff}); // The longest possible origin length. |
90 fb.Append("Too little origin!"); | 89 fb.Append("Too little origin!"); |
91 EXPECT_TRUE(VerifyDetectsFrameSizeError( | 90 EXPECT_TRUE( |
92 0, fb.buffer(), | 91 VerifyDetectsFrameSizeError(0, fb.buffer(), /*approve_size*/ nullptr)); |
93 base::Bind(&AbstractPayloadDecoderTest::SucceedingApproveSize))); | |
94 } | 92 } |
95 | 93 |
96 class AltSvcPayloadLengthTests : public AltSvcPayloadDecoderTest, | 94 class AltSvcPayloadLengthTests : public AltSvcPayloadDecoderTest, |
97 public ::testing::WithParamInterface< | 95 public ::testing::WithParamInterface< |
98 ::testing::tuple<uint16_t, uint32_t>> { | 96 ::testing::tuple<uint16_t, uint32_t>> { |
99 protected: | 97 protected: |
100 AltSvcPayloadLengthTests() | 98 AltSvcPayloadLengthTests() |
101 : origin_length_(::testing::get<0>(GetParam())), | 99 : origin_length_(::testing::get<0>(GetParam())), |
102 value_length_(::testing::get<1>(GetParam())) { | 100 value_length_(::testing::get<1>(GetParam())) { |
103 VLOG(1) << "################ origin_length_=" << origin_length_ | 101 VLOG(1) << "################ origin_length_=" << origin_length_ |
(...skipping 20 matching lines...) Expand all Loading... |
124 RandStreamId()); | 122 RandStreamId()); |
125 set_frame_header(header); | 123 set_frame_header(header); |
126 FrameParts expected(header); | 124 FrameParts expected(header); |
127 expected.SetAltSvcExpected(origin, value); | 125 expected.SetAltSvcExpected(origin, value); |
128 ASSERT_TRUE(DecodePayloadAndValidateSeveralWays(fb.buffer(), expected)); | 126 ASSERT_TRUE(DecodePayloadAndValidateSeveralWays(fb.buffer(), expected)); |
129 } | 127 } |
130 | 128 |
131 } // namespace | 129 } // namespace |
132 } // namespace test | 130 } // namespace test |
133 } // namespace net | 131 } // namespace net |
OLD | NEW |