| 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 <memory> | 5 #include <memory> |
| 6 #include <string> | 6 #include <string> |
| 7 #include <utility> | 7 #include <utility> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 bool priority_to_dependency; | 103 bool priority_to_dependency; |
| 104 }; | 104 }; |
| 105 | 105 |
| 106 void UpdateSpdySessionDependencies(SpdyNetworkTransactionTestParams test_params, | 106 void UpdateSpdySessionDependencies(SpdyNetworkTransactionTestParams test_params, |
| 107 SpdySessionDependencies* session_deps) { | 107 SpdySessionDependencies* session_deps) { |
| 108 session_deps->parse_alternative_services = true; | 108 session_deps->parse_alternative_services = true; |
| 109 session_deps->enable_alternative_service_with_different_host = true; | 109 session_deps->enable_alternative_service_with_different_host = true; |
| 110 if (test_params.ssl_type == HTTP_SPDY_VIA_ALT_SVC) { | 110 if (test_params.ssl_type == HTTP_SPDY_VIA_ALT_SVC) { |
| 111 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); | 111 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); |
| 112 session_deps->http_server_properties.SetAlternativeService( | 112 session_deps->http_server_properties.SetAlternativeService( |
| 113 HostPortPair("www.example.org", 80), | 113 url::SchemeHostPort("http", "www.example.org", 80), |
| 114 AlternativeService(AlternateProtocolFromNextProto(test_params.protocol), | 114 AlternativeService(AlternateProtocolFromNextProto(test_params.protocol), |
| 115 "www.example.org", 443), | 115 "www.example.org", 443), |
| 116 expiration); | 116 expiration); |
| 117 } | 117 } |
| 118 session_deps->enable_priority_dependencies = | 118 session_deps->enable_priority_dependencies = |
| 119 test_params.priority_to_dependency; | 119 test_params.priority_to_dependency; |
| 120 } | 120 } |
| 121 | 121 |
| 122 std::unique_ptr<SpdySessionDependencies> CreateSpdySessionDependencies( | 122 std::unique_ptr<SpdySessionDependencies> CreateSpdySessionDependencies( |
| 123 SpdyNetworkTransactionTestParams test_params) { | 123 SpdyNetworkTransactionTestParams test_params) { |
| (...skipping 4099 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4223 DATA_FLAG_NONE // Data Flags | 4223 DATA_FLAG_NONE // Data Flags |
| 4224 }; | 4224 }; |
| 4225 | 4225 |
| 4226 BoundNetLog net_log; | 4226 BoundNetLog net_log; |
| 4227 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 4227 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 4228 net_log, GetParam(), NULL); | 4228 net_log, GetParam(), NULL); |
| 4229 helper.RunPreTestSetup(); | 4229 helper.RunPreTestSetup(); |
| 4230 | 4230 |
| 4231 // Verify that no settings exist initially. | 4231 // Verify that no settings exist initially. |
| 4232 HostPortPair host_port_pair("www.example.org", helper.port()); | 4232 HostPortPair host_port_pair("www.example.org", helper.port()); |
| 4233 url::SchemeHostPort spdy_server("https", host_port_pair.host(), |
| 4234 host_port_pair.port()); |
| 4235 |
| 4233 SpdySessionPool* spdy_session_pool = helper.session()->spdy_session_pool(); | 4236 SpdySessionPool* spdy_session_pool = helper.session()->spdy_session_pool(); |
| 4234 EXPECT_TRUE(spdy_session_pool->http_server_properties()->GetSpdySettings( | 4237 EXPECT_TRUE(spdy_session_pool->http_server_properties() |
| 4235 host_port_pair).empty()); | 4238 ->GetSpdySettings(spdy_server) |
| 4239 .empty()); |
| 4236 | 4240 |
| 4237 // Construct the request. | 4241 // Construct the request. |
| 4238 std::unique_ptr<SpdySerializedFrame> req( | 4242 std::unique_ptr<SpdySerializedFrame> req( |
| 4239 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 4243 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
| 4240 MockWrite writes[] = {CreateMockWrite(*req, 0)}; | 4244 MockWrite writes[] = {CreateMockWrite(*req, 0)}; |
| 4241 | 4245 |
| 4242 // Construct the reply. | 4246 // Construct the reply. |
| 4243 std::unique_ptr<SpdyHeaderBlock> reply_headers(new SpdyHeaderBlock()); | 4247 std::unique_ptr<SpdyHeaderBlock> reply_headers(new SpdyHeaderBlock()); |
| 4244 (*reply_headers)[spdy_util_.GetStatusKey()] = "200"; | 4248 (*reply_headers)[spdy_util_.GetStatusKey()] = "200"; |
| 4245 (*reply_headers)[spdy_util_.GetVersionKey()] = "HTTP/1.1"; | 4249 (*reply_headers)[spdy_util_.GetVersionKey()] = "HTTP/1.1"; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4283 helper.VerifyDataConsumed(); | 4287 helper.VerifyDataConsumed(); |
| 4284 TransactionHelperResult out = helper.output(); | 4288 TransactionHelperResult out = helper.output(); |
| 4285 EXPECT_EQ(OK, out.rv); | 4289 EXPECT_EQ(OK, out.rv); |
| 4286 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 4290 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
| 4287 EXPECT_EQ("hello!", out.response_data); | 4291 EXPECT_EQ("hello!", out.response_data); |
| 4288 | 4292 |
| 4289 { | 4293 { |
| 4290 // Verify we had two persisted settings. | 4294 // Verify we had two persisted settings. |
| 4291 const SettingsMap& settings_map = | 4295 const SettingsMap& settings_map = |
| 4292 spdy_session_pool->http_server_properties()->GetSpdySettings( | 4296 spdy_session_pool->http_server_properties()->GetSpdySettings( |
| 4293 host_port_pair); | 4297 spdy_server); |
| 4294 ASSERT_EQ(2u, settings_map.size()); | 4298 ASSERT_EQ(2u, settings_map.size()); |
| 4295 | 4299 |
| 4296 // Verify the first persisted setting. | 4300 // Verify the first persisted setting. |
| 4297 SettingsMap::const_iterator it1 = settings_map.find(kSampleId1); | 4301 SettingsMap::const_iterator it1 = settings_map.find(kSampleId1); |
| 4298 EXPECT_TRUE(it1 != settings_map.end()); | 4302 EXPECT_TRUE(it1 != settings_map.end()); |
| 4299 SettingsFlagsAndValue flags_and_value1 = it1->second; | 4303 SettingsFlagsAndValue flags_and_value1 = it1->second; |
| 4300 EXPECT_EQ(SETTINGS_FLAG_PERSISTED, flags_and_value1.first); | 4304 EXPECT_EQ(SETTINGS_FLAG_PERSISTED, flags_and_value1.first); |
| 4301 EXPECT_EQ(kSampleValue1, flags_and_value1.second); | 4305 EXPECT_EQ(kSampleValue1, flags_and_value1.second); |
| 4302 | 4306 |
| 4303 // Verify the second persisted setting. | 4307 // Verify the second persisted setting. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 4334 net_log, GetParam(), NULL); | 4338 net_log, GetParam(), NULL); |
| 4335 helper.RunPreTestSetup(); | 4339 helper.RunPreTestSetup(); |
| 4336 | 4340 |
| 4337 SpdySessionPool* spdy_session_pool = helper.session()->spdy_session_pool(); | 4341 SpdySessionPool* spdy_session_pool = helper.session()->spdy_session_pool(); |
| 4338 | 4342 |
| 4339 SpdySessionPoolPeer pool_peer(spdy_session_pool); | 4343 SpdySessionPoolPeer pool_peer(spdy_session_pool); |
| 4340 pool_peer.SetEnableSendingInitialData(true); | 4344 pool_peer.SetEnableSendingInitialData(true); |
| 4341 | 4345 |
| 4342 // Verify that no settings exist initially. | 4346 // Verify that no settings exist initially. |
| 4343 HostPortPair host_port_pair("www.example.org", helper.port()); | 4347 HostPortPair host_port_pair("www.example.org", helper.port()); |
| 4344 EXPECT_TRUE(spdy_session_pool->http_server_properties()->GetSpdySettings( | 4348 url::SchemeHostPort spdy_server("https", host_port_pair.host(), |
| 4345 host_port_pair).empty()); | 4349 host_port_pair.port()); |
| 4350 EXPECT_TRUE(spdy_session_pool->http_server_properties() |
| 4351 ->GetSpdySettings(spdy_server) |
| 4352 .empty()); |
| 4346 | 4353 |
| 4347 const SpdySettingsIds kSampleId1 = SETTINGS_MAX_CONCURRENT_STREAMS; | 4354 const SpdySettingsIds kSampleId1 = SETTINGS_MAX_CONCURRENT_STREAMS; |
| 4348 unsigned int kSampleValue1 = 0x0a0a0a0a; | 4355 unsigned int kSampleValue1 = 0x0a0a0a0a; |
| 4349 const SpdySettingsIds kSampleId2 = SETTINGS_INITIAL_WINDOW_SIZE; | 4356 const SpdySettingsIds kSampleId2 = SETTINGS_INITIAL_WINDOW_SIZE; |
| 4350 unsigned int kSampleValue2 = 0x0c0c0c0c; | 4357 unsigned int kSampleValue2 = 0x0c0c0c0c; |
| 4351 | 4358 |
| 4352 // First add a persisted setting. | 4359 // First add a persisted setting. |
| 4353 spdy_session_pool->http_server_properties()->SetSpdySetting( | 4360 spdy_session_pool->http_server_properties()->SetSpdySetting( |
| 4354 host_port_pair, | 4361 spdy_server, kSampleId1, SETTINGS_FLAG_PLEASE_PERSIST, kSampleValue1); |
| 4355 kSampleId1, | |
| 4356 SETTINGS_FLAG_PLEASE_PERSIST, | |
| 4357 kSampleValue1); | |
| 4358 | 4362 |
| 4359 // Next add another persisted setting. | 4363 // Next add another persisted setting. |
| 4360 spdy_session_pool->http_server_properties()->SetSpdySetting( | 4364 spdy_session_pool->http_server_properties()->SetSpdySetting( |
| 4361 host_port_pair, | 4365 spdy_server, kSampleId2, SETTINGS_FLAG_PLEASE_PERSIST, kSampleValue2); |
| 4362 kSampleId2, | |
| 4363 SETTINGS_FLAG_PLEASE_PERSIST, | |
| 4364 kSampleValue2); | |
| 4365 | 4366 |
| 4366 EXPECT_EQ(2u, spdy_session_pool->http_server_properties()->GetSpdySettings( | 4367 EXPECT_EQ(2u, spdy_session_pool->http_server_properties() |
| 4367 host_port_pair).size()); | 4368 ->GetSpdySettings(spdy_server) |
| 4369 .size()); |
| 4368 | 4370 |
| 4369 // Construct the initial SETTINGS frame. | 4371 // Construct the initial SETTINGS frame. |
| 4370 SettingsMap initial_settings; | 4372 SettingsMap initial_settings; |
| 4371 initial_settings[SETTINGS_MAX_CONCURRENT_STREAMS] = | 4373 initial_settings[SETTINGS_MAX_CONCURRENT_STREAMS] = |
| 4372 SettingsFlagsAndValue(SETTINGS_FLAG_NONE, kMaxConcurrentPushedStreams); | 4374 SettingsFlagsAndValue(SETTINGS_FLAG_NONE, kMaxConcurrentPushedStreams); |
| 4373 std::unique_ptr<SpdySerializedFrame> initial_settings_frame( | 4375 std::unique_ptr<SpdySerializedFrame> initial_settings_frame( |
| 4374 spdy_util_.ConstructSpdySettings(initial_settings)); | 4376 spdy_util_.ConstructSpdySettings(initial_settings)); |
| 4375 | 4377 |
| 4376 // Construct the persisted SETTINGS frame. | 4378 // Construct the persisted SETTINGS frame. |
| 4377 const SettingsMap& settings = | 4379 const SettingsMap& settings = |
| 4378 spdy_session_pool->http_server_properties()->GetSpdySettings( | 4380 spdy_session_pool->http_server_properties()->GetSpdySettings(spdy_server); |
| 4379 host_port_pair); | |
| 4380 std::unique_ptr<SpdySerializedFrame> settings_frame( | 4381 std::unique_ptr<SpdySerializedFrame> settings_frame( |
| 4381 spdy_util_.ConstructSpdySettings(settings)); | 4382 spdy_util_.ConstructSpdySettings(settings)); |
| 4382 | 4383 |
| 4383 // Construct the request. | 4384 // Construct the request. |
| 4384 std::unique_ptr<SpdySerializedFrame> req( | 4385 std::unique_ptr<SpdySerializedFrame> req( |
| 4385 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 4386 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
| 4386 | 4387 |
| 4387 MockWrite writes[] = { | 4388 MockWrite writes[] = { |
| 4388 CreateMockWrite(*initial_settings_frame, 0), | 4389 CreateMockWrite(*initial_settings_frame, 0), |
| 4389 CreateMockWrite(*settings_frame, 1), | 4390 CreateMockWrite(*settings_frame, 1), |
| (...skipping 21 matching lines...) Expand all Loading... |
| 4411 helper.VerifyDataConsumed(); | 4412 helper.VerifyDataConsumed(); |
| 4412 TransactionHelperResult out = helper.output(); | 4413 TransactionHelperResult out = helper.output(); |
| 4413 EXPECT_EQ(OK, out.rv); | 4414 EXPECT_EQ(OK, out.rv); |
| 4414 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 4415 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
| 4415 EXPECT_EQ("hello!", out.response_data); | 4416 EXPECT_EQ("hello!", out.response_data); |
| 4416 | 4417 |
| 4417 { | 4418 { |
| 4418 // Verify we had two persisted settings. | 4419 // Verify we had two persisted settings. |
| 4419 const SettingsMap& settings_map = | 4420 const SettingsMap& settings_map = |
| 4420 spdy_session_pool->http_server_properties()->GetSpdySettings( | 4421 spdy_session_pool->http_server_properties()->GetSpdySettings( |
| 4421 host_port_pair); | 4422 spdy_server); |
| 4422 ASSERT_EQ(2u, settings_map.size()); | 4423 ASSERT_EQ(2u, settings_map.size()); |
| 4423 | 4424 |
| 4424 // Verify the first persisted setting. | 4425 // Verify the first persisted setting. |
| 4425 SettingsMap::const_iterator it1 = settings_map.find(kSampleId1); | 4426 SettingsMap::const_iterator it1 = settings_map.find(kSampleId1); |
| 4426 EXPECT_TRUE(it1 != settings_map.end()); | 4427 EXPECT_TRUE(it1 != settings_map.end()); |
| 4427 SettingsFlagsAndValue flags_and_value1 = it1->second; | 4428 SettingsFlagsAndValue flags_and_value1 = it1->second; |
| 4428 EXPECT_EQ(SETTINGS_FLAG_PERSISTED, flags_and_value1.first); | 4429 EXPECT_EQ(SETTINGS_FLAG_PERSISTED, flags_and_value1.first); |
| 4429 EXPECT_EQ(kSampleValue1, flags_and_value1.second); | 4430 EXPECT_EQ(kSampleValue1, flags_and_value1.second); |
| 4430 | 4431 |
| 4431 // Verify the second persisted setting. | 4432 // Verify the second persisted setting. |
| (...skipping 2693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7125 TEST_P(SpdyNetworkTransactionTLSUsageCheckTest, TLSCipherSuiteSucky) { | 7126 TEST_P(SpdyNetworkTransactionTLSUsageCheckTest, TLSCipherSuiteSucky) { |
| 7126 std::unique_ptr<SSLSocketDataProvider> ssl_provider( | 7127 std::unique_ptr<SSLSocketDataProvider> ssl_provider( |
| 7127 new SSLSocketDataProvider(ASYNC, OK)); | 7128 new SSLSocketDataProvider(ASYNC, OK)); |
| 7128 // Set to TLS_RSA_WITH_NULL_MD5 | 7129 // Set to TLS_RSA_WITH_NULL_MD5 |
| 7129 SSLConnectionStatusSetCipherSuite(0x1, &ssl_provider->connection_status); | 7130 SSLConnectionStatusSetCipherSuite(0x1, &ssl_provider->connection_status); |
| 7130 | 7131 |
| 7131 RunTLSUsageCheckTest(std::move(ssl_provider)); | 7132 RunTLSUsageCheckTest(std::move(ssl_provider)); |
| 7132 } | 7133 } |
| 7133 | 7134 |
| 7134 } // namespace net | 7135 } // namespace net |
| OLD | NEW |