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

Unified Diff: net/base/sdch_manager_unittest.cc

Issue 574283006: Fix dictionary domain check problem. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed glitch from self-review. Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/base/sdch_manager.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/sdch_manager_unittest.cc
diff --git a/net/base/sdch_manager_unittest.cc b/net/base/sdch_manager_unittest.cc
index 83418adde7dc782bef8702fb9744fcbeb6bd2abd..a01e71eb040e12a15ca753b7752d75927990fd99 100644
--- a/net/base/sdch_manager_unittest.cc
+++ b/net/base/sdch_manager_unittest.cc
@@ -278,6 +278,15 @@ TEST_F(SdchManagerTest, FailToSetDotHostPrefixDomainDictionary) {
GURL("http://w.x.y.z.google.com")));
}
+TEST_F(SdchManagerTest, FailToSetDotHostPrefixDomainDictionaryTrailingDot) {
+ std::string dictionary_domain("x.y.z.google.com");
+ std::string dictionary_text(NewSdchDictionary(dictionary_domain));
+
+ // Fail the HD with D being the domain and H having a dot requirement.
+ EXPECT_FALSE(AddSdchDictionary(dictionary_text,
+ GURL("http://w.x.y.z.google.com.")));
+}
+
TEST_F(SdchManagerTest, FailToSetRepeatPrefixWithDotDictionary) {
// Make sure that a prefix that matches the domain postfix won't confuse
// the validation checks.
@@ -300,6 +309,42 @@ TEST_F(SdchManagerTest, CanSetLeadingDotDomainDictionary) {
EXPECT_TRUE(AddSdchDictionary(dictionary_text, GURL("http://www.google.com")));
}
+TEST_F(SdchManagerTest,
+ CanSetLeadingDotDomainDictionaryFromURLWithTrailingDot) {
+ // Make sure that a prefix that matches the domain postfix won't confuse
+ // the validation checks.
+ std::string dictionary_domain(".google.com");
+ std::string dictionary_text(NewSdchDictionary(dictionary_domain));
+
+ // Verify that a leading dot in the domain is acceptable, as long as the host
+ // name does not contain any dots preceding the matched domain name.
+ EXPECT_TRUE(AddSdchDictionary(dictionary_text,
+ GURL("http://www.google.com.")));
+}
+
+TEST_F(SdchManagerTest, CannotSetLeadingDotDomainDictionary) {
+ // Make sure that a prefix that matches the domain postfix won't confuse
+ // the validation checks.
+ std::string dictionary_domain(".google.com");
+ std::string dictionary_text(NewSdchDictionary(dictionary_domain));
+
+ // Verify that a leading dot in the domain does not affect the name containing
+ // dots failure.
+ EXPECT_FALSE(AddSdchDictionary(dictionary_text,
+ GURL("http://www.subdomain.google.com")));
+}
+
+TEST_F(SdchManagerTest, CannotSetLeadingDotDomainDictionaryTrailingDot) {
+ // Make sure that a prefix that matches the domain postfix won't confuse
+ // the validation checks.
+ std::string dictionary_domain(".google.com");
+ std::string dictionary_text(NewSdchDictionary(dictionary_domain));
+
+ // Verify that a trailing period in the URL doesn't affect the check.
+ EXPECT_FALSE(AddSdchDictionary(dictionary_text,
+ GURL("http://www.subdomain.google.com.")));
+}
+
// Make sure the order of the tests is not helping us or confusing things.
// See test CanSetExactMatchDictionary above for first try.
TEST_F(SdchManagerTest, CanStillSetExactMatchDictionary) {
@@ -509,4 +554,3 @@ TEST_F(SdchManagerTest, ClearDictionaryData) {
}
} // namespace net
-
« no previous file with comments | « net/base/sdch_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698