| 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 <string> | 5 #include <string> |
| 6 #include <utility> | 6 #include <utility> |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 4209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4220 DATA_FLAG_NONE // Data Flags | 4220 DATA_FLAG_NONE // Data Flags |
| 4221 }; | 4221 }; |
| 4222 | 4222 |
| 4223 BoundNetLog net_log; | 4223 BoundNetLog net_log; |
| 4224 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, | 4224 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, |
| 4225 net_log, GetParam(), NULL); | 4225 net_log, GetParam(), NULL); |
| 4226 helper.RunPreTestSetup(); | 4226 helper.RunPreTestSetup(); |
| 4227 | 4227 |
| 4228 // Verify that no settings exist initially. | 4228 // Verify that no settings exist initially. |
| 4229 HostPortPair host_port_pair("www.example.org", helper.port()); | 4229 HostPortPair host_port_pair("www.example.org", helper.port()); |
| 4230 url::SchemeHostPort spdy_server("https", host_port_pair.host(), |
| 4231 host_port_pair.port()); |
| 4232 |
| 4230 SpdySessionPool* spdy_session_pool = helper.session()->spdy_session_pool(); | 4233 SpdySessionPool* spdy_session_pool = helper.session()->spdy_session_pool(); |
| 4231 EXPECT_TRUE(spdy_session_pool->http_server_properties()->GetSpdySettings( | 4234 EXPECT_TRUE(spdy_session_pool->http_server_properties()->GetSpdySettings( |
| 4232 host_port_pair).empty()); | 4235 spdy_server).empty()); |
| 4233 | 4236 |
| 4234 // Construct the request. | 4237 // Construct the request. |
| 4235 scoped_ptr<SpdySerializedFrame> req( | 4238 scoped_ptr<SpdySerializedFrame> req( |
| 4236 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 4239 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
| 4237 MockWrite writes[] = {CreateMockWrite(*req, 0)}; | 4240 MockWrite writes[] = {CreateMockWrite(*req, 0)}; |
| 4238 | 4241 |
| 4239 // Construct the reply. | 4242 // Construct the reply. |
| 4240 scoped_ptr<SpdyHeaderBlock> reply_headers(new SpdyHeaderBlock()); | 4243 scoped_ptr<SpdyHeaderBlock> reply_headers(new SpdyHeaderBlock()); |
| 4241 (*reply_headers)[spdy_util_.GetStatusKey()] = "200"; | 4244 (*reply_headers)[spdy_util_.GetStatusKey()] = "200"; |
| 4242 (*reply_headers)[spdy_util_.GetVersionKey()] = "HTTP/1.1"; | 4245 (*reply_headers)[spdy_util_.GetVersionKey()] = "HTTP/1.1"; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4280 helper.VerifyDataConsumed(); | 4283 helper.VerifyDataConsumed(); |
| 4281 TransactionHelperResult out = helper.output(); | 4284 TransactionHelperResult out = helper.output(); |
| 4282 EXPECT_EQ(OK, out.rv); | 4285 EXPECT_EQ(OK, out.rv); |
| 4283 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 4286 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
| 4284 EXPECT_EQ("hello!", out.response_data); | 4287 EXPECT_EQ("hello!", out.response_data); |
| 4285 | 4288 |
| 4286 { | 4289 { |
| 4287 // Verify we had two persisted settings. | 4290 // Verify we had two persisted settings. |
| 4288 const SettingsMap& settings_map = | 4291 const SettingsMap& settings_map = |
| 4289 spdy_session_pool->http_server_properties()->GetSpdySettings( | 4292 spdy_session_pool->http_server_properties()->GetSpdySettings( |
| 4290 host_port_pair); | 4293 spdy_server); |
| 4291 ASSERT_EQ(2u, settings_map.size()); | 4294 ASSERT_EQ(2u, settings_map.size()); |
| 4292 | 4295 |
| 4293 // Verify the first persisted setting. | 4296 // Verify the first persisted setting. |
| 4294 SettingsMap::const_iterator it1 = settings_map.find(kSampleId1); | 4297 SettingsMap::const_iterator it1 = settings_map.find(kSampleId1); |
| 4295 EXPECT_TRUE(it1 != settings_map.end()); | 4298 EXPECT_TRUE(it1 != settings_map.end()); |
| 4296 SettingsFlagsAndValue flags_and_value1 = it1->second; | 4299 SettingsFlagsAndValue flags_and_value1 = it1->second; |
| 4297 EXPECT_EQ(SETTINGS_FLAG_PERSISTED, flags_and_value1.first); | 4300 EXPECT_EQ(SETTINGS_FLAG_PERSISTED, flags_and_value1.first); |
| 4298 EXPECT_EQ(kSampleValue1, flags_and_value1.second); | 4301 EXPECT_EQ(kSampleValue1, flags_and_value1.second); |
| 4299 | 4302 |
| 4300 // Verify the second persisted setting. | 4303 // Verify the second persisted setting. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 4331 net_log, GetParam(), NULL); | 4334 net_log, GetParam(), NULL); |
| 4332 helper.RunPreTestSetup(); | 4335 helper.RunPreTestSetup(); |
| 4333 | 4336 |
| 4334 SpdySessionPool* spdy_session_pool = helper.session()->spdy_session_pool(); | 4337 SpdySessionPool* spdy_session_pool = helper.session()->spdy_session_pool(); |
| 4335 | 4338 |
| 4336 SpdySessionPoolPeer pool_peer(spdy_session_pool); | 4339 SpdySessionPoolPeer pool_peer(spdy_session_pool); |
| 4337 pool_peer.SetEnableSendingInitialData(true); | 4340 pool_peer.SetEnableSendingInitialData(true); |
| 4338 | 4341 |
| 4339 // Verify that no settings exist initially. | 4342 // Verify that no settings exist initially. |
| 4340 HostPortPair host_port_pair("www.example.org", helper.port()); | 4343 HostPortPair host_port_pair("www.example.org", helper.port()); |
| 4344 url::SchemeHostPort spdy_server("https", host_port_pair.host(), |
| 4345 host_port_pair.port()); |
| 4341 EXPECT_TRUE(spdy_session_pool->http_server_properties()->GetSpdySettings( | 4346 EXPECT_TRUE(spdy_session_pool->http_server_properties()->GetSpdySettings( |
| 4342 host_port_pair).empty()); | 4347 spdy_server).empty()); |
| 4343 | 4348 |
| 4344 const SpdySettingsIds kSampleId1 = SETTINGS_MAX_CONCURRENT_STREAMS; | 4349 const SpdySettingsIds kSampleId1 = SETTINGS_MAX_CONCURRENT_STREAMS; |
| 4345 unsigned int kSampleValue1 = 0x0a0a0a0a; | 4350 unsigned int kSampleValue1 = 0x0a0a0a0a; |
| 4346 const SpdySettingsIds kSampleId2 = SETTINGS_INITIAL_WINDOW_SIZE; | 4351 const SpdySettingsIds kSampleId2 = SETTINGS_INITIAL_WINDOW_SIZE; |
| 4347 unsigned int kSampleValue2 = 0x0c0c0c0c; | 4352 unsigned int kSampleValue2 = 0x0c0c0c0c; |
| 4348 | 4353 |
| 4349 // First add a persisted setting. | 4354 // First add a persisted setting. |
| 4350 spdy_session_pool->http_server_properties()->SetSpdySetting( | 4355 spdy_session_pool->http_server_properties()->SetSpdySetting( |
| 4351 host_port_pair, | 4356 spdy_server, |
| 4352 kSampleId1, | 4357 kSampleId1, |
| 4353 SETTINGS_FLAG_PLEASE_PERSIST, | 4358 SETTINGS_FLAG_PLEASE_PERSIST, |
| 4354 kSampleValue1); | 4359 kSampleValue1); |
| 4355 | 4360 |
| 4356 // Next add another persisted setting. | 4361 // Next add another persisted setting. |
| 4357 spdy_session_pool->http_server_properties()->SetSpdySetting( | 4362 spdy_session_pool->http_server_properties()->SetSpdySetting( |
| 4358 host_port_pair, | 4363 spdy_server, |
| 4359 kSampleId2, | 4364 kSampleId2, |
| 4360 SETTINGS_FLAG_PLEASE_PERSIST, | 4365 SETTINGS_FLAG_PLEASE_PERSIST, |
| 4361 kSampleValue2); | 4366 kSampleValue2); |
| 4362 | 4367 |
| 4363 EXPECT_EQ(2u, spdy_session_pool->http_server_properties()->GetSpdySettings( | 4368 EXPECT_EQ(2u, spdy_session_pool->http_server_properties()->GetSpdySettings( |
| 4364 host_port_pair).size()); | 4369 spdy_server).size()); |
| 4365 | 4370 |
| 4366 // Construct the initial SETTINGS frame. | 4371 // Construct the initial SETTINGS frame. |
| 4367 SettingsMap initial_settings; | 4372 SettingsMap initial_settings; |
| 4368 initial_settings[SETTINGS_MAX_CONCURRENT_STREAMS] = | 4373 initial_settings[SETTINGS_MAX_CONCURRENT_STREAMS] = |
| 4369 SettingsFlagsAndValue(SETTINGS_FLAG_NONE, kMaxConcurrentPushedStreams); | 4374 SettingsFlagsAndValue(SETTINGS_FLAG_NONE, kMaxConcurrentPushedStreams); |
| 4370 scoped_ptr<SpdySerializedFrame> initial_settings_frame( | 4375 scoped_ptr<SpdySerializedFrame> initial_settings_frame( |
| 4371 spdy_util_.ConstructSpdySettings(initial_settings)); | 4376 spdy_util_.ConstructSpdySettings(initial_settings)); |
| 4372 | 4377 |
| 4373 // Construct the persisted SETTINGS frame. | 4378 // Construct the persisted SETTINGS frame. |
| 4374 const SettingsMap& settings = | 4379 const SettingsMap& settings = |
| 4375 spdy_session_pool->http_server_properties()->GetSpdySettings( | 4380 spdy_session_pool->http_server_properties()->GetSpdySettings(spdy_server); |
| 4376 host_port_pair); | |
| 4377 scoped_ptr<SpdySerializedFrame> settings_frame( | 4381 scoped_ptr<SpdySerializedFrame> settings_frame( |
| 4378 spdy_util_.ConstructSpdySettings(settings)); | 4382 spdy_util_.ConstructSpdySettings(settings)); |
| 4379 | 4383 |
| 4380 // Construct the request. | 4384 // Construct the request. |
| 4381 scoped_ptr<SpdySerializedFrame> req( | 4385 scoped_ptr<SpdySerializedFrame> req( |
| 4382 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 4386 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
| 4383 | 4387 |
| 4384 MockWrite writes[] = { | 4388 MockWrite writes[] = { |
| 4385 CreateMockWrite(*initial_settings_frame, 0), | 4389 CreateMockWrite(*initial_settings_frame, 0), |
| 4386 CreateMockWrite(*settings_frame, 1), | 4390 CreateMockWrite(*settings_frame, 1), |
| (...skipping 21 matching lines...) Expand all Loading... |
| 4408 helper.VerifyDataConsumed(); | 4412 helper.VerifyDataConsumed(); |
| 4409 TransactionHelperResult out = helper.output(); | 4413 TransactionHelperResult out = helper.output(); |
| 4410 EXPECT_EQ(OK, out.rv); | 4414 EXPECT_EQ(OK, out.rv); |
| 4411 EXPECT_EQ("HTTP/1.1 200", out.status_line); | 4415 EXPECT_EQ("HTTP/1.1 200", out.status_line); |
| 4412 EXPECT_EQ("hello!", out.response_data); | 4416 EXPECT_EQ("hello!", out.response_data); |
| 4413 | 4417 |
| 4414 { | 4418 { |
| 4415 // Verify we had two persisted settings. | 4419 // Verify we had two persisted settings. |
| 4416 const SettingsMap& settings_map = | 4420 const SettingsMap& settings_map = |
| 4417 spdy_session_pool->http_server_properties()->GetSpdySettings( | 4421 spdy_session_pool->http_server_properties()->GetSpdySettings( |
| 4418 host_port_pair); | 4422 spdy_server); |
| 4419 ASSERT_EQ(2u, settings_map.size()); | 4423 ASSERT_EQ(2u, settings_map.size()); |
| 4420 | 4424 |
| 4421 // Verify the first persisted setting. | 4425 // Verify the first persisted setting. |
| 4422 SettingsMap::const_iterator it1 = settings_map.find(kSampleId1); | 4426 SettingsMap::const_iterator it1 = settings_map.find(kSampleId1); |
| 4423 EXPECT_TRUE(it1 != settings_map.end()); | 4427 EXPECT_TRUE(it1 != settings_map.end()); |
| 4424 SettingsFlagsAndValue flags_and_value1 = it1->second; | 4428 SettingsFlagsAndValue flags_and_value1 = it1->second; |
| 4425 EXPECT_EQ(SETTINGS_FLAG_PERSISTED, flags_and_value1.first); | 4429 EXPECT_EQ(SETTINGS_FLAG_PERSISTED, flags_and_value1.first); |
| 4426 EXPECT_EQ(kSampleValue1, flags_and_value1.second); | 4430 EXPECT_EQ(kSampleValue1, flags_and_value1.second); |
| 4427 | 4431 |
| 4428 // Verify the second persisted setting. | 4432 // Verify the second persisted setting. |
| (...skipping 2686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7115 TEST_P(SpdyNetworkTransactionTLSUsageCheckTest, TLSCipherSuiteSucky) { | 7119 TEST_P(SpdyNetworkTransactionTLSUsageCheckTest, TLSCipherSuiteSucky) { |
| 7116 scoped_ptr<SSLSocketDataProvider> ssl_provider( | 7120 scoped_ptr<SSLSocketDataProvider> ssl_provider( |
| 7117 new SSLSocketDataProvider(ASYNC, OK)); | 7121 new SSLSocketDataProvider(ASYNC, OK)); |
| 7118 // Set to TLS_RSA_WITH_NULL_MD5 | 7122 // Set to TLS_RSA_WITH_NULL_MD5 |
| 7119 SSLConnectionStatusSetCipherSuite(0x1, &ssl_provider->connection_status); | 7123 SSLConnectionStatusSetCipherSuite(0x1, &ssl_provider->connection_status); |
| 7120 | 7124 |
| 7121 RunTLSUsageCheckTest(std::move(ssl_provider)); | 7125 RunTLSUsageCheckTest(std::move(ssl_provider)); |
| 7122 } | 7126 } |
| 7123 | 7127 |
| 7124 } // namespace net | 7128 } // namespace net |
| OLD | NEW |