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

Unified Diff: components/update_client/utils_unittest.cc

Issue 1876573002: Component updater must enforce that the brand length is 4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@apchange
Patch Set: Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/update_client/utils.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/update_client/utils_unittest.cc
diff --git a/components/update_client/utils_unittest.cc b/components/update_client/utils_unittest.cc
index e48a83eea1e412909e94098b262c2066bf48fca2..bd9246088b2615ea0584a19f28f4fea24c7aa4ae 100644
--- a/components/update_client/utils_unittest.cc
+++ b/components/update_client/utils_unittest.cc
@@ -57,20 +57,17 @@ TEST(UpdateClientUtils, VerifyFileHash256) {
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")));
}
-// Tests that the brand matches ^([a-zA-Z]{4})?$
+// Tests that the brand matches ^[a-zA-Z]{4}?$
TEST(UpdateClientUtils, IsValidBrand) {
+ // The valid brand code must be empty or exactly 4 chars long.
EXPECT_TRUE(IsValidBrand(std::string("")));
- EXPECT_TRUE(IsValidBrand(std::string("T")));
- EXPECT_TRUE(IsValidBrand(std::string("TE")));
- EXPECT_TRUE(IsValidBrand(std::string("TES")));
EXPECT_TRUE(IsValidBrand(std::string("TEST")));
- EXPECT_TRUE(IsValidBrand(std::string("")));
- EXPECT_TRUE(IsValidBrand(std::string("t")));
- EXPECT_TRUE(IsValidBrand(std::string("te")));
- EXPECT_TRUE(IsValidBrand(std::string("tes")));
EXPECT_TRUE(IsValidBrand(std::string("test")));
EXPECT_TRUE(IsValidBrand(std::string("TEst")));
+ EXPECT_FALSE(IsValidBrand(std::string("T"))); // Too short.
+ EXPECT_FALSE(IsValidBrand(std::string("TE"))); //
+ EXPECT_FALSE(IsValidBrand(std::string("TES"))); //
EXPECT_FALSE(IsValidBrand(std::string("TESTS"))); // Too long.
EXPECT_FALSE(IsValidBrand(std::string("TES1"))); // Has digit.
EXPECT_FALSE(IsValidBrand(std::string(" TES"))); // Begins with white space.
@@ -78,10 +75,12 @@ TEST(UpdateClientUtils, IsValidBrand) {
EXPECT_FALSE(IsValidBrand(std::string("T ES"))); // Contains white space.
EXPECT_FALSE(IsValidBrand(std::string("<TE"))); // Has <.
EXPECT_FALSE(IsValidBrand(std::string("TE>"))); // Has >.
+ EXPECT_FALSE(IsValidAp(std::string("\""))); // Has "
+ EXPECT_FALSE(IsValidAp(std::string("\\"))); // Has backslash.
EXPECT_FALSE(IsValidBrand(std::string("\xaa"))); // Has non-ASCII char.
}
-// Tests that the ap matches ^([-+_=a-zA-Z0-9]{0,256})$
+// Tests that the ap matches ^[-+_=a-zA-Z0-9]{0,256}$
TEST(UpdateClientUtils, IsValidAp) {
EXPECT_TRUE(IsValidAp(std::string("a=1")));
EXPECT_TRUE(IsValidAp(std::string("")));
« no previous file with comments | « components/update_client/utils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698