Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(231)

Side by Side Diff: net/spdy/spdy_network_transaction_unittest.cc

Issue 2782193002: Add unittest for ignoring unknown HTTP/2 frame type 0x0b. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <cmath> 5 #include <cmath>
6 #include <memory> 6 #include <memory>
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 6500 matching lines...) Expand 10 before | Expand all | Expand 10 after
6511 nullptr); 6511 nullptr);
6512 6512
6513 helper.RunToCompletion(&data); 6513 helper.RunToCompletion(&data);
6514 6514
6515 TransactionHelperResult out = helper.output(); 6515 TransactionHelperResult out = helper.output();
6516 EXPECT_THAT(out.rv, IsOk()); 6516 EXPECT_THAT(out.rv, IsOk());
6517 EXPECT_EQ("HTTP/1.1 200", out.status_line); 6517 EXPECT_EQ("HTTP/1.1 200", out.status_line);
6518 EXPECT_EQ("hello!", out.response_data); 6518 EXPECT_EQ("hello!", out.response_data);
6519 } 6519 }
6520 6520
6521 // Unsupported frames must be ignored. This is especially important for frame
6522 // type 0xb, which used to be the BLOCKED frame in previous versions of SPDY,
6523 // but is going to be used for the ORIGIN frame.
6524 // TODO(bnc): Implement ORIGIN frame support. https://crbug.com/697333
6525 TEST_F(SpdyNetworkTransactionTest, IgnoreUnsupportedOriginFrame) {
6526 SpdySerializedFrame req(
6527 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true));
6528 MockWrite writes[] = {CreateMockWrite(req, 0)};
6529
6530 const char origin_frame_on_stream_zero[] = {
6531 0x00, 0x00, 0x05, // Length
6532 0x0b, // Type
6533 0x00, // Flags
6534 0x00, 0x00, 0x00, 0x00, // Stream ID
6535 0x00, 0x03, // Origin-Len
6536 'f', 'o', 'o' // ASCII-Origin
6537 };
6538
6539 const char origin_frame_on_stream_one[] = {
6540 0x00, 0x00, 0x05, // Length
6541 0x0b, // Type
6542 0x00, // Flags
6543 0x00, 0x00, 0x00, 0x01, // Stream ID
6544 0x00, 0x03, // Origin-Len
6545 'b', 'a', 'r' // ASCII-Origin
6546 };
6547
6548 SpdySerializedFrame resp(spdy_util_.ConstructSpdyGetReply(nullptr, 0, 1));
6549 SpdySerializedFrame body(spdy_util_.ConstructSpdyDataFrame(1, true));
6550 MockRead reads[] = {MockRead(ASYNC, origin_frame_on_stream_zero,
6551 arraysize(origin_frame_on_stream_zero), 1),
6552 CreateMockRead(resp, 2),
6553 MockRead(ASYNC, origin_frame_on_stream_one,
6554 arraysize(origin_frame_on_stream_one), 3),
6555 CreateMockRead(body, 4), MockRead(ASYNC, 0, 5)};
6556
6557 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
6558 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
6559 NetLogWithSource(), nullptr);
6560 helper.RunToCompletion(&data);
6561 TransactionHelperResult out = helper.output();
6562 EXPECT_THAT(out.rv, IsOk());
6563 EXPECT_EQ("HTTP/1.1 200", out.status_line);
6564 EXPECT_EQ("hello!", out.response_data);
6565 }
6566
6521 class SpdyNetworkTransactionTLSUsageCheckTest 6567 class SpdyNetworkTransactionTLSUsageCheckTest
6522 : public SpdyNetworkTransactionTest { 6568 : public SpdyNetworkTransactionTest {
6523 protected: 6569 protected:
6524 void RunTLSUsageCheckTest( 6570 void RunTLSUsageCheckTest(
6525 std::unique_ptr<SSLSocketDataProvider> ssl_provider) { 6571 std::unique_ptr<SSLSocketDataProvider> ssl_provider) {
6526 SpdySerializedFrame goaway( 6572 SpdySerializedFrame goaway(
6527 spdy_util_.ConstructSpdyGoAway(0, ERROR_CODE_INADEQUATE_SECURITY, "")); 6573 spdy_util_.ConstructSpdyGoAway(0, ERROR_CODE_INADEQUATE_SECURITY, ""));
6528 MockWrite writes[] = {CreateMockWrite(goaway)}; 6574 MockWrite writes[] = {CreateMockWrite(goaway)};
6529 6575
6530 StaticSocketDataProvider data(nullptr, 0, writes, arraysize(writes)); 6576 StaticSocketDataProvider data(nullptr, 0, writes, arraysize(writes));
(...skipping 20 matching lines...) Expand all
6551 TEST_F(SpdyNetworkTransactionTLSUsageCheckTest, TLSCipherSuiteSucky) { 6597 TEST_F(SpdyNetworkTransactionTLSUsageCheckTest, TLSCipherSuiteSucky) {
6552 std::unique_ptr<SSLSocketDataProvider> ssl_provider( 6598 std::unique_ptr<SSLSocketDataProvider> ssl_provider(
6553 new SSLSocketDataProvider(ASYNC, OK)); 6599 new SSLSocketDataProvider(ASYNC, OK));
6554 // Set to TLS_RSA_WITH_NULL_MD5 6600 // Set to TLS_RSA_WITH_NULL_MD5
6555 SSLConnectionStatusSetCipherSuite(0x1, &ssl_provider->connection_status); 6601 SSLConnectionStatusSetCipherSuite(0x1, &ssl_provider->connection_status);
6556 6602
6557 RunTLSUsageCheckTest(std::move(ssl_provider)); 6603 RunTLSUsageCheckTest(std::move(ssl_provider));
6558 } 6604 }
6559 6605
6560 } // namespace net 6606 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698