summaryrefslogtreecommitdiffstats
path: root/net/url_request/url_request_unittest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'net/url_request/url_request_unittest.cc')
-rw-r--r--net/url_request/url_request_unittest.cc212
1 files changed, 1 insertions, 211 deletions
diff --git a/net/url_request/url_request_unittest.cc b/net/url_request/url_request_unittest.cc
index 56901fc..48cfd35 100644
--- a/net/url_request/url_request_unittest.cc
+++ b/net/url_request/url_request_unittest.cc
@@ -24,7 +24,6 @@
#include "base/string_piece.h"
#include "base/string_util.h"
#include "net/base/cookie_monster.h"
-#include "net/base/cookie_policy.h"
#include "net/base/load_flags.h"
#include "net/base/load_log.h"
#include "net/base/load_log_unittest.h"
@@ -1287,6 +1286,7 @@ TEST_F(URLRequestTest, DoNotSaveCookies) {
// Try to set-up another cookie and update the previous cookie.
{
+ scoped_refptr<URLRequestContext> context = new URLRequestTestContext();
TestDelegate d;
URLRequest req(server->TestServerPage(
"set-cookie?CookieToNotSave=1&CookieToNotUpdate=1"), &d);
@@ -1312,216 +1312,6 @@ TEST_F(URLRequestTest, DoNotSaveCookies) {
}
}
-TEST_F(URLRequestTest, DoNotSendCookies_ViaPolicy) {
- scoped_refptr<HTTPTestServer> server =
- HTTPTestServer::CreateServer(L"", NULL);
- ASSERT_TRUE(NULL != server.get());
- scoped_refptr<URLRequestTestContext> context = new URLRequestTestContext();
-
- // Set up a cookie.
- {
- TestDelegate d;
- URLRequest req(server->TestServerPage("set-cookie?CookieToNotSend=1"), &d);
- req.set_context(context);
- req.Start();
- MessageLoop::current()->Run();
- }
-
- // Verify that the cookie is set.
- {
- TestDelegate d;
- TestURLRequest req(server->TestServerPage("echoheader?Cookie"), &d);
- req.set_context(context);
- req.Start();
- MessageLoop::current()->Run();
-
- EXPECT_TRUE(d.data_received().find("CookieToNotSend=1")
- != std::string::npos);
- }
-
- // Verify that the cookie isn't sent.
- {
- TestCookiePolicy cookie_policy(TestCookiePolicy::NO_GET_COOKIES);
- context->set_cookie_policy(&cookie_policy);
-
- TestDelegate d;
- TestURLRequest req(server->TestServerPage("echoheader?Cookie"), &d);
- req.set_context(context);
- req.Start();
- MessageLoop::current()->Run();
-
- EXPECT_TRUE(d.data_received().find("Cookie: CookieToNotSend=1")
- == std::string::npos);
-
- context->set_cookie_policy(NULL);
- }
-}
-
-TEST_F(URLRequestTest, DoNotSaveCookies_ViaPolicy) {
- scoped_refptr<HTTPTestServer> server =
- HTTPTestServer::CreateServer(L"", NULL);
- ASSERT_TRUE(NULL != server.get());
- scoped_refptr<URLRequestTestContext> context = new URLRequestTestContext();
-
- // Set up a cookie.
- {
- TestDelegate d;
- URLRequest req(server->TestServerPage("set-cookie?CookieToNotUpdate=2"),
- &d);
- req.set_context(context);
- req.Start();
- MessageLoop::current()->Run();
- }
-
- // Try to set-up another cookie and update the previous cookie.
- {
- TestCookiePolicy cookie_policy(TestCookiePolicy::NO_SET_COOKIE);
- context->set_cookie_policy(&cookie_policy);
-
- TestDelegate d;
- URLRequest req(server->TestServerPage(
- "set-cookie?CookieToNotSave=1&CookieToNotUpdate=1"), &d);
- req.set_context(context);
- req.Start();
-
- MessageLoop::current()->Run();
-
- context->set_cookie_policy(NULL);
- }
-
-
- // Verify the cookies weren't saved or updated.
- {
- TestDelegate d;
- TestURLRequest req(server->TestServerPage("echoheader?Cookie"), &d);
- req.set_context(context);
- req.Start();
- MessageLoop::current()->Run();
-
- EXPECT_TRUE(d.data_received().find("CookieToNotSave=1")
- == std::string::npos);
- EXPECT_TRUE(d.data_received().find("CookieToNotUpdate=2")
- != std::string::npos);
- }
-}
-
-TEST_F(URLRequestTest, DoNotSendCookies_ViaPolicy_Async) {
- scoped_refptr<HTTPTestServer> server =
- HTTPTestServer::CreateServer(L"", NULL);
- ASSERT_TRUE(NULL != server.get());
- scoped_refptr<URLRequestTestContext> context = new URLRequestTestContext();
-
- // Set up a cookie.
- {
- TestDelegate d;
- URLRequest req(server->TestServerPage("set-cookie?CookieToNotSend=1"), &d);
- req.set_context(context);
- req.Start();
- MessageLoop::current()->Run();
- }
-
- // Verify that the cookie is set.
- {
- TestDelegate d;
- TestURLRequest req(server->TestServerPage("echoheader?Cookie"), &d);
- req.set_context(context);
- req.Start();
- MessageLoop::current()->Run();
-
- EXPECT_TRUE(d.data_received().find("CookieToNotSend=1")
- != std::string::npos);
- }
-
- // Verify that the cookie isn't sent.
- {
- TestCookiePolicy cookie_policy(TestCookiePolicy::NO_GET_COOKIES |
- TestCookiePolicy::ASYNC);
- context->set_cookie_policy(&cookie_policy);
-
- TestDelegate d;
- TestURLRequest req(server->TestServerPage("echoheader?Cookie"), &d);
- req.set_context(context);
- req.Start();
- MessageLoop::current()->Run();
-
- EXPECT_TRUE(d.data_received().find("Cookie: CookieToNotSend=1")
- == std::string::npos);
-
- context->set_cookie_policy(NULL);
- }
-}
-
-TEST_F(URLRequestTest, DoNotSaveCookies_ViaPolicy_Async) {
- scoped_refptr<HTTPTestServer> server =
- HTTPTestServer::CreateServer(L"", NULL);
- ASSERT_TRUE(NULL != server.get());
- scoped_refptr<URLRequestTestContext> context = new URLRequestTestContext();
-
- // Set up a cookie.
- {
- TestDelegate d;
- URLRequest req(server->TestServerPage("set-cookie?CookieToNotUpdate=2"),
- &d);
- req.set_context(context);
- req.Start();
- MessageLoop::current()->Run();
- }
-
- // Try to set-up another cookie and update the previous cookie.
- {
- TestCookiePolicy cookie_policy(TestCookiePolicy::NO_SET_COOKIE |
- TestCookiePolicy::ASYNC);
- context->set_cookie_policy(&cookie_policy);
-
- TestDelegate d;
- URLRequest req(server->TestServerPage(
- "set-cookie?CookieToNotSave=1&CookieToNotUpdate=1"), &d);
- req.set_context(context);
- req.Start();
-
- MessageLoop::current()->Run();
-
- context->set_cookie_policy(NULL);
- }
-
- // Verify the cookies weren't saved or updated.
- {
- TestDelegate d;
- TestURLRequest req(server->TestServerPage("echoheader?Cookie"), &d);
- req.set_context(context);
- req.Start();
- MessageLoop::current()->Run();
-
- EXPECT_TRUE(d.data_received().find("CookieToNotSave=1")
- == std::string::npos);
- EXPECT_TRUE(d.data_received().find("CookieToNotUpdate=2")
- != std::string::npos);
- }
-}
-
-TEST_F(URLRequestTest, CancelTest_DuringCookiePolicy) {
- scoped_refptr<HTTPTestServer> server =
- HTTPTestServer::CreateServer(L"", NULL);
- ASSERT_TRUE(NULL != server.get());
- scoped_refptr<URLRequestTestContext> context = new URLRequestTestContext();
-
- TestCookiePolicy cookie_policy(TestCookiePolicy::ASYNC);
- context->set_cookie_policy(&cookie_policy);
-
- // Set up a cookie.
- {
- TestDelegate d;
- URLRequest req(server->TestServerPage("set-cookie?A=1&B=2&C=3"),
- &d);
- req.set_context(context);
- req.Start(); // Triggers an asynchronous cookie policy check.
-
- // But, now we cancel the request. This should not cause a crash.
- }
-
- context->set_cookie_policy(NULL);
-}
-
// In this test, we do a POST which the server will 302 redirect.
// The subsequent transaction should use GET, and should not send the
// Content-Type header.