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

Side by Side Diff: net/cookies/parsed_cookie_unittest.cc

Issue 2876463006: Allow an arbitrary number of cookie string pairs. (Closed)
Patch Set: Created 3 years, 7 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/cookies/parsed_cookie.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 <string> 5 #include <string>
6 6
7 #include "net/cookies/cookie_constants.h" 7 #include "net/cookies/cookie_constants.h"
8 #include "net/cookies/parsed_cookie.h" 8 #include "net/cookies/parsed_cookie.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 EXPECT_TRUE(pc.IsValid()); 210 EXPECT_TRUE(pc.IsValid());
211 EXPECT_EQ("ANCUUID", pc.Name()); 211 EXPECT_EQ("ANCUUID", pc.Name());
212 EXPECT_EQ("zohNumRKgI0oxyhSsV3Z7D", pc.Value()); 212 EXPECT_EQ("zohNumRKgI0oxyhSsV3Z7D", pc.Value());
213 EXPECT_TRUE(pc.HasExpires()); 213 EXPECT_TRUE(pc.HasExpires());
214 EXPECT_TRUE(pc.HasPath()); 214 EXPECT_TRUE(pc.HasPath());
215 EXPECT_EQ("/", pc.Path()); 215 EXPECT_EQ("/", pc.Path());
216 EXPECT_EQ(COOKIE_PRIORITY_DEFAULT, pc.Priority()); 216 EXPECT_EQ(COOKIE_PRIORITY_DEFAULT, pc.Priority());
217 EXPECT_EQ(2U, pc.NumberOfAttributes()); 217 EXPECT_EQ(2U, pc.NumberOfAttributes());
218 } 218 }
219 219
220 TEST(ParsedCookieTest, TooManyPairs) { 220 TEST(ParsedCookieTest, LotsOfPairs) {
221 std::string blankpairs; 221 for (int i = 1; i < 100; i++) {
222 blankpairs.resize(ParsedCookie::kMaxPairs - 2, ';'); 222 std::string blankpairs;
223 blankpairs.resize(i, ';');
223 224
224 ParsedCookie pc1("a=b;" + blankpairs + "secure"); 225 ParsedCookie c("a=b;" + blankpairs + "secure");
225 EXPECT_TRUE(pc1.IsValid()); 226 EXPECT_EQ("a", c.Name());
226 EXPECT_TRUE(pc1.IsSecure()); 227 EXPECT_EQ("b", c.Value());
227 228 EXPECT_TRUE(c.IsValid());
228 ParsedCookie pc2("a=b;" + blankpairs + ";secure"); 229 EXPECT_TRUE(c.IsSecure());
229 EXPECT_TRUE(pc2.IsValid()); 230 }
230 EXPECT_FALSE(pc2.IsSecure());
231 } 231 }
232 232
233 // TODO(erikwright): some better test cases for invalid cookies. 233 // TODO(erikwright): some better test cases for invalid cookies.
234 TEST(ParsedCookieTest, InvalidTooLong) { 234 TEST(ParsedCookieTest, InvalidTooLong) {
235 std::string maxstr; 235 std::string maxstr;
236 maxstr.resize(ParsedCookie::kMaxCookieSize, 'a'); 236 maxstr.resize(ParsedCookie::kMaxCookieSize, 'a');
237 237
238 ParsedCookie pc1(maxstr); 238 ParsedCookie pc1(maxstr);
239 EXPECT_TRUE(pc1.IsValid()); 239 EXPECT_TRUE(pc1.IsValid());
240 240
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 EXPECT_TRUE(pc5.IsValid()); 605 EXPECT_TRUE(pc5.IsValid());
606 EXPECT_EQ(pc5_literal, pc5.ToCookieLine()); 606 EXPECT_EQ(pc5_literal, pc5.ToCookieLine());
607 EXPECT_TRUE(pc6.IsValid()); 607 EXPECT_TRUE(pc6.IsValid());
608 EXPECT_EQ(pc6_literal, pc6.ToCookieLine()); 608 EXPECT_EQ(pc6_literal, pc6.ToCookieLine());
609 EXPECT_TRUE(pc7.IsValid()); 609 EXPECT_TRUE(pc7.IsValid());
610 EXPECT_EQ(pc7_literal, pc7.ToCookieLine()); 610 EXPECT_EQ(pc7_literal, pc7.ToCookieLine());
611 EXPECT_TRUE(pc8.IsValid()); 611 EXPECT_TRUE(pc8.IsValid());
612 EXPECT_EQ(pc8_literal, pc8.ToCookieLine()); 612 EXPECT_EQ(pc8_literal, pc8.ToCookieLine());
613 } 613 }
614 } 614 }
OLDNEW
« no previous file with comments | « net/cookies/parsed_cookie.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698