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

Side by Side Diff: headless/public/util/generic_url_request_job_test.cc

Issue 2861063003: Remove dangerous CanonicalCookie::Create method. (Closed)
Patch Set: Moved test to shared file. 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "headless/public/util/generic_url_request_job.h" 5 #include "headless/public/util/generic_url_request_job.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 360
361 EXPECT_TRUE(request->Read(buffer.get(), kBufferSize, &bytes_read)); 361 EXPECT_TRUE(request->Read(buffer.get(), kBufferSize, &bytes_read));
362 EXPECT_EQ(0, bytes_read); 362 EXPECT_EQ(0, bytes_read);
363 } 363 }
364 364
365 TEST_F(GenericURLRequestJobTest, RequestWithCookies) { 365 TEST_F(GenericURLRequestJobTest, RequestWithCookies) {
366 net::CookieList* cookies = cookie_store_.cookies(); 366 net::CookieList* cookies = cookie_store_.cookies();
367 367
368 // Basic matching cookie. 368 // Basic matching cookie.
369 cookies->push_back(*net::CanonicalCookie::Create( 369 cookies->push_back(*net::CanonicalCookie::Create(
370 GURL("https://example.com"), "basic_cookie", "1", "example.com", "/", 370 "basic_cookie", "1", ".example.com", "/", base::Time(), base::Time(),
371 base::Time(), base::Time(), 371 base::Time(),
372 /* secure */ false, 372 /* secure */ false,
373 /* http_only */ false, net::CookieSameSite::NO_RESTRICTION, 373 /* http_only */ false, net::CookieSameSite::NO_RESTRICTION,
374 net::COOKIE_PRIORITY_DEFAULT)); 374 net::COOKIE_PRIORITY_DEFAULT));
375 375
376 // Matching secure cookie. 376 // Matching secure cookie.
377 cookies->push_back(*net::CanonicalCookie::Create( 377 cookies->push_back(*net::CanonicalCookie::Create(
378 GURL("https://example.com"), "secure_cookie", "2", "example.com", "/", 378 "secure_cookie", "2", ".example.com", "/", base::Time(), base::Time(),
379 base::Time(), base::Time(), 379 base::Time(),
380 /* secure */ true, 380 /* secure */ true,
381 /* http_only */ false, net::CookieSameSite::NO_RESTRICTION, 381 /* http_only */ false, net::CookieSameSite::NO_RESTRICTION,
382 net::COOKIE_PRIORITY_DEFAULT)); 382 net::COOKIE_PRIORITY_DEFAULT));
383 383
384 // Matching http-only cookie. 384 // Matching http-only cookie.
385 cookies->push_back(*net::CanonicalCookie::Create( 385 cookies->push_back(*net::CanonicalCookie::Create(
386 GURL("https://example.com"), "http_only_cookie", "3", "example.com", "/", 386 "http_only_cookie", "3", ".example.com", "/", base::Time(), base::Time(),
387 base::Time(), base::Time(), 387 base::Time(),
388 /* secure */ false, 388 /* secure */ false,
389 /* http_only */ true, net::CookieSameSite::NO_RESTRICTION, 389 /* http_only */ true, net::CookieSameSite::NO_RESTRICTION,
390 net::COOKIE_PRIORITY_DEFAULT)); 390 net::COOKIE_PRIORITY_DEFAULT));
391 391
392 // Matching cookie with path. 392 // Matching cookie with path.
393 cookies->push_back(*net::CanonicalCookie::Create( 393 cookies->push_back(*net::CanonicalCookie::Create(
394 GURL("https://example.com"), "cookie_with_path", "4", "example.com", 394 "cookie_with_path", "4", ".example.com", "/widgets", base::Time(),
395 "/widgets", base::Time(), base::Time(), 395 base::Time(), base::Time(),
396 /* secure */ false, 396 /* secure */ false,
397 /* http_only */ false, net::CookieSameSite::NO_RESTRICTION, 397 /* http_only */ false, net::CookieSameSite::NO_RESTRICTION,
398 net::COOKIE_PRIORITY_DEFAULT)); 398 net::COOKIE_PRIORITY_DEFAULT));
399 399
400 // Matching cookie with subdomain. 400 // Matching cookie with subdomain.
401 cookies->push_back(*net::CanonicalCookie::Create( 401 cookies->push_back(*net::CanonicalCookie::Create(
402 GURL("https://cdn.example.com"), "bad_subdomain_cookie", "5", 402 "bad_subdomain_cookie", "5", ".cdn.example.com", "/", base::Time(),
403 "cdn.example.com", "/", base::Time(), base::Time(), 403 base::Time(), base::Time(),
404 /* secure */ false, 404 /* secure */ false,
405 /* http_only */ false, net::CookieSameSite::NO_RESTRICTION, 405 /* http_only */ false, net::CookieSameSite::NO_RESTRICTION,
406 net::COOKIE_PRIORITY_DEFAULT)); 406 net::COOKIE_PRIORITY_DEFAULT));
407 407
408 // Non-matching cookie (different site). 408 // Non-matching cookie (different site).
409 cookies->push_back(*net::CanonicalCookie::Create( 409 cookies->push_back(*net::CanonicalCookie::Create(
410 GURL("https://zombo.com"), "bad_site_cookie", "6", "zombo.com", "/", 410 "bad_site_cookie", "6", ".zombo.com", "/", base::Time(), base::Time(),
411 base::Time(), base::Time(), 411 base::Time(),
412 /* secure */ false, 412 /* secure */ false,
413 /* http_only */ false, net::CookieSameSite::NO_RESTRICTION, 413 /* http_only */ false, net::CookieSameSite::NO_RESTRICTION,
414 net::COOKIE_PRIORITY_DEFAULT)); 414 net::COOKIE_PRIORITY_DEFAULT));
415 415
416 // Non-matching cookie (different path). 416 // Non-matching cookie (different path).
417 cookies->push_back(*net::CanonicalCookie::Create( 417 cookies->push_back(*net::CanonicalCookie::Create(
418 GURL("https://example.com"), "bad_path_cookie", "7", "example.com", 418 "bad_path_cookie", "7", ".example.com", "/gadgets", base::Time(),
419 "/gadgets", base::Time(), base::Time(), 419 base::Time(), base::Time(),
420 /* secure */ false, 420 /* secure */ false,
421 /* http_only */ false, net::CookieSameSite::NO_RESTRICTION, 421 /* http_only */ false, net::CookieSameSite::NO_RESTRICTION,
422 net::COOKIE_PRIORITY_DEFAULT)); 422 net::COOKIE_PRIORITY_DEFAULT));
423 423
424 std::string reply = R"( 424 std::string reply = R"(
425 { 425 {
426 "url": "https://example.com", 426 "url": "https://example.com",
427 "data": "Reply", 427 "data": "Reply",
428 "headers": { 428 "headers": {
429 "Content-Type": "text/html; charset=UTF-8" 429 "Content-Type": "text/html; charset=UTF-8"
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 pending_request->AllowRequest(); 652 pending_request->AllowRequest();
653 }, 653 },
654 &post_data)); 654 &post_data));
655 655
656 CreateAndCompletePostJob(GURL("https://example.com"), "payload", reply); 656 CreateAndCompletePostJob(GURL("https://example.com"), "payload", reply);
657 657
658 EXPECT_EQ("payload", post_data); 658 EXPECT_EQ("payload", post_data);
659 } 659 }
660 660
661 } // namespace headless 661 } // namespace headless
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698