OLD | NEW |
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 "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <shlobj.h> | 9 #include <shlobj.h> |
10 #endif | 10 #endif |
(...skipping 2866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2877 r.Start(); | 2877 r.Start(); |
2878 | 2878 |
2879 MessageLoop::current()->Run(); | 2879 MessageLoop::current()->Run(); |
2880 | 2880 |
2881 EXPECT_TRUE(d.data_received().find("user/secret") != std::string::npos); | 2881 EXPECT_TRUE(d.data_received().find("user/secret") != std::string::npos); |
2882 | 2882 |
2883 // Make sure we sent the cookie in the restarted transaction. | 2883 // Make sure we sent the cookie in the restarted transaction. |
2884 EXPECT_TRUE(d.data_received().find("Cookie: got_challenged=true") | 2884 EXPECT_TRUE(d.data_received().find("Cookie: got_challenged=true") |
2885 != std::string::npos); | 2885 != std::string::npos); |
2886 } | 2886 } |
| 2887 |
| 2888 // Same test as above, except this time the restart is initiated earlier |
| 2889 // (without user intervention since identity is embedded in the URL). |
| 2890 { |
| 2891 TestNetworkDelegate network_delegate; // must outlive URLRequest |
| 2892 scoped_refptr<TestURLRequestContext> context( |
| 2893 new TestURLRequestContext(true)); |
| 2894 context->set_network_delegate(&network_delegate); |
| 2895 context->Init(); |
| 2896 |
| 2897 TestDelegate d; |
| 2898 |
| 2899 GURL::Replacements replacements; |
| 2900 std::string username("user2"); |
| 2901 std::string password("secret"); |
| 2902 replacements.SetUsernameStr(username); |
| 2903 replacements.SetPasswordStr(password); |
| 2904 GURL url_with_identity = url_requiring_auth.ReplaceComponents(replacements); |
| 2905 |
| 2906 URLRequest r(url_with_identity, &d); |
| 2907 r.set_context(context); |
| 2908 r.Start(); |
| 2909 |
| 2910 MessageLoop::current()->Run(); |
| 2911 |
| 2912 EXPECT_TRUE(d.data_received().find("user2/secret") != std::string::npos); |
| 2913 |
| 2914 // Make sure we sent the cookie in the restarted transaction. |
| 2915 EXPECT_TRUE(d.data_received().find("Cookie: got_challenged=true") |
| 2916 != std::string::npos); |
| 2917 } |
2887 } | 2918 } |
2888 | 2919 |
2889 TEST_F(URLRequestTest, DelayedCookieCallback) { | 2920 TEST_F(URLRequestTest, DelayedCookieCallback) { |
2890 LocalHttpTestServer test_server; | 2921 LocalHttpTestServer test_server; |
2891 ASSERT_TRUE(test_server.Start()); | 2922 ASSERT_TRUE(test_server.Start()); |
2892 | 2923 |
2893 scoped_refptr<URLRequestContext> context(new TestURLRequestContext()); | 2924 scoped_refptr<URLRequestContext> context(new TestURLRequestContext()); |
2894 scoped_refptr<DelayedCookieMonster> delayed_cm = | 2925 scoped_refptr<DelayedCookieMonster> delayed_cm = |
2895 new DelayedCookieMonster(); | 2926 new DelayedCookieMonster(); |
2896 scoped_refptr<CookieStore> cookie_store = delayed_cm; | 2927 scoped_refptr<CookieStore> cookie_store = delayed_cm; |
(...skipping 1630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4527 req.SetExtraRequestHeaders(headers); | 4558 req.SetExtraRequestHeaders(headers); |
4528 req.Start(); | 4559 req.Start(); |
4529 MessageLoop::current()->Run(); | 4560 MessageLoop::current()->Run(); |
4530 // If the net tests are being run with ChromeFrame then we need to allow for | 4561 // If the net tests are being run with ChromeFrame then we need to allow for |
4531 // the 'chromeframe' suffix which is added to the user agent before the | 4562 // the 'chromeframe' suffix which is added to the user agent before the |
4532 // closing parentheses. | 4563 // closing parentheses. |
4533 EXPECT_TRUE(StartsWithASCII(d.data_received(), "Lynx (textmode", true)); | 4564 EXPECT_TRUE(StartsWithASCII(d.data_received(), "Lynx (textmode", true)); |
4534 } | 4565 } |
4535 | 4566 |
4536 } // namespace net | 4567 } // namespace net |
OLD | NEW |