OLD | NEW |
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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 54 |
55 namespace net { | 55 namespace net { |
56 | 56 |
57 namespace { | 57 namespace { |
58 | 58 |
59 using testing::Each; | 59 using testing::Each; |
60 using testing::Eq; | 60 using testing::Eq; |
61 | 61 |
62 const int32_t kBufferSize = SpdyHttpStream::kRequestBodyBufferSize; | 62 const int32_t kBufferSize = SpdyHttpStream::kRequestBodyBufferSize; |
63 | 63 |
64 enum SpdyNetworkTransactionTestSSLType { | |
65 // Request an https:// URL and use NPN (or ALPN) to negotiate SPDY during | |
66 // the TLS handshake. | |
67 HTTPS_SPDY_VIA_NPN, | |
68 // Request an https:// URL to a server that supports SPDY via Alternative | |
69 // Service. | |
70 // See: http://httpwg.org/http-extensions/alt-svc.html. | |
71 HTTPS_SPDY_VIA_ALT_SVC, | |
72 }; | |
73 | |
74 struct SpdyNetworkTransactionTestParams { | 64 struct SpdyNetworkTransactionTestParams { |
75 SpdyNetworkTransactionTestParams() | 65 SpdyNetworkTransactionTestParams() |
76 : protocol(kProtoSPDY31), | 66 : protocol(kProtoSPDY31), |
77 ssl_type(HTTPS_SPDY_VIA_NPN), | |
78 priority_to_dependency(false) {} | 67 priority_to_dependency(false) {} |
79 | 68 |
80 SpdyNetworkTransactionTestParams(NextProto protocol, | 69 SpdyNetworkTransactionTestParams(NextProto protocol, |
81 SpdyNetworkTransactionTestSSLType ssl_type, | |
82 bool priority_to_dependency) | 70 bool priority_to_dependency) |
83 : protocol(protocol), | 71 : protocol(protocol), |
84 ssl_type(ssl_type), | |
85 priority_to_dependency(priority_to_dependency) {} | 72 priority_to_dependency(priority_to_dependency) {} |
86 | 73 |
87 friend std::ostream& operator<<(std::ostream& os, | 74 friend std::ostream& operator<<(std::ostream& os, |
88 const SpdyNetworkTransactionTestParams& p) { | 75 const SpdyNetworkTransactionTestParams& p) { |
89 std::string type_str; | |
90 switch (p.ssl_type) { | |
91 case HTTPS_SPDY_VIA_ALT_SVC: | |
92 type_str = "HTTPS_SPDY_VIA_ALT_SVC"; | |
93 break; | |
94 case HTTPS_SPDY_VIA_NPN: | |
95 type_str = "HTTPS_SPDY_VIA_NPN"; | |
96 break; | |
97 } | |
98 os << "{ protocol: " << SSLClientSocket::NextProtoToString(p.protocol) | 76 os << "{ protocol: " << SSLClientSocket::NextProtoToString(p.protocol) |
99 << ", ssl_type: " << type_str | |
100 << ", priority_to_dependency: " << p.priority_to_dependency << " }"; | 77 << ", priority_to_dependency: " << p.priority_to_dependency << " }"; |
101 return os; | 78 return os; |
102 } | 79 } |
103 | 80 |
104 NextProto protocol; | 81 NextProto protocol; |
105 SpdyNetworkTransactionTestSSLType ssl_type; | |
106 bool priority_to_dependency; | 82 bool priority_to_dependency; |
107 }; | 83 }; |
108 | 84 |
109 void UpdateSpdySessionDependencies(SpdyNetworkTransactionTestParams test_params, | 85 void UpdateSpdySessionDependencies(SpdyNetworkTransactionTestParams test_params, |
110 SpdySessionDependencies* session_deps) { | 86 SpdySessionDependencies* session_deps) { |
111 if (test_params.ssl_type == HTTPS_SPDY_VIA_ALT_SVC) { | |
112 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); | |
113 session_deps->http_server_properties->SetAlternativeService( | |
114 url::SchemeHostPort(GURL(kDefaultUrl)), | |
115 AlternativeService(AlternateProtocolFromNextProto(test_params.protocol), | |
116 "mail.example.org", 443), | |
117 expiration); | |
118 } | |
119 session_deps->enable_priority_dependencies = | 87 session_deps->enable_priority_dependencies = |
120 test_params.priority_to_dependency; | 88 test_params.priority_to_dependency; |
121 } | 89 } |
122 | 90 |
123 std::unique_ptr<SpdySessionDependencies> CreateSpdySessionDependencies( | 91 std::unique_ptr<SpdySessionDependencies> CreateSpdySessionDependencies( |
124 SpdyNetworkTransactionTestParams test_params) { | 92 SpdyNetworkTransactionTestParams test_params) { |
125 std::unique_ptr<SpdySessionDependencies> session_deps( | 93 std::unique_ptr<SpdySessionDependencies> session_deps( |
126 new SpdySessionDependencies(test_params.protocol)); | 94 new SpdySessionDependencies(test_params.protocol)); |
127 UpdateSpdySessionDependencies(test_params, session_deps.get()); | 95 UpdateSpdySessionDependencies(test_params, session_deps.get()); |
128 return session_deps; | 96 return session_deps; |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 if (ssl_provider->next_proto_status == | 298 if (ssl_provider->next_proto_status == |
331 SSLClientSocket::kNextProtoUnsupported) { | 299 SSLClientSocket::kNextProtoUnsupported) { |
332 ssl_provider->SetNextProto(test_params_.protocol); | 300 ssl_provider->SetNextProto(test_params_.protocol); |
333 } | 301 } |
334 | 302 |
335 session_deps_->socket_factory->AddSSLSocketDataProvider( | 303 session_deps_->socket_factory->AddSSLSocketDataProvider( |
336 ssl_provider.get()); | 304 ssl_provider.get()); |
337 ssl_vector_.push_back(std::move(ssl_provider)); | 305 ssl_vector_.push_back(std::move(ssl_provider)); |
338 | 306 |
339 session_deps_->socket_factory->AddSocketDataProvider(data); | 307 session_deps_->socket_factory->AddSocketDataProvider(data); |
340 if (test_params_.ssl_type == HTTPS_SPDY_VIA_ALT_SVC) { | |
341 MockConnect hanging_connect(SYNCHRONOUS, ERR_IO_PENDING); | |
342 std::unique_ptr<StaticSocketDataProvider> hanging_non_alt_svc_socket( | |
343 base::WrapUnique(new StaticSocketDataProvider(NULL, 0, NULL, 0))); | |
344 hanging_non_alt_svc_socket->set_connect_data(hanging_connect); | |
345 session_deps_->socket_factory->AddSocketDataProvider( | |
346 hanging_non_alt_svc_socket.get()); | |
347 alternate_vector_.push_back(std::move(hanging_non_alt_svc_socket)); | |
348 } | |
349 } | 308 } |
350 | 309 |
351 void SetSession(std::unique_ptr<HttpNetworkSession> session) { | 310 void SetSession(std::unique_ptr<HttpNetworkSession> session) { |
352 session_ = std::move(session); | 311 session_ = std::move(session); |
353 } | 312 } |
354 HttpNetworkTransaction* trans() { return trans_.get(); } | 313 HttpNetworkTransaction* trans() { return trans_.get(); } |
355 void ResetTrans() { trans_.reset(); } | 314 void ResetTrans() { trans_.reset(); } |
356 TransactionHelperResult& output() { return output_; } | 315 TransactionHelperResult& output() { return output_; } |
357 const HttpRequestInfo& request() const { return request_; } | 316 const HttpRequestInfo& request() const { return request_; } |
358 HttpNetworkSession* session() const { return session_.get(); } | 317 HttpNetworkSession* session() const { return session_.get(); } |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 | 632 |
674 //----------------------------------------------------------------------------- | 633 //----------------------------------------------------------------------------- |
675 // All tests are run with three different connection types: SPDY after NPN | 634 // All tests are run with three different connection types: SPDY after NPN |
676 // negotiation, SPDY without SSL, and SPDY with SSL. | 635 // negotiation, SPDY without SSL, and SPDY with SSL. |
677 // | 636 // |
678 // TODO(akalin): Use ::testing::Combine() when we are able to use | 637 // TODO(akalin): Use ::testing::Combine() when we are able to use |
679 // <tr1/tuple>. | 638 // <tr1/tuple>. |
680 INSTANTIATE_TEST_CASE_P( | 639 INSTANTIATE_TEST_CASE_P( |
681 Spdy, | 640 Spdy, |
682 SpdyNetworkTransactionTest, | 641 SpdyNetworkTransactionTest, |
683 ::testing::Values( | 642 ::testing::Values(SpdyNetworkTransactionTestParams(kProtoSPDY31, false), |
684 SpdyNetworkTransactionTestParams(kProtoSPDY31, | 643 SpdyNetworkTransactionTestParams(kProtoSPDY31, true), |
685 HTTPS_SPDY_VIA_NPN, | 644 SpdyNetworkTransactionTestParams(kProtoHTTP2, false), |
686 false), | 645 SpdyNetworkTransactionTestParams(kProtoHTTP2, true))); |
687 SpdyNetworkTransactionTestParams(kProtoSPDY31, | |
688 HTTPS_SPDY_VIA_ALT_SVC, | |
689 false), | |
690 SpdyNetworkTransactionTestParams(kProtoHTTP2, | |
691 HTTPS_SPDY_VIA_NPN, | |
692 false), | |
693 SpdyNetworkTransactionTestParams(kProtoHTTP2, HTTPS_SPDY_VIA_NPN, true), | |
694 SpdyNetworkTransactionTestParams(kProtoHTTP2, | |
695 HTTPS_SPDY_VIA_ALT_SVC, | |
696 false), | |
697 SpdyNetworkTransactionTestParams(kProtoHTTP2, | |
698 HTTPS_SPDY_VIA_ALT_SVC, | |
699 true))); | |
700 | 646 |
701 // Verify HttpNetworkTransaction constructor. | 647 // Verify HttpNetworkTransaction constructor. |
702 TEST_P(SpdyNetworkTransactionTest, Constructor) { | 648 TEST_P(SpdyNetworkTransactionTest, Constructor) { |
703 std::unique_ptr<SpdySessionDependencies> session_deps( | 649 std::unique_ptr<SpdySessionDependencies> session_deps( |
704 CreateSpdySessionDependencies(GetParam())); | 650 CreateSpdySessionDependencies(GetParam())); |
705 std::unique_ptr<HttpNetworkSession> session( | 651 std::unique_ptr<HttpNetworkSession> session( |
706 SpdySessionDependencies::SpdyCreateSession(session_deps.get())); | 652 SpdySessionDependencies::SpdyCreateSession(session_deps.get())); |
707 std::unique_ptr<HttpTransaction> trans( | 653 std::unique_ptr<HttpTransaction> trans( |
708 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 654 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
709 } | 655 } |
(...skipping 1602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2312 helper.ResetTrans(); | 2258 helper.ResetTrans(); |
2313 base::RunLoop().RunUntilIdle(); | 2259 base::RunLoop().RunUntilIdle(); |
2314 | 2260 |
2315 helper.VerifyDataConsumed(); | 2261 helper.VerifyDataConsumed(); |
2316 } | 2262 } |
2317 | 2263 |
2318 // Verify that the client can correctly deal with the user callback attempting | 2264 // Verify that the client can correctly deal with the user callback attempting |
2319 // to start another transaction on a session that is closing down. See | 2265 // to start another transaction on a session that is closing down. See |
2320 // http://crbug.com/47455 | 2266 // http://crbug.com/47455 |
2321 TEST_P(SpdyNetworkTransactionTest, StartTransactionOnReadCallback) { | 2267 TEST_P(SpdyNetworkTransactionTest, StartTransactionOnReadCallback) { |
2322 if (GetParam().ssl_type != HTTPS_SPDY_VIA_NPN) | |
2323 return; | |
2324 | |
2325 std::unique_ptr<SpdySerializedFrame> req( | 2268 std::unique_ptr<SpdySerializedFrame> req( |
2326 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 2269 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
2327 MockWrite writes[] = {CreateMockWrite(*req)}; | 2270 MockWrite writes[] = {CreateMockWrite(*req)}; |
2328 MockWrite writes2[] = {CreateMockWrite(*req, 0)}; | 2271 MockWrite writes2[] = {CreateMockWrite(*req, 0)}; |
2329 | 2272 |
2330 // The indicated length of this frame is longer than its actual length. When | 2273 // The indicated length of this frame is longer than its actual length. When |
2331 // the session receives an empty frame after this one, it shuts down the | 2274 // the session receives an empty frame after this one, it shuts down the |
2332 // session, and calls the read callback with the incomplete data. | 2275 // session, and calls the read callback with the incomplete data. |
2333 const uint8_t kGetBodyFrame2[] = { | 2276 const uint8_t kGetBodyFrame2[] = { |
2334 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, | 2277 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, |
(...skipping 2168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4503 EXPECT_EQ(ERR_HTTP_1_1_REQUIRED, out.rv); | 4446 EXPECT_EQ(ERR_HTTP_1_1_REQUIRED, out.rv); |
4504 } | 4447 } |
4505 | 4448 |
4506 // Retry with HTTP/1.1 when receiving HTTP_1_1_REQUIRED. Note that no actual | 4449 // Retry with HTTP/1.1 when receiving HTTP_1_1_REQUIRED. Note that no actual |
4507 // protocol negotiation happens, instead this test forces protocols for both | 4450 // protocol negotiation happens, instead this test forces protocols for both |
4508 // sockets. | 4451 // sockets. |
4509 TEST_P(SpdyNetworkTransactionTest, HTTP11RequiredRetry) { | 4452 TEST_P(SpdyNetworkTransactionTest, HTTP11RequiredRetry) { |
4510 // HTTP_1_1_REQUIRED is only supported by HTTP/2. | 4453 // HTTP_1_1_REQUIRED is only supported by HTTP/2. |
4511 if (spdy_util_.spdy_version() < HTTP2) | 4454 if (spdy_util_.spdy_version() < HTTP2) |
4512 return; | 4455 return; |
4513 // HTTP_1_1_REQUIRED implementation relies on the assumption that HTTP/2 is | |
4514 // only spoken over SSL. | |
4515 if (GetParam().ssl_type != HTTPS_SPDY_VIA_NPN) | |
4516 return; | |
4517 | 4456 |
4518 HttpRequestInfo request; | 4457 HttpRequestInfo request; |
4519 request.method = "GET"; | 4458 request.method = "GET"; |
4520 request.url = default_url_; | 4459 request.url = default_url_; |
4521 std::unique_ptr<SpdySessionDependencies> session_deps( | 4460 std::unique_ptr<SpdySessionDependencies> session_deps( |
4522 CreateSpdySessionDependencies(GetParam())); | 4461 CreateSpdySessionDependencies(GetParam())); |
4523 // Do not force SPDY so that second socket can negotiate HTTP/1.1. | 4462 // Do not force SPDY so that second socket can negotiate HTTP/1.1. |
4524 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, BoundNetLog(), | 4463 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, BoundNetLog(), |
4525 GetParam(), std::move(session_deps)); | 4464 GetParam(), std::move(session_deps)); |
4526 | 4465 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4590 EXPECT_EQ("hello", response_data); | 4529 EXPECT_EQ("hello", response_data); |
4591 } | 4530 } |
4592 | 4531 |
4593 // Retry with HTTP/1.1 to the proxy when receiving HTTP_1_1_REQUIRED from the | 4532 // Retry with HTTP/1.1 to the proxy when receiving HTTP_1_1_REQUIRED from the |
4594 // proxy. Note that no actual protocol negotiation happens, instead this test | 4533 // proxy. Note that no actual protocol negotiation happens, instead this test |
4595 // forces protocols for both sockets. | 4534 // forces protocols for both sockets. |
4596 TEST_P(SpdyNetworkTransactionTest, HTTP11RequiredProxyRetry) { | 4535 TEST_P(SpdyNetworkTransactionTest, HTTP11RequiredProxyRetry) { |
4597 // HTTP_1_1_REQUIRED is only supported by HTTP/2. | 4536 // HTTP_1_1_REQUIRED is only supported by HTTP/2. |
4598 if (spdy_util_.spdy_version() < HTTP2) | 4537 if (spdy_util_.spdy_version() < HTTP2) |
4599 return; | 4538 return; |
4600 // HTTP_1_1_REQUIRED implementation relies on the assumption that HTTP/2 is | |
4601 // only spoken over SSL. | |
4602 if (GetParam().ssl_type != HTTPS_SPDY_VIA_NPN) | |
4603 return; | |
4604 | 4539 |
4605 HttpRequestInfo request; | 4540 HttpRequestInfo request; |
4606 request.method = "GET"; | 4541 request.method = "GET"; |
4607 request.url = default_url_; | 4542 request.url = default_url_; |
4608 std::unique_ptr<SpdySessionDependencies> session_deps( | 4543 std::unique_ptr<SpdySessionDependencies> session_deps( |
4609 CreateSpdySessionDependencies( | 4544 CreateSpdySessionDependencies( |
4610 GetParam(), | 4545 GetParam(), |
4611 ProxyService::CreateFixedFromPacResult("HTTPS myproxy:70"))); | 4546 ProxyService::CreateFixedFromPacResult("HTTPS myproxy:70"))); |
4612 // Do not force SPDY so that second socket can negotiate HTTP/1.1. | 4547 // Do not force SPDY so that second socket can negotiate HTTP/1.1. |
4613 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, BoundNetLog(), | 4548 NormalSpdyTransactionHelper helper(request, DEFAULT_PRIORITY, BoundNetLog(), |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4892 EXPECT_EQ("hello!", response_data); | 4827 EXPECT_EQ("hello!", response_data); |
4893 | 4828 |
4894 helper_proxy.VerifyDataConsumed(); | 4829 helper_proxy.VerifyDataConsumed(); |
4895 } | 4830 } |
4896 | 4831 |
4897 // When we get a TCP-level RST, we need to retry a HttpNetworkTransaction | 4832 // When we get a TCP-level RST, we need to retry a HttpNetworkTransaction |
4898 // on a new connection, if the connection was previously known to be good. | 4833 // on a new connection, if the connection was previously known to be good. |
4899 // This can happen when a server reboots without saying goodbye, or when | 4834 // This can happen when a server reboots without saying goodbye, or when |
4900 // we're behind a NAT that masked the RST. | 4835 // we're behind a NAT that masked the RST. |
4901 TEST_P(SpdyNetworkTransactionTest, VerifyRetryOnConnectionReset) { | 4836 TEST_P(SpdyNetworkTransactionTest, VerifyRetryOnConnectionReset) { |
4902 if (GetParam().ssl_type != HTTPS_SPDY_VIA_NPN) | |
4903 return; | |
4904 std::unique_ptr<SpdySerializedFrame> resp( | 4837 std::unique_ptr<SpdySerializedFrame> resp( |
4905 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 4838 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
4906 std::unique_ptr<SpdySerializedFrame> body( | 4839 std::unique_ptr<SpdySerializedFrame> body( |
4907 spdy_util_.ConstructSpdyBodyFrame(1, true)); | 4840 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
4908 MockRead reads[] = { | 4841 MockRead reads[] = { |
4909 CreateMockRead(*resp, 1), | 4842 CreateMockRead(*resp, 1), |
4910 CreateMockRead(*body, 2), | 4843 CreateMockRead(*body, 2), |
4911 MockRead(ASYNC, ERR_IO_PENDING, 3), | 4844 MockRead(ASYNC, ERR_IO_PENDING, 3), |
4912 MockRead(ASYNC, ERR_CONNECTION_RESET, 4), | 4845 MockRead(ASYNC, ERR_CONNECTION_RESET, 4), |
4913 }; | 4846 }; |
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5605 | 5538 |
5606 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 5539 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
5607 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 5540 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
5608 BoundNetLog(), GetParam(), NULL); | 5541 BoundNetLog(), GetParam(), NULL); |
5609 helper.RunToCompletion(&data); | 5542 helper.RunToCompletion(&data); |
5610 TransactionHelperResult out = helper.output(); | 5543 TransactionHelperResult out = helper.output(); |
5611 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv); | 5544 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv); |
5612 } | 5545 } |
5613 | 5546 |
5614 TEST_P(SpdyNetworkTransactionTest, ServerPushCrossOriginCorrectness) { | 5547 TEST_P(SpdyNetworkTransactionTest, ServerPushCrossOriginCorrectness) { |
5615 // Running these tests via Alt-Svc is too complicated to be worthwhile. | |
5616 if (GetParam().ssl_type != HTTPS_SPDY_VIA_NPN) | |
5617 return; | |
5618 | |
5619 // In this test we want to verify that we can't accidentally push content | 5548 // In this test we want to verify that we can't accidentally push content |
5620 // which can't be pushed by this content server. | 5549 // which can't be pushed by this content server. |
5621 // This test assumes that: | 5550 // This test assumes that: |
5622 // - if we're requesting http://www.foo.com/barbaz | 5551 // - if we're requesting http://www.foo.com/barbaz |
5623 // - the browser has made a connection to "www.foo.com". | 5552 // - the browser has made a connection to "www.foo.com". |
5624 | 5553 |
5625 // A list of the URL to fetch, followed by the URL being pushed. | 5554 // A list of the URL to fetch, followed by the URL being pushed. |
5626 static const char* const kTestCases[] = { | 5555 static const char* const kTestCases[] = { |
5627 "https://www.example.org/foo.html", | 5556 "https://www.example.org/foo.html", |
5628 "http://www.example.org/foo.js", // Bad protocol | 5557 "http://www.example.org/foo.js", // Bad protocol |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5814 EXPECT_EQ("HTTP/1.1 200", push_response.headers->GetStatusLine()); | 5743 EXPECT_EQ("HTTP/1.1 200", push_response.headers->GetStatusLine()); |
5815 | 5744 |
5816 std::string result1; | 5745 std::string result1; |
5817 ReadResult(trans1.get(), &result1); | 5746 ReadResult(trans1.get(), &result1); |
5818 EXPECT_EQ(kPushedData, result1); | 5747 EXPECT_EQ(kPushedData, result1); |
5819 } | 5748 } |
5820 | 5749 |
5821 // Verify that push works cross origin, even if there is already a connection | 5750 // Verify that push works cross origin, even if there is already a connection |
5822 // open to origin of pushed resource. | 5751 // open to origin of pushed resource. |
5823 TEST_P(SpdyNetworkTransactionTest, ServerPushValidCrossOriginWithOpenSession) { | 5752 TEST_P(SpdyNetworkTransactionTest, ServerPushValidCrossOriginWithOpenSession) { |
5824 // Running this test via Alt-Svc is too complicated to be worthwhile. | |
5825 if (GetParam().ssl_type != HTTPS_SPDY_VIA_NPN) | |
5826 return; | |
5827 | |
5828 const char* url_to_fetch0 = "https://mail.example.org/foo"; | 5753 const char* url_to_fetch0 = "https://mail.example.org/foo"; |
5829 const char* url_to_fetch1 = "https://docs.example.org"; | 5754 const char* url_to_fetch1 = "https://docs.example.org"; |
5830 const char* url_to_push = "https://mail.example.org/bar"; | 5755 const char* url_to_push = "https://mail.example.org/bar"; |
5831 | 5756 |
5832 SpdyTestUtil spdy_util_0(GetParam().protocol, | 5757 SpdyTestUtil spdy_util_0(GetParam().protocol, |
5833 GetParam().priority_to_dependency); | 5758 GetParam().priority_to_dependency); |
5834 | 5759 |
5835 std::unique_ptr<SpdySerializedFrame> headers0( | 5760 std::unique_ptr<SpdySerializedFrame> headers0( |
5836 spdy_util_0.ConstructSpdyGet(url_to_fetch0, 1, LOWEST)); | 5761 spdy_util_0.ConstructSpdyGet(url_to_fetch0, 1, LOWEST)); |
5837 MockWrite writes0[] = { | 5762 MockWrite writes0[] = { |
(...skipping 1316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7154 NormalSpdyTransactionHelper helper( | 7079 NormalSpdyTransactionHelper helper( |
7155 request, DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL); | 7080 request, DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL); |
7156 helper.RunToCompletionWithSSLData(&data, std::move(ssl_provider)); | 7081 helper.RunToCompletionWithSSLData(&data, std::move(ssl_provider)); |
7157 TransactionHelperResult out = helper.output(); | 7082 TransactionHelperResult out = helper.output(); |
7158 EXPECT_EQ(OK, out.rv); | 7083 EXPECT_EQ(OK, out.rv); |
7159 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 7084 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
7160 EXPECT_EQ("hello!", out.response_data); | 7085 EXPECT_EQ("hello!", out.response_data); |
7161 } | 7086 } |
7162 }; | 7087 }; |
7163 | 7088 |
7164 //----------------------------------------------------------------------------- | |
7165 // All tests are run with three different connection types: SPDY after NPN | |
7166 // negotiation, SPDY without SSL, and SPDY with SSL. | |
7167 // | |
7168 // TODO(akalin): Use ::testing::Combine() when we are able to use | |
7169 // <tr1/tuple>. | |
7170 INSTANTIATE_TEST_CASE_P( | 7089 INSTANTIATE_TEST_CASE_P( |
7171 Spdy, | 7090 Spdy, |
7172 SpdyNetworkTransactionNoTLSUsageCheckTest, | 7091 SpdyNetworkTransactionNoTLSUsageCheckTest, |
7173 ::testing::Values(SpdyNetworkTransactionTestParams(kProtoSPDY31, | 7092 ::testing::Values(SpdyNetworkTransactionTestParams(kProtoSPDY31, |
7174 HTTPS_SPDY_VIA_NPN, | |
7175 false))); | 7093 false))); |
7176 | 7094 |
7177 TEST_P(SpdyNetworkTransactionNoTLSUsageCheckTest, TLSVersionTooOld) { | 7095 TEST_P(SpdyNetworkTransactionNoTLSUsageCheckTest, TLSVersionTooOld) { |
7178 std::unique_ptr<SSLSocketDataProvider> ssl_provider( | 7096 std::unique_ptr<SSLSocketDataProvider> ssl_provider( |
7179 new SSLSocketDataProvider(ASYNC, OK)); | 7097 new SSLSocketDataProvider(ASYNC, OK)); |
7180 SSLConnectionStatusSetVersion(SSL_CONNECTION_VERSION_SSL3, | 7098 SSLConnectionStatusSetVersion(SSL_CONNECTION_VERSION_SSL3, |
7181 &ssl_provider->connection_status); | 7099 &ssl_provider->connection_status); |
7182 | 7100 |
7183 RunNoTLSUsageCheckTest(std::move(ssl_provider)); | 7101 RunNoTLSUsageCheckTest(std::move(ssl_provider)); |
7184 } | 7102 } |
(...skipping 24 matching lines...) Expand all Loading... |
7209 request, DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL); | 7127 request, DEFAULT_PRIORITY, BoundNetLog(), GetParam(), NULL); |
7210 helper.RunToCompletionWithSSLData(&data, std::move(ssl_provider)); | 7128 helper.RunToCompletionWithSSLData(&data, std::move(ssl_provider)); |
7211 TransactionHelperResult out = helper.output(); | 7129 TransactionHelperResult out = helper.output(); |
7212 EXPECT_EQ(ERR_SPDY_INADEQUATE_TRANSPORT_SECURITY, out.rv); | 7130 EXPECT_EQ(ERR_SPDY_INADEQUATE_TRANSPORT_SECURITY, out.rv); |
7213 } | 7131 } |
7214 }; | 7132 }; |
7215 | 7133 |
7216 INSTANTIATE_TEST_CASE_P( | 7134 INSTANTIATE_TEST_CASE_P( |
7217 Spdy, | 7135 Spdy, |
7218 SpdyNetworkTransactionTLSUsageCheckTest, | 7136 SpdyNetworkTransactionTLSUsageCheckTest, |
7219 ::testing::Values(SpdyNetworkTransactionTestParams(kProtoHTTP2, | 7137 ::testing::Values(SpdyNetworkTransactionTestParams(kProtoHTTP2, false), |
7220 HTTPS_SPDY_VIA_NPN, | 7138 SpdyNetworkTransactionTestParams(kProtoHTTP2, true))); |
7221 false), | |
7222 SpdyNetworkTransactionTestParams(kProtoHTTP2, | |
7223 HTTPS_SPDY_VIA_NPN, | |
7224 true))); | |
7225 | 7139 |
7226 TEST_P(SpdyNetworkTransactionTLSUsageCheckTest, TLSVersionTooOld) { | 7140 TEST_P(SpdyNetworkTransactionTLSUsageCheckTest, TLSVersionTooOld) { |
7227 std::unique_ptr<SSLSocketDataProvider> ssl_provider( | 7141 std::unique_ptr<SSLSocketDataProvider> ssl_provider( |
7228 new SSLSocketDataProvider(ASYNC, OK)); | 7142 new SSLSocketDataProvider(ASYNC, OK)); |
7229 SSLConnectionStatusSetVersion(SSL_CONNECTION_VERSION_SSL3, | 7143 SSLConnectionStatusSetVersion(SSL_CONNECTION_VERSION_SSL3, |
7230 &ssl_provider->connection_status); | 7144 &ssl_provider->connection_status); |
7231 | 7145 |
7232 RunTLSUsageCheckTest(std::move(ssl_provider)); | 7146 RunTLSUsageCheckTest(std::move(ssl_provider)); |
7233 } | 7147 } |
7234 | 7148 |
7235 TEST_P(SpdyNetworkTransactionTLSUsageCheckTest, TLSCipherSuiteSucky) { | 7149 TEST_P(SpdyNetworkTransactionTLSUsageCheckTest, TLSCipherSuiteSucky) { |
7236 std::unique_ptr<SSLSocketDataProvider> ssl_provider( | 7150 std::unique_ptr<SSLSocketDataProvider> ssl_provider( |
7237 new SSLSocketDataProvider(ASYNC, OK)); | 7151 new SSLSocketDataProvider(ASYNC, OK)); |
7238 // Set to TLS_RSA_WITH_NULL_MD5 | 7152 // Set to TLS_RSA_WITH_NULL_MD5 |
7239 SSLConnectionStatusSetCipherSuite(0x1, &ssl_provider->connection_status); | 7153 SSLConnectionStatusSetCipherSuite(0x1, &ssl_provider->connection_status); |
7240 | 7154 |
7241 RunTLSUsageCheckTest(std::move(ssl_provider)); | 7155 RunTLSUsageCheckTest(std::move(ssl_provider)); |
7242 } | 7156 } |
7243 | 7157 |
7244 } // namespace net | 7158 } // namespace net |
OLD | NEW |