OLD | NEW |
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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 | 274 |
275 TEST_F(GenericURLRequestJobTest, RequestWithCookies) { | 275 TEST_F(GenericURLRequestJobTest, RequestWithCookies) { |
276 net::CookieList* cookies = cookie_store_.cookies(); | 276 net::CookieList* cookies = cookie_store_.cookies(); |
277 | 277 |
278 // Basic matching cookie. | 278 // Basic matching cookie. |
279 cookies->push_back(*net::CanonicalCookie::Create( | 279 cookies->push_back(*net::CanonicalCookie::Create( |
280 GURL("https://example.com"), "basic_cookie", "1", "example.com", "/", | 280 GURL("https://example.com"), "basic_cookie", "1", "example.com", "/", |
281 base::Time(), base::Time(), | 281 base::Time(), base::Time(), |
282 /* secure */ false, | 282 /* secure */ false, |
283 /* http_only */ false, net::CookieSameSite::NO_RESTRICTION, | 283 /* http_only */ false, net::CookieSameSite::NO_RESTRICTION, |
284 /* enforce_strict_secure */ false, net::COOKIE_PRIORITY_DEFAULT)); | 284 net::COOKIE_PRIORITY_DEFAULT)); |
285 | 285 |
286 // Matching secure cookie. | 286 // Matching secure cookie. |
287 cookies->push_back(*net::CanonicalCookie::Create( | 287 cookies->push_back(*net::CanonicalCookie::Create( |
288 GURL("https://example.com"), "secure_cookie", "2", "example.com", "/", | 288 GURL("https://example.com"), "secure_cookie", "2", "example.com", "/", |
289 base::Time(), base::Time(), | 289 base::Time(), base::Time(), |
290 /* secure */ true, | 290 /* secure */ true, |
291 /* http_only */ false, net::CookieSameSite::NO_RESTRICTION, | 291 /* http_only */ false, net::CookieSameSite::NO_RESTRICTION, |
292 /* enforce_strict_secure */ true, net::COOKIE_PRIORITY_DEFAULT)); | 292 net::COOKIE_PRIORITY_DEFAULT)); |
293 | 293 |
294 // Matching http-only cookie. | 294 // Matching http-only cookie. |
295 cookies->push_back(*net::CanonicalCookie::Create( | 295 cookies->push_back(*net::CanonicalCookie::Create( |
296 GURL("https://example.com"), "http_only_cookie", "3", "example.com", "/", | 296 GURL("https://example.com"), "http_only_cookie", "3", "example.com", "/", |
297 base::Time(), base::Time(), | 297 base::Time(), base::Time(), |
298 /* secure */ false, | 298 /* secure */ false, |
299 /* http_only */ true, net::CookieSameSite::NO_RESTRICTION, | 299 /* http_only */ true, net::CookieSameSite::NO_RESTRICTION, |
300 /* enforce_strict_secure */ false, net::COOKIE_PRIORITY_DEFAULT)); | 300 net::COOKIE_PRIORITY_DEFAULT)); |
301 | 301 |
302 // Matching cookie with path. | 302 // Matching cookie with path. |
303 cookies->push_back(*net::CanonicalCookie::Create( | 303 cookies->push_back(*net::CanonicalCookie::Create( |
304 GURL("https://example.com"), "cookie_with_path", "4", "example.com", | 304 GURL("https://example.com"), "cookie_with_path", "4", "example.com", |
305 "/widgets", base::Time(), base::Time(), | 305 "/widgets", base::Time(), base::Time(), |
306 /* secure */ false, | 306 /* secure */ false, |
307 /* http_only */ false, net::CookieSameSite::NO_RESTRICTION, | 307 /* http_only */ false, net::CookieSameSite::NO_RESTRICTION, |
308 /* enforce_strict_secure */ false, net::COOKIE_PRIORITY_DEFAULT)); | 308 net::COOKIE_PRIORITY_DEFAULT)); |
309 | 309 |
310 // Matching cookie with subdomain. | 310 // Matching cookie with subdomain. |
311 cookies->push_back(*net::CanonicalCookie::Create( | 311 cookies->push_back(*net::CanonicalCookie::Create( |
312 GURL("https://cdn.example.com"), "bad_subdomain_cookie", "5", | 312 GURL("https://cdn.example.com"), "bad_subdomain_cookie", "5", |
313 "cdn.example.com", "/", base::Time(), base::Time(), | 313 "cdn.example.com", "/", base::Time(), base::Time(), |
314 /* secure */ false, | 314 /* secure */ false, |
315 /* http_only */ false, net::CookieSameSite::NO_RESTRICTION, | 315 /* http_only */ false, net::CookieSameSite::NO_RESTRICTION, |
316 /* enforce_strict_secure */ false, net::COOKIE_PRIORITY_DEFAULT)); | 316 net::COOKIE_PRIORITY_DEFAULT)); |
317 | 317 |
318 // Non-matching cookie (different site). | 318 // Non-matching cookie (different site). |
319 cookies->push_back(*net::CanonicalCookie::Create( | 319 cookies->push_back(*net::CanonicalCookie::Create( |
320 GURL("https://zombo.com"), "bad_site_cookie", "6", "zombo.com", "/", | 320 GURL("https://zombo.com"), "bad_site_cookie", "6", "zombo.com", "/", |
321 base::Time(), base::Time(), | 321 base::Time(), base::Time(), |
322 /* secure */ false, | 322 /* secure */ false, |
323 /* http_only */ false, net::CookieSameSite::NO_RESTRICTION, | 323 /* http_only */ false, net::CookieSameSite::NO_RESTRICTION, |
324 /* enforce_strict_secure */ false, net::COOKIE_PRIORITY_DEFAULT)); | 324 net::COOKIE_PRIORITY_DEFAULT)); |
325 | 325 |
326 // Non-matching cookie (different path). | 326 // Non-matching cookie (different path). |
327 cookies->push_back(*net::CanonicalCookie::Create( | 327 cookies->push_back(*net::CanonicalCookie::Create( |
328 GURL("https://example.com"), "bad_path_cookie", "7", "example.com", | 328 GURL("https://example.com"), "bad_path_cookie", "7", "example.com", |
329 "/gadgets", base::Time(), base::Time(), | 329 "/gadgets", base::Time(), base::Time(), |
330 /* secure */ false, | 330 /* secure */ false, |
331 /* http_only */ false, net::CookieSameSite::NO_RESTRICTION, | 331 /* http_only */ false, net::CookieSameSite::NO_RESTRICTION, |
332 /* enforce_strict_secure */ false, net::COOKIE_PRIORITY_DEFAULT)); | 332 net::COOKIE_PRIORITY_DEFAULT)); |
333 | 333 |
334 std::string reply = | 334 std::string reply = |
335 "{\"url\":\"https://example.com\"," | 335 "{\"url\":\"https://example.com\"," |
336 " \"http_response_code\":200," | 336 " \"http_response_code\":200," |
337 " \"data\":\"Reply\"," | 337 " \"data\":\"Reply\"," |
338 " \"headers\":{\"Content-Type\":\"text/html; charset=UTF-8\"}}"; | 338 " \"headers\":{\"Content-Type\":\"text/html; charset=UTF-8\"}}"; |
339 | 339 |
340 std::unique_ptr<net::URLRequest> request( | 340 std::unique_ptr<net::URLRequest> request( |
341 CreateAndCompleteJob(GURL("https://example.com"), reply)); | 341 CreateAndCompleteJob(GURL("https://example.com"), reply)); |
342 | 342 |
(...skipping 19 matching lines...) Expand all Loading... |
362 job_delegate_.SetShouldBlock(true); | 362 job_delegate_.SetShouldBlock(true); |
363 | 363 |
364 std::unique_ptr<net::URLRequest> request( | 364 std::unique_ptr<net::URLRequest> request( |
365 CreateAndCompleteJob(GURL("https://example.com"), reply)); | 365 CreateAndCompleteJob(GURL("https://example.com"), reply)); |
366 | 366 |
367 EXPECT_EQ(net::URLRequestStatus::FAILED, request->status().status()); | 367 EXPECT_EQ(net::URLRequestStatus::FAILED, request->status().status()); |
368 EXPECT_EQ(net::ERR_FILE_NOT_FOUND, request->status().error()); | 368 EXPECT_EQ(net::ERR_FILE_NOT_FOUND, request->status().error()); |
369 } | 369 } |
370 | 370 |
371 } // namespace headless | 371 } // namespace headless |
OLD | NEW |