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

Unified Diff: components/update_client/utils_unittest.cc

Issue 1872053002: Implement an API to allow passing an "ap" parameter to component updates. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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
« components/update_client/utils.h ('K') | « 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 b15fcac4b5e73b2ada38c1581eb9b24273132c60..ea5530f5e5b2e2da40f5c631b05c96036b8b7d08 100644
--- a/components/update_client/utils_unittest.cc
+++ b/components/update_client/utils_unittest.cc
@@ -81,6 +81,28 @@ TEST(UpdateClientUtils, IsValidBrand) {
EXPECT_FALSE(IsValidBrand(std::string("\xaa"))); // Has non-ASCII char.
}
+// 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("")));
+ EXPECT_TRUE(IsValidAp(std::string("A")));
+ EXPECT_TRUE(IsValidAp(std::string("Z")));
+ EXPECT_TRUE(IsValidAp(std::string("a")));
+ EXPECT_TRUE(IsValidAp(std::string("z")));
+ EXPECT_TRUE(IsValidAp(std::string("0")));
+ EXPECT_TRUE(IsValidAp(std::string("9")));
+ EXPECT_TRUE(IsValidAp(std::string(256, 'a')));
+ EXPECT_TRUE(IsValidAp(std::string("-+_=")));
+
+ EXPECT_FALSE(IsValidAp(std::string(257, 'a'))); // Too long.
+ EXPECT_FALSE(IsValidAp(std::string(" ap"))); // Begins with white space.
+ EXPECT_FALSE(IsValidAp(std::string("ap "))); // Ends with white space.
+ EXPECT_FALSE(IsValidAp(std::string("a p"))); // Contains white space.
+ EXPECT_FALSE(IsValidAp(std::string("<ap"))); // Has <.
+ EXPECT_FALSE(IsValidAp(std::string("ap>"))); // Has >.
+ EXPECT_FALSE(IsValidAp(std::string("\xaa"))); // Has non-ASCII char.
waffles 2016/04/08 21:06:16 Please add a test for " and \ as well.
Sorin Jianu 2016/04/08 21:13:42 Done.
+}
+
TEST(UpdateClientUtils, RemoveUnsecureUrls) {
const GURL test1[] = {GURL("http://foo"), GURL("https://foo")};
std::vector<GURL> urls(std::begin(test1), std::end(test1));
« components/update_client/utils.h ('K') | « components/update_client/utils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698