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

Side by Side Diff: net/url_request/url_request_unittest.cc

Issue 10452024: Merge 138264 - Re-enable embedded identities in URLs for HTTP authentication. (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1132/src/
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « net/http/http_network_transaction_spdy3_unittest.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 "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 2919 matching lines...) Expand 10 before | Expand all | Expand 10 after
2930 r.Start(); 2930 r.Start();
2931 2931
2932 MessageLoop::current()->Run(); 2932 MessageLoop::current()->Run();
2933 2933
2934 EXPECT_TRUE(d.data_received().find("user/secret") != std::string::npos); 2934 EXPECT_TRUE(d.data_received().find("user/secret") != std::string::npos);
2935 2935
2936 // Make sure we sent the cookie in the restarted transaction. 2936 // Make sure we sent the cookie in the restarted transaction.
2937 EXPECT_TRUE(d.data_received().find("Cookie: got_challenged=true") 2937 EXPECT_TRUE(d.data_received().find("Cookie: got_challenged=true")
2938 != std::string::npos); 2938 != std::string::npos);
2939 } 2939 }
2940
2941 // Same test as above, except this time the restart is initiated earlier
2942 // (without user intervention since identity is embedded in the URL).
2943 {
2944 TestNetworkDelegate network_delegate; // must outlive URLRequest
2945 scoped_refptr<TestURLRequestContext> context(
2946 new TestURLRequestContext(true));
2947 context->set_network_delegate(&network_delegate);
2948 context->Init();
2949
2950 TestDelegate d;
2951
2952 GURL::Replacements replacements;
2953 std::string username("user2");
2954 std::string password("secret");
2955 replacements.SetUsernameStr(username);
2956 replacements.SetPasswordStr(password);
2957 GURL url_with_identity = url_requiring_auth.ReplaceComponents(replacements);
2958
2959 URLRequest r(url_with_identity, &d);
2960 r.set_context(context);
2961 r.Start();
2962
2963 MessageLoop::current()->Run();
2964
2965 EXPECT_TRUE(d.data_received().find("user2/secret") != std::string::npos);
2966
2967 // Make sure we sent the cookie in the restarted transaction.
2968 EXPECT_TRUE(d.data_received().find("Cookie: got_challenged=true")
2969 != std::string::npos);
2970 }
2940 } 2971 }
2941 2972
2942 TEST_F(URLRequestTest, DelayedCookieCallback) { 2973 TEST_F(URLRequestTest, DelayedCookieCallback) {
2943 LocalHttpTestServer test_server; 2974 LocalHttpTestServer test_server;
2944 ASSERT_TRUE(test_server.Start()); 2975 ASSERT_TRUE(test_server.Start());
2945 2976
2946 scoped_refptr<URLRequestContext> context(new TestURLRequestContext()); 2977 scoped_refptr<URLRequestContext> context(new TestURLRequestContext());
2947 scoped_refptr<DelayedCookieMonster> delayed_cm = 2978 scoped_refptr<DelayedCookieMonster> delayed_cm =
2948 new DelayedCookieMonster(); 2979 new DelayedCookieMonster();
2949 scoped_refptr<CookieStore> cookie_store = delayed_cm; 2980 scoped_refptr<CookieStore> cookie_store = delayed_cm;
(...skipping 1630 matching lines...) Expand 10 before | Expand all | Expand 10 after
4580 req.SetExtraRequestHeaders(headers); 4611 req.SetExtraRequestHeaders(headers);
4581 req.Start(); 4612 req.Start();
4582 MessageLoop::current()->Run(); 4613 MessageLoop::current()->Run();
4583 // If the net tests are being run with ChromeFrame then we need to allow for 4614 // If the net tests are being run with ChromeFrame then we need to allow for
4584 // the 'chromeframe' suffix which is added to the user agent before the 4615 // the 'chromeframe' suffix which is added to the user agent before the
4585 // closing parentheses. 4616 // closing parentheses.
4586 EXPECT_TRUE(StartsWithASCII(d.data_received(), "Lynx (textmode", true)); 4617 EXPECT_TRUE(StartsWithASCII(d.data_received(), "Lynx (textmode", true));
4587 } 4618 }
4588 4619
4589 } // namespace net 4620 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_network_transaction_spdy3_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698