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

Side by Side Diff: net/url_request/url_request_unittest.cc

Issue 2820573004: Remove the code to store and load QUIC server configs in the disk cache. (Closed)
Patch Set: Fix 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 | « net/quic/chromium/quic_stream_factory_test.cc ('k') | 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 <memory> 5 #include <memory>
6 #include <utility> 6 #include <utility>
7 7
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 7850 matching lines...) Expand 10 before | Expand all | Expand 10 after
7861 RequestPriority job_priority; 7861 RequestPriority job_priority;
7862 std::unique_ptr<URLRequestJob> job(new PriorityMonitoringURLRequestJob( 7862 std::unique_ptr<URLRequestJob> job(new PriorityMonitoringURLRequestJob(
7863 req.get(), &default_network_delegate_, &job_priority)); 7863 req.get(), &default_network_delegate_, &job_priority));
7864 AddTestInterceptor()->set_main_intercept_job(std::move(job)); 7864 AddTestInterceptor()->set_main_intercept_job(std::move(job));
7865 7865
7866 // Should trigger |job| to be started. 7866 // Should trigger |job| to be started.
7867 base::RunLoop().Run(); 7867 base::RunLoop().Run();
7868 EXPECT_EQ(LOW, job_priority); 7868 EXPECT_EQ(LOW, job_priority);
7869 } 7869 }
7870 7870
7871 TEST_F(URLRequestTest, QuicServerInfoFactoryTest) {
7872 HttpNetworkSession::Params params;
7873
7874 MockClientSocketFactory socket_factory;
7875 MockCryptoClientStreamFactory crypto_client_stream_factory;
7876 MockHostResolver host_resolver;
7877 MockCertVerifier cert_verifier;
7878 CTPolicyEnforcer ct_policy_enforcer;
7879 TransportSecurityState transport_security_state;
7880 std::unique_ptr<CTVerifier> cert_transparency_verifier(
7881 new MultiLogCTVerifier());
7882 std::unique_ptr<ProxyService> proxy_service = ProxyService::CreateDirect();
7883 scoped_refptr<SSLConfigServiceDefaults> ssl_config_service(
7884 new SSLConfigServiceDefaults);
7885 HttpServerPropertiesImpl http_server_properties;
7886 // Set up the quic stream factory.
7887 params.enable_quic = true;
7888 params.client_socket_factory = &socket_factory;
7889 params.quic_crypto_client_stream_factory = &crypto_client_stream_factory;
7890 params.host_resolver = &host_resolver;
7891 params.cert_verifier = &cert_verifier;
7892 params.ct_policy_enforcer = &ct_policy_enforcer;
7893 params.transport_security_state = &transport_security_state;
7894 params.cert_transparency_verifier = cert_transparency_verifier.get();
7895
7896 params.proxy_service = proxy_service.get();
7897 params.ssl_config_service = ssl_config_service.get();
7898 params.http_server_properties = &http_server_properties;
7899
7900 HttpNetworkSession session(params);
7901 DCHECK(session.quic_stream_factory());
7902
7903 std::unique_ptr<HttpNetworkLayer> network_layer1(
7904 new HttpNetworkLayer(&session));
7905
7906 HttpCache main_cache(std::move(network_layer1),
7907 HttpCache::DefaultBackend::InMemory(0),
7908 true /* is_main_cache */);
7909
7910 EXPECT_TRUE(session.quic_stream_factory()->has_quic_server_info_factory());
7911
7912 default_context_.set_http_transaction_factory(&main_cache);
7913
7914 QuicServerInfoFactory* quic_server_info_factory =
7915 session.quic_stream_factory()->quic_server_info_factory();
7916 DCHECK(quic_server_info_factory);
7917
7918 QuicServerId server_id("www.google.com", 443, PRIVACY_MODE_DISABLED);
7919 const string server_config_a = "server_config_a";
7920 const string source_address_token_a = "source_address_token_a";
7921 const string cert_sct_a = "cert_sct_a";
7922 const string chlo_hash_a = "chlo_hash_a";
7923 const string server_config_sig_a = "server_config_sig_a";
7924 const string cert_a = "cert_a";
7925 const string cert_b = "cert_b";
7926
7927 {
7928 // Store a QuicServerInfo to the quic server info factory.
7929 TestCompletionCallback cb;
7930 std::unique_ptr<QuicServerInfo> quic_server_info =
7931 quic_server_info_factory->GetForServer(server_id);
7932 quic_server_info->Start();
7933 int rv = quic_server_info->WaitForDataReady(cb.callback());
7934 EXPECT_THAT(cb.GetResult(rv), IsOk());
7935
7936 QuicServerInfo::State* state = quic_server_info->mutable_state();
7937 EXPECT_TRUE(state->certs.empty());
7938
7939 state->server_config = server_config_a;
7940 state->source_address_token = source_address_token_a;
7941 state->cert_sct = cert_sct_a;
7942 state->chlo_hash = chlo_hash_a;
7943 state->server_config_sig = server_config_sig_a;
7944 state->certs.push_back(cert_a);
7945 quic_server_info->Persist();
7946 base::RunLoop().RunUntilIdle();
7947 }
7948
7949 // Retrieve the QuicServerInfo from the quic server info factory and verify
7950 // the data is correct.
7951 {
7952 TestCompletionCallback cb;
7953 std::unique_ptr<QuicServerInfo> quic_server_info =
7954 quic_server_info_factory->GetForServer(server_id);
7955 quic_server_info->Start();
7956 int rv = quic_server_info->WaitForDataReady(cb.callback());
7957 EXPECT_THAT(cb.GetResult(rv), IsOk());
7958
7959 QuicServerInfo::State* state = quic_server_info->mutable_state();
7960 EXPECT_TRUE(quic_server_info->IsDataReady());
7961 EXPECT_EQ(server_config_a, state->server_config);
7962 EXPECT_EQ(source_address_token_a, state->source_address_token);
7963 EXPECT_EQ(cert_sct_a, state->cert_sct);
7964 EXPECT_EQ(chlo_hash_a, state->chlo_hash);
7965 EXPECT_EQ(server_config_sig_a, state->server_config_sig);
7966 EXPECT_EQ(1U, state->certs.size());
7967 EXPECT_EQ(cert_a, state->certs[0]);
7968
7969 // Update the data.
7970 state->certs.push_back(cert_b);
7971 quic_server_info->Persist();
7972 base::RunLoop().RunUntilIdle();
7973 }
7974
7975 {
7976 // Verify data has been successfully updated.
7977 TestCompletionCallback cb;
7978 std::unique_ptr<QuicServerInfo> quic_server_info =
7979 quic_server_info_factory->GetForServer(server_id);
7980 quic_server_info->Start();
7981 int rv = quic_server_info->WaitForDataReady(cb.callback());
7982 EXPECT_THAT(cb.GetResult(rv), IsOk());
7983
7984 QuicServerInfo::State* state = quic_server_info->mutable_state();
7985 EXPECT_TRUE(quic_server_info->IsDataReady());
7986 EXPECT_EQ(2U, state->certs.size());
7987 EXPECT_EQ(cert_a, state->certs[0]);
7988 EXPECT_EQ(cert_b, state->certs[1]);
7989 }
7990 }
7991
7992 // Check that creating a network request while entering/exiting suspend mode 7871 // Check that creating a network request while entering/exiting suspend mode
7993 // fails as it should. This is the only case where an HttpTransactionFactory 7872 // fails as it should. This is the only case where an HttpTransactionFactory
7994 // does not return an HttpTransaction. 7873 // does not return an HttpTransaction.
7995 TEST_F(URLRequestTestHTTP, NetworkSuspendTest) { 7874 TEST_F(URLRequestTestHTTP, NetworkSuspendTest) {
7996 // Create a new HttpNetworkLayer that thinks it's suspended. 7875 // Create a new HttpNetworkLayer that thinks it's suspended.
7997 std::unique_ptr<HttpNetworkLayer> network_layer(new HttpNetworkLayer( 7876 std::unique_ptr<HttpNetworkLayer> network_layer(new HttpNetworkLayer(
7998 default_context_.http_transaction_factory()->GetSession())); 7877 default_context_.http_transaction_factory()->GetSession()));
7999 network_layer->OnSuspend(); 7878 network_layer->OnSuspend();
8000 7879
8001 HttpCache http_cache(std::move(network_layer), 7880 HttpCache http_cache(std::move(network_layer),
(...skipping 3047 matching lines...) Expand 10 before | Expand all | Expand 10 after
11049 AddTestInterceptor()->set_main_intercept_job(std::move(job)); 10928 AddTestInterceptor()->set_main_intercept_job(std::move(job));
11050 10929
11051 req->Start(); 10930 req->Start();
11052 req->Cancel(); 10931 req->Cancel();
11053 base::RunLoop().RunUntilIdle(); 10932 base::RunLoop().RunUntilIdle();
11054 EXPECT_EQ(ERR_ABORTED, d.request_status()); 10933 EXPECT_EQ(ERR_ABORTED, d.request_status());
11055 EXPECT_EQ(0, d.received_redirect_count()); 10934 EXPECT_EQ(0, d.received_redirect_count());
11056 } 10935 }
11057 10936
11058 } // namespace net 10937 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/chromium/quic_stream_factory_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698