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

Side by Side Diff: net/http/http_network_transaction_unittest.cc

Issue 1393693002: [net/http auth] Split HttpAuthHandler creation from initialization. Base URL: https://chromium.googlesource.com/chromium/src.git@rename-auth-handler-methods
Patch Set: Created 5 years, 2 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "net/http/http_network_transaction.h" 5 #include "net/http/http_network_transaction.h"
6 6
7 #include <math.h> // ceil 7 #include <math.h> // ceil
8 #include <stdarg.h> 8 #include <stdarg.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 10494 matching lines...) Expand 10 before | Expand all | Expand 10 after
10505 const TestConfig& test_config = test_configs[i]; 10505 const TestConfig& test_config = test_configs[i];
10506 10506
10507 // Set up authentication handlers as necessary. 10507 // Set up authentication handlers as necessary.
10508 if (test_config.proxy_auth_timing != AUTH_NONE) { 10508 if (test_config.proxy_auth_timing != AUTH_NONE) {
10509 for (int n = 0; n < 2; n++) { 10509 for (int n = 0; n < 2; n++) {
10510 scoped_ptr<HttpAuthHandlerMock> auth_handler(new HttpAuthHandlerMock()); 10510 scoped_ptr<HttpAuthHandlerMock> auth_handler(new HttpAuthHandlerMock());
10511 auth_handler->SetGenerateExpectation( 10511 auth_handler->SetGenerateExpectation(
10512 test_config.proxy_auth_timing == AUTH_ASYNC, 10512 test_config.proxy_auth_timing == AUTH_ASYNC,
10513 test_config.proxy_auth_rv); 10513 test_config.proxy_auth_rv);
10514 auth_factory->AddMockHandler( 10514 auth_factory->AddMockHandler(
10515 auth_handler.Pass(), 10515 auth_handler.Pass(), n == 0
10516 n == 0 ? HttpAuthHandlerFactory::CREATE_CHALLENGE 10516 ? HttpAuthHandlerCreateReason::CHALLENGE
10517 : HttpAuthHandlerFactory::CREATE_PREEMPTIVE, 10517 : HttpAuthHandlerCreateReason::PREEMPTIVE);
10518 HttpAuth::AUTH_PROXY);
10519 } 10518 }
10520 } 10519 }
10521 if (test_config.server_auth_timing != AUTH_NONE) { 10520 if (test_config.server_auth_timing != AUTH_NONE) {
10522 scoped_ptr<HttpAuthHandlerMock> auth_handler(new HttpAuthHandlerMock()); 10521 scoped_ptr<HttpAuthHandlerMock> auth_handler(new HttpAuthHandlerMock());
10523 auth_handler->SetGenerateExpectation( 10522 auth_handler->SetGenerateExpectation(
10524 test_config.server_auth_timing == AUTH_ASYNC, 10523 test_config.server_auth_timing == AUTH_ASYNC,
10525 test_config.server_auth_rv); 10524 test_config.server_auth_rv);
10526 auth_factory->AddMockHandler(auth_handler.Pass(), 10525 auth_factory->AddMockHandler(auth_handler.Pass(),
10527 HttpAuthHandlerFactory::CREATE_CHALLENGE, 10526 HttpAuthHandlerCreateReason::CHALLENGE);
10528 HttpAuth::AUTH_SERVER);
10529 } 10527 }
10530 if (test_config.proxy_url) { 10528 if (test_config.proxy_url) {
10531 session_deps_.proxy_service = 10529 session_deps_.proxy_service =
10532 ProxyService::CreateFixed(test_config.proxy_url); 10530 ProxyService::CreateFixed(test_config.proxy_url);
10533 } else { 10531 } else {
10534 session_deps_.proxy_service = ProxyService::CreateDirect(); 10532 session_deps_.proxy_service = ProxyService::CreateDirect();
10535 } 10533 }
10536 10534
10537 HttpRequestInfo request; 10535 HttpRequestInfo request;
10538 request.method = "GET"; 10536 request.method = "GET";
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
10620 new HttpAuthHandlerMock::Factory()); 10618 new HttpAuthHandlerMock::Factory());
10621 session_deps_.http_auth_handler_factory.reset(auth_factory); 10619 session_deps_.http_auth_handler_factory.reset(auth_factory);
10622 session_deps_.proxy_service = ProxyService::CreateDirect(); 10620 session_deps_.proxy_service = ProxyService::CreateDirect();
10623 session_deps_.host_resolver->rules()->AddRule("www.example.com", "10.0.0.1"); 10621 session_deps_.host_resolver->rules()->AddRule("www.example.com", "10.0.0.1");
10624 session_deps_.host_resolver->set_synchronous_mode(true); 10622 session_deps_.host_resolver->set_synchronous_mode(true);
10625 10623
10626 scoped_ptr<HttpAuthHandlerMock> auth_handler(new HttpAuthHandlerMock()); 10624 scoped_ptr<HttpAuthHandlerMock> auth_handler(new HttpAuthHandlerMock());
10627 auth_handler->SetGenerateExpectation(false, OK); 10625 auth_handler->SetGenerateExpectation(false, OK);
10628 auth_handler->set_expect_multiple_challenges(true); 10626 auth_handler->set_expect_multiple_challenges(true);
10629 auth_factory->AddMockHandler(auth_handler.Pass(), 10627 auth_factory->AddMockHandler(auth_handler.Pass(),
10630 HttpAuthHandlerFactory::CREATE_CHALLENGE, 10628 HttpAuthHandlerCreateReason::CHALLENGE);
10631 HttpAuth::AUTH_SERVER);
10632 10629
10633 GURL origin("http://www.example.com"); 10630 GURL origin("http://www.example.com");
10634 int rv = OK; 10631 int rv = OK;
10635 const HttpResponseInfo* response = NULL; 10632 const HttpResponseInfo* response = NULL;
10636 HttpRequestInfo request; 10633 HttpRequestInfo request;
10637 request.method = "GET"; 10634 request.method = "GET";
10638 request.url = origin; 10635 request.url = origin;
10639 request.load_flags = 0; 10636 request.load_flags = 0;
10640 10637
10641 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 10638 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
10928 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70"); 10925 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70");
10929 TestNetLog net_log; 10926 TestNetLog net_log;
10930 session_deps_.net_log = &net_log; 10927 session_deps_.net_log = &net_log;
10931 GURL request_url; 10928 GURL request_url;
10932 { 10929 {
10933 HttpAuthHandlerMock::Factory* auth_factory = 10930 HttpAuthHandlerMock::Factory* auth_factory =
10934 new HttpAuthHandlerMock::Factory(); 10931 new HttpAuthHandlerMock::Factory();
10935 scoped_ptr<UrlRecordingHttpAuthHandlerMock> auth_handler( 10932 scoped_ptr<UrlRecordingHttpAuthHandlerMock> auth_handler(
10936 new UrlRecordingHttpAuthHandlerMock(&request_url)); 10933 new UrlRecordingHttpAuthHandlerMock(&request_url));
10937 auth_factory->AddMockHandler(auth_handler.Pass(), 10934 auth_factory->AddMockHandler(auth_handler.Pass(),
10938 HttpAuthHandlerFactory::CREATE_CHALLENGE, 10935 HttpAuthHandlerCreateReason::CHALLENGE);
10939 HttpAuth::AUTH_PROXY);
10940 session_deps_.http_auth_handler_factory.reset(auth_factory); 10936 session_deps_.http_auth_handler_factory.reset(auth_factory);
10941 } 10937 }
10942 10938
10943 HttpRequestInfo request; 10939 HttpRequestInfo request;
10944 request.method = "GET"; 10940 request.method = "GET";
10945 request.url = GURL("http://www.example.org"); 10941 request.url = GURL("http://www.example.org");
10946 request.load_flags = 0; 10942 request.load_flags = 0;
10947 10943
10948 // First round goes unauthenticated through the proxy. 10944 // First round goes unauthenticated through the proxy.
10949 MockWrite data_writes_1[] = { 10945 MockWrite data_writes_1[] = {
(...skipping 3812 matching lines...) Expand 10 before | Expand all | Expand 10 after
14762 std::string response_data; 14758 std::string response_data;
14763 EXPECT_EQ(OK, ReadTransaction(trans.get(), &response_data)); 14759 EXPECT_EQ(OK, ReadTransaction(trans.get(), &response_data));
14764 14760
14765 EXPECT_EQ(CountWriteBytes(data_writes, arraysize(data_writes)), 14761 EXPECT_EQ(CountWriteBytes(data_writes, arraysize(data_writes)),
14766 trans->GetTotalSentBytes()); 14762 trans->GetTotalSentBytes());
14767 EXPECT_EQ(CountReadBytes(data_reads, arraysize(data_reads)), 14763 EXPECT_EQ(CountReadBytes(data_reads, arraysize(data_reads)),
14768 trans->GetTotalReceivedBytes()); 14764 trans->GetTotalReceivedBytes());
14769 } 14765 }
14770 14766
14771 } // namespace net 14767 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_auth_handler_ntlm_win.cc ('k') | net/url_request/url_request_context_builder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698