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

Unified Diff: net/http/http_server_properties_manager_unittest.cc

Issue 737943002: Update from https://crrev.com/304715 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/http/http_server_properties_manager.cc ('k') | net/http/transport_security_state.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_server_properties_manager_unittest.cc
diff --git a/net/http/http_server_properties_manager_unittest.cc b/net/http/http_server_properties_manager_unittest.cc
index db58c920752d1f853a99d8a6e50172741f18e3ac..bb8b68c6e20273b76b04a5920002f7a373c1816b 100644
--- a/net/http/http_server_properties_manager_unittest.cc
+++ b/net/http/http_server_properties_manager_unittest.cc
@@ -241,6 +241,95 @@ TEST_F(HttpServerPropertiesManagerTest,
EXPECT_EQ("bar", supports_quic2.address);
}
+TEST_F(HttpServerPropertiesManagerTest, BadCachedHostPortPair) {
+ ExpectCacheUpdate();
+ // The prefs are automaticalls updated in the case corruption is detected.
+ ExpectPrefsUpdate();
+
+ base::DictionaryValue* server_pref_dict = new base::DictionaryValue;
+
+ // Set supports_spdy for www.google.com:65536.
+ server_pref_dict->SetBoolean("supports_spdy", true);
+
+ // Set up alternate_protocol for www.google.com:65536.
+ base::DictionaryValue* alternate_protocol = new base::DictionaryValue;
+ alternate_protocol->SetInteger("port", 80);
+ alternate_protocol->SetString("protocol_str", "npn-spdy/3");
+ server_pref_dict->SetWithoutPathExpansion("alternate_protocol",
+ alternate_protocol);
+
+ // Set up SupportsQuic for www.google.com:65536.
+ base::DictionaryValue* supports_quic = new base::DictionaryValue;
+ supports_quic->SetBoolean("used_quic", true);
+ supports_quic->SetString("address", "foo");
+ server_pref_dict->SetWithoutPathExpansion("supports_quic", supports_quic);
+
+ // Set the server preference for www.google.com:65536.
+ base::DictionaryValue* servers_dict = new base::DictionaryValue;
+ servers_dict->SetWithoutPathExpansion("www.google.com:65536",
+ server_pref_dict);
+
+ base::DictionaryValue* http_server_properties_dict =
+ new base::DictionaryValue;
+ HttpServerPropertiesManager::SetVersion(http_server_properties_dict, -1);
+ http_server_properties_dict->SetWithoutPathExpansion("servers", servers_dict);
+
+ // Set up the pref.
+ pref_service_.SetManagedPref(kTestHttpServerProperties,
+ http_server_properties_dict);
+
+ base::RunLoop().RunUntilIdle();
+ Mock::VerifyAndClearExpectations(http_server_props_manager_.get());
+
+ // Verify that nothing is set.
+ EXPECT_FALSE(http_server_props_manager_->SupportsSpdy(
+ net::HostPortPair::FromString("www.google.com:65536")));
+ EXPECT_FALSE(http_server_props_manager_->HasAlternateProtocol(
+ net::HostPortPair::FromString("www.google.com:65536")));
+ net::SupportsQuic supports_quic2 =
+ http_server_props_manager_->GetSupportsQuic(
+ net::HostPortPair::FromString("www.google.com:65536"));
+ EXPECT_FALSE(supports_quic2.used_quic);
+}
+
+TEST_F(HttpServerPropertiesManagerTest, BadCachedAltProtocolPort) {
+ ExpectCacheUpdate();
+ // The prefs are automaticalls updated in the case corruption is detected.
+ ExpectPrefsUpdate();
+
+ base::DictionaryValue* server_pref_dict = new base::DictionaryValue;
+
+ // Set supports_spdy for www.google.com:80.
+ server_pref_dict->SetBoolean("supports_spdy", true);
+
+ // Set up alternate_protocol for www.google.com:80.
+ base::DictionaryValue* alternate_protocol = new base::DictionaryValue;
+ alternate_protocol->SetInteger("port", 65536);
+ alternate_protocol->SetString("protocol_str", "npn-spdy/3");
+ server_pref_dict->SetWithoutPathExpansion("alternate_protocol",
+ alternate_protocol);
+
+ // Set the server preference for www.google.com:80.
+ base::DictionaryValue* servers_dict = new base::DictionaryValue;
+ servers_dict->SetWithoutPathExpansion("www.google.com:80", server_pref_dict);
+
+ base::DictionaryValue* http_server_properties_dict =
+ new base::DictionaryValue;
+ HttpServerPropertiesManager::SetVersion(http_server_properties_dict, -1);
+ http_server_properties_dict->SetWithoutPathExpansion("servers", servers_dict);
+
+ // Set up the pref.
+ pref_service_.SetManagedPref(kTestHttpServerProperties,
+ http_server_properties_dict);
+
+ base::RunLoop().RunUntilIdle();
+ Mock::VerifyAndClearExpectations(http_server_props_manager_.get());
+
+ // Verify AlternateProtocol is not set.
+ EXPECT_FALSE(http_server_props_manager_->HasAlternateProtocol(
+ net::HostPortPair::FromString("www.google.com:80")));
+}
+
TEST_F(HttpServerPropertiesManagerTest, SupportsSpdy) {
ExpectPrefsUpdate();
« no previous file with comments | « net/http/http_server_properties_manager.cc ('k') | net/http/transport_security_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698