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

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

Issue 6804032: Add TLS-SRP (RFC 5054) support Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: remove "httpsv" scheme, minor NSS/OpenSSL changes Created 9 years, 8 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/url_request/url_request_test_util.cc ('k') | third_party/tlslite/README.chromium » ('j') | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <shlobj.h> 8 #include <shlobj.h>
9 #include <windows.h> 9 #include <windows.h>
10 #elif defined(USE_NSS) 10 #elif defined(USE_NSS)
11 #include "base/nss_util.h" 11 #include "base/nss_util.h"
12 #include <sslproto.h>
12 #endif 13 #endif
13 14
14 #include <algorithm> 15 #include <algorithm>
15 #include <string> 16 #include <string>
16 17
17 #include "base/file_util.h" 18 #include "base/file_util.h"
18 #include "base/format_macros.h" 19 #include "base/format_macros.h"
19 #include "base/message_loop.h" 20 #include "base/message_loop.h"
20 #include "base/path_service.h" 21 #include "base/path_service.h"
21 #include "base/process_util.h" 22 #include "base/process_util.h"
22 #include "base/string_number_conversions.h" 23 #include "base/string_number_conversions.h"
23 #include "base/string_piece.h" 24 #include "base/string_piece.h"
24 #include "base/string_util.h" 25 #include "base/string_util.h"
25 #include "base/stringprintf.h" 26 #include "base/stringprintf.h"
26 #include "base/utf_string_conversions.h" 27 #include "base/utf_string_conversions.h"
27 #include "net/base/cookie_monster.h" 28 #include "net/base/cookie_monster.h"
28 #include "net/base/cookie_policy.h" 29 #include "net/base/cookie_policy.h"
29 #include "net/base/load_flags.h" 30 #include "net/base/load_flags.h"
30 #include "net/base/net_errors.h" 31 #include "net/base/net_errors.h"
31 #include "net/base/net_log.h" 32 #include "net/base/net_log.h"
32 #include "net/base/net_log_unittest.h" 33 #include "net/base/net_log_unittest.h"
33 #include "net/base/net_module.h" 34 #include "net/base/net_module.h"
34 #include "net/base/net_util.h" 35 #include "net/base/net_util.h"
35 #include "net/base/ssl_connection_status_flags.h" 36 #include "net/base/ssl_connection_status_flags.h"
37 #include "net/base/cert_status_flags.h"
36 #include "net/base/upload_data.h" 38 #include "net/base/upload_data.h"
37 #include "net/disk_cache/disk_cache.h" 39 #include "net/disk_cache/disk_cache.h"
38 #include "net/ftp/ftp_network_layer.h" 40 #include "net/ftp/ftp_network_layer.h"
39 #include "net/http/http_cache.h" 41 #include "net/http/http_cache.h"
40 #include "net/http/http_network_layer.h" 42 #include "net/http/http_network_layer.h"
41 #include "net/http/http_request_headers.h" 43 #include "net/http/http_request_headers.h"
42 #include "net/http/http_response_headers.h" 44 #include "net/http/http_response_headers.h"
43 #include "net/proxy/proxy_service.h" 45 #include "net/proxy/proxy_service.h"
44 #include "net/test/test_server.h" 46 #include "net/test/test_server.h"
45 #include "net/url_request/url_request.h" 47 #include "net/url_request/url_request.h"
46 #include "net/url_request/url_request_file_dir_job.h" 48 #include "net/url_request/url_request_file_dir_job.h"
47 #include "net/url_request/url_request_http_job.h" 49 #include "net/url_request/url_request_http_job.h"
48 #include "net/url_request/url_request_test_job.h" 50 #include "net/url_request/url_request_test_job.h"
49 #include "net/url_request/url_request_test_util.h" 51 #include "net/url_request/url_request_test_util.h"
50 #include "testing/gtest/include/gtest/gtest.h" 52 #include "testing/gtest/include/gtest/gtest.h"
51 #include "testing/platform_test.h" 53 #include "testing/platform_test.h"
52 54
53 using base::Time; 55 using base::Time;
54 56
55 namespace { 57 namespace {
56 58
57 const string16 kChrome(ASCIIToUTF16("chrome")); 59 const string16 kChrome(ASCIIToUTF16("chrome"));
58 const string16 kSecret(ASCIIToUTF16("secret")); 60 const string16 kSecret(ASCIIToUTF16("secret"));
61 const string16 kWrongSecret(ASCIIToUTF16("wrongsecret"));
59 const string16 kUser(ASCIIToUTF16("user")); 62 const string16 kUser(ASCIIToUTF16("user"));
63 const string16 kWrongUser(ASCIIToUTF16("wronguser"));
60 64
61 base::StringPiece TestNetResourceProvider(int key) { 65 base::StringPiece TestNetResourceProvider(int key) {
62 return "header"; 66 return "header";
63 } 67 }
64 68
65 // Do a case-insensitive search through |haystack| for |needle|. 69 // Do a case-insensitive search through |haystack| for |needle|.
66 bool ContainsString(const std::string& haystack, const char* needle) { 70 bool ContainsString(const std::string& haystack, const char* needle) {
67 std::string::const_iterator it = 71 std::string::const_iterator it =
68 std::search(haystack.begin(), 72 std::search(haystack.begin(),
69 haystack.end(), 73 haystack.end(),
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 110
107 // -1 means unknown. 0 means no encryption. 111 // -1 means unknown. 0 means no encryption.
108 EXPECT_GT(ssl_info.security_bits, 0); 112 EXPECT_GT(ssl_info.security_bits, 0);
109 113
110 // The cipher suite TLS_NULL_WITH_NULL_NULL (0) must not be negotiated. 114 // The cipher suite TLS_NULL_WITH_NULL_NULL (0) must not be negotiated.
111 int cipher_suite = net::SSLConnectionStatusToCipherSuite( 115 int cipher_suite = net::SSLConnectionStatusToCipherSuite(
112 ssl_info.connection_status); 116 ssl_info.connection_status);
113 EXPECT_NE(0, cipher_suite); 117 EXPECT_NE(0, cipher_suite);
114 } 118 }
115 119
120 // Verify that the AuthChallengeInfo for TLS-SRP has valid values.
121 void CheckTLSAuthChallengeInfo(net::AuthChallengeInfo* login_request,
122 GURL& request_url) {
123 EXPECT_EQ(WideToUTF8(login_request->host_and_port),
124 net::GetHostAndPort(request_url));
125 EXPECT_EQ(net::kTLSSRPScheme, WideToUTF8(login_request->scheme));
126 EXPECT_EQ("", WideToUTF8(login_request->realm));
127 EXPECT_EQ(net::AUTH_OVER_TLS, login_request->over_protocol);
128 }
129
116 } // namespace 130 } // namespace
117 131
118 // Inherit PlatformTest since we require the autorelease pool on Mac OS X.f 132 // Inherit PlatformTest since we require the autorelease pool on Mac OS X.f
119 class URLRequestTest : public PlatformTest { 133 class URLRequestTest : public PlatformTest {
120 public: 134 public:
121 static void SetUpTestCase() { 135 static void SetUpTestCase() {
122 net::URLRequest::AllowFileAccess(); 136 net::URLRequest::AllowFileAccess();
123 } 137 }
124 }; 138 };
125 139
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 on_certificate_requested_count_++; 430 on_certificate_requested_count_++;
417 MessageLoop::current()->Quit(); 431 MessageLoop::current()->Quit();
418 } 432 }
419 int on_certificate_requested_count() { 433 int on_certificate_requested_count() {
420 return on_certificate_requested_count_; 434 return on_certificate_requested_count_;
421 } 435 }
422 private: 436 private:
423 int on_certificate_requested_count_; 437 int on_certificate_requested_count_;
424 }; 438 };
425 439
440 class TLSSRPClientLoginTestDelegate : public TestDelegate {
441 public:
442 TLSSRPClientLoginTestDelegate() :
443 on_tls_login_required_count_(0),
444 last_login_request_info_(NULL) {
445 }
446 virtual void OnTLSLoginRequired(
447 net::URLRequest* request,
448 net::AuthChallengeInfo* login_request_info) {
449 on_tls_login_required_count_++;
450 last_login_request_info_ = login_request_info;
451 MessageLoop::current()->Quit();
452 }
453 int on_tls_login_required_count() {
454 return on_tls_login_required_count_;
455 };
456 net::AuthChallengeInfo* last_login_request_info() {
457 return last_login_request_info_;
458 }
459 private:
460 int on_tls_login_required_count_;
461 net::AuthChallengeInfo* last_login_request_info_;
462 };
463
426 } // namespace 464 } // namespace
427 465
428 // TODO(davidben): Test the rest of the code. Specifically, 466 // TODO(davidben): Test the rest of the code. Specifically,
429 // - Filtering which certificates to select. 467 // - Filtering which certificates to select.
430 // - Sending a certificate back. 468 // - Sending a certificate back.
431 // - Getting a certificate request in an SSL renegotiation sending the 469 // - Getting a certificate request in an SSL renegotiation sending the
432 // HTTP request. 470 // HTTP request.
433 TEST_F(HTTPSRequestTest, ClientAuthTest) { 471 TEST_F(HTTPSRequestTest, ClientAuthTest) {
434 net::TestServer::HTTPSOptions https_options; 472 net::TestServer::HTTPSOptions https_options;
435 https_options.request_client_certificate = true; 473 https_options.request_client_certificate = true;
(...skipping 20 matching lines...) Expand all
456 r.ContinueWithCertificate(NULL); 494 r.ContinueWithCertificate(NULL);
457 495
458 MessageLoop::current()->Run(); 496 MessageLoop::current()->Run();
459 497
460 EXPECT_EQ(1, d.response_started_count()); 498 EXPECT_EQ(1, d.response_started_count());
461 EXPECT_FALSE(d.received_data_before_response()); 499 EXPECT_FALSE(d.received_data_before_response());
462 EXPECT_NE(0, d.bytes_received()); 500 EXPECT_NE(0, d.bytes_received());
463 } 501 }
464 } 502 }
465 503
504 TEST_F(HTTPSRequestTest, HTTPSSRPLoginTest) {
505 net::TestServer::HTTPSOptions https_options;
506 https_options.use_tls_srp = true;
507 https_options.only_tls_srp = true;
508 net::TestServer test_server(https_options, FilePath());
509 ASSERT_TRUE(test_server.Start());
510
511 TestDelegate d;
512 {
513 TestURLRequest r(test_server.GetURL("tlslogininfo"), &d);
514 r.SetTLSLogin(kUser, kSecret);
515
516 r.Start();
517 EXPECT_TRUE(r.is_pending());
518
519 MessageLoop::current()->Run();
520
521 EXPECT_NE(0, d.bytes_received());
522 EXPECT_TRUE(d.data_received().find(UTF16ToUTF8(kUser)) !=
523 std::string::npos);
524 EXPECT_FALSE(d.received_data_before_response());
525 }
526 }
527
528 // Provide no TLS login credentials at first; wait to be prompted by the
529 // server, and then provide them.
530 TEST_F(HTTPSRequestTest, HTTPSSRPLoginContinueTest) {
531 net::TestServer::HTTPSOptions https_options;
532 https_options.use_tls_srp = true;
533 https_options.only_tls_srp = true;
534 net::TestServer test_server(https_options, FilePath());
535 ASSERT_TRUE(test_server.Start());
536
537 TLSSRPClientLoginTestDelegate d;
538 {
539 GURL https_url = test_server.GetURL("tlslogininfo");
540 TestURLRequest r(https_url, &d);
541
542 r.Start();
543 EXPECT_TRUE(r.is_pending());
544 MessageLoop::current()->Run();
545 EXPECT_EQ(0, d.bytes_received());
546 EXPECT_FALSE(d.received_data_before_response());
547 EXPECT_EQ(1, d.on_tls_login_required_count());
548 CheckTLSAuthChallengeInfo(d.last_login_request_info(), https_url);
549
550 r.SetTLSLogin(kUser, kSecret);
551 r.ContinueWithTLSLogin();
552 MessageLoop::current()->Run();
553
554 EXPECT_NE(0, d.bytes_received());
555 EXPECT_TRUE(d.data_received().find(UTF16ToUTF8(kUser)) !=
556 std::string::npos);
557 EXPECT_FALSE(d.received_data_before_response());
558 }
559 }
560
561 // Open a connection to the same host using SSL certificate auth, and then open
562 // a connection to the same host requesting TLS-SRP auth.
563 // TODO(sqs): disabled - see todo below.
564 //
565 // TODO(sqs): This happens on, e.g., GnuTLS/mod_gnutls. If the Client Hello has
566 // no "srp" extension but has SRP cipher suites, GnuTLS will choose a non-SRP
567 // ciphersuite. Other implementations (OpenSSL, TLS Lite) will send
568 // "unknown_psk_identity".
569 TEST_F(HTTPSRequestTest, DISABLED_SSLCertThenWantUpgradeToSRP) {
570 net::TestServer::HTTPSOptions https_options;
571 https_options.use_tls_srp = true;
572 https_options.only_tls_srp = false;
573 net::TestServer test_server(https_options, FilePath());
574 ASSERT_TRUE(test_server.Start());
575
576 GURL https_url = test_server.GetURL("tlslogininfo");
577
578 {
579 TestDelegate d_https;
580 d_https.set_allow_certificate_errors(true);
581 TestURLRequest r_https(https_url, &d_https);
582 // TODO(sqs): need to force this connection to use certificate auth. Right
583 // now, TLS Lite sends unknown_psk_identity if the client lists SRP cipher
584 // suites even if no srp username is sent in the client hello. One way to
585 // force this is to set all of the SRP cipher suites as disabled in the
586 // URLRequest's ssl_config, but it's not accessible (ssl_config is actually
587 // much deeper than URLRequest).
588
589 r_https.Start();
590 EXPECT_TRUE(r_https.is_pending());
591 MessageLoop::current()->Run();
592 EXPECT_EQ(1, d_https.response_started_count());
593 EXPECT_NE(0, d_https.bytes_received());
594 CheckSSLInfo(r_https.ssl_info());
595
596 TLSSRPClientLoginTestDelegate d;
597 TestURLRequest r(https_url, &d);
598 r.Start();
599 EXPECT_TRUE(r.is_pending());
600
601 MessageLoop::current()->Run();
602 EXPECT_EQ(0, d.bytes_received());
603 EXPECT_FALSE(d.received_data_before_response());
604 EXPECT_EQ(1, d.on_tls_login_required_count());
605 CheckTLSAuthChallengeInfo(d.last_login_request_info(), https_url);
606
607 r.SetTLSLogin(kUser, kSecret);
608 r.ContinueWithTLSLogin();
609
610 MessageLoop::current()->Run();
611 EXPECT_NE(0, d.bytes_received());
612 EXPECT_TRUE(d.data_received().find(UTF16ToUTF8(kUser)) !=
613 std::string::npos);
614 EXPECT_FALSE(d.received_data_before_response());
615 }
616 }
617
618 TEST_F(HTTPSRequestTest, TLSLoginCredentialsRemainCached) {
619 net::TestServer::HTTPSOptions https_options;
620 https_options.use_tls_srp = true;
621 net::TestServer test_server(https_options, FilePath());
622 ASSERT_TRUE(test_server.Start());
623
624 GURL https_url = test_server.GetURL("");
625
626 GURL::Replacements replacements2;
627 replacements2.SetPathStr("tlslogininfo");
628 GURL https_url2 = https_url.ReplaceComponents(replacements2);
629
630 {
631 TLSSRPClientLoginTestDelegate d;
632 TestURLRequest r(https_url, &d);
633 r.Start();
634 EXPECT_TRUE(r.is_pending());
635
636 MessageLoop::current()->Run();
637 EXPECT_EQ(0, d.bytes_received());
638 EXPECT_FALSE(d.received_data_before_response());
639 EXPECT_EQ(1, d.on_tls_login_required_count());
640 CheckTLSAuthChallengeInfo(d.last_login_request_info(), https_url);
641
642 r.SetTLSLogin(kUser, kSecret);
643 r.ContinueWithTLSLogin();
644
645 MessageLoop::current()->Run();
646 EXPECT_NE(0, d.bytes_received());
647 EXPECT_FALSE(d.received_data_before_response());
648
649 // Don't specify credentials for this request.
650 TLSSRPClientLoginTestDelegate d2;
651 TestURLRequest r2(https_url2, &d2);
652 r2.Start();
653 EXPECT_TRUE(r2.is_pending());
654 MessageLoop::current()->Run();
655 EXPECT_NE(0, d2.bytes_received());
656 EXPECT_FALSE(d2.received_data_before_response());
657 LOG(INFO) << "GOT '" << d2.data_received() << "'";
658 EXPECT_TRUE(d2.data_received().find(UTF16ToUTF8(kUser)) !=
659 std::string::npos);
660 }
661 }
662
663 TEST_F(HTTPSRequestTest, TLSSRPLoginTest) {
664 net::TestServer::HTTPSOptions https_options;
665 https_options.use_tls_srp = true;
666 https_options.only_tls_srp = true;
667 net::TestServer test_server(https_options, FilePath());
668 ASSERT_TRUE(test_server.Start());
669
670 GURL https_url = test_server.GetURL("tlslogininfo");
671
672 {
673 TLSSRPClientLoginTestDelegate d;
674 TestURLRequest r(https_url, &d);
675 r.Start();
676 EXPECT_TRUE(r.is_pending());
677
678 MessageLoop::current()->Run();
679 EXPECT_EQ(0, d.bytes_received());
680 EXPECT_FALSE(d.received_data_before_response());
681 EXPECT_EQ(1, d.on_tls_login_required_count());
682 CheckTLSAuthChallengeInfo(d.last_login_request_info(), https_url);
683
684 r.SetTLSLogin(kUser, kSecret);
685 r.ContinueWithTLSLogin();
686
687 MessageLoop::current()->Run();
688 EXPECT_NE(0, d.bytes_received());
689 EXPECT_TRUE(d.data_received().find(UTF16ToUTF8(kUser)) !=
690 std::string::npos);
691 EXPECT_FALSE(d.received_data_before_response());
692 }
693 }
694
695 TEST_F(HTTPSRequestTest, TLSSRPSRPLoginWithCertTest) {
696 net::TestServer::HTTPSOptions https_options(
697 net::TestServer::HTTPSOptions::CERT_OK);
698 https_options.use_tls_srp = true;
699 net::TestServer test_server(https_options,
700 FilePath(FILE_PATH_LITERAL("net/data/ssl")));
701 ASSERT_TRUE(test_server.Start());
702
703 GURL https_url = test_server.GetURL("tlslogininfo");
704
705 TestDelegate d;
706 {
707 TestURLRequest r(https_url, &d);
708 r.SetTLSLogin(kUser, kSecret);
709
710 r.Start();
711 EXPECT_TRUE(r.is_pending());
712
713 MessageLoop::current()->Run();
714
715 EXPECT_EQ(1, d.response_started_count());
716 EXPECT_FALSE(d.received_data_before_response());
717 EXPECT_NE(0, d.bytes_received());
718 CheckSSLInfo(r.ssl_info());
719 EXPECT_FALSE(net::IsCertStatusError(r.ssl_info().cert_status));
720 EXPECT_TRUE(r.ssl_info().cert.get());
721 EXPECT_EQ(kUser, r.ssl_info().tls_username);
722 EXPECT_TRUE(d.data_received().find(UTF16ToUTF8(kUser)) !=
723 std::string::npos);
724 }
725 }
726
727 // Check that we still validate certs on SRP cipher suites that use certs.
728 TEST_F(HTTPSRequestTest, TLSSRPSRPBadCertFailureTest) {
729 bool cert_err_allowed = false;
730 for (int i = 0; i < 2; i++, cert_err_allowed = !cert_err_allowed) {
731 net::TestServer::HTTPSOptions https_options(
732 net::TestServer::HTTPSOptions::CERT_EXPIRED);
733 https_options.use_tls_srp = true;
734 net::TestServer test_server(https_options,
735 FilePath(FILE_PATH_LITERAL("net/data/ssl")));
736 ASSERT_TRUE(test_server.Start());
737
738 GURL https_url = test_server.GetURL("tlslogininfo");
739
740 TestDelegate d;
741 {
742 d.set_allow_certificate_errors(cert_err_allowed);
743 TestURLRequest r(https_url, &d);
744 r.SetTLSLogin(kUser, kSecret);
745
746 r.Start();
747 EXPECT_TRUE(r.is_pending());
748 MessageLoop::current()->Run();
749
750 EXPECT_EQ(1, d.response_started_count());
751 EXPECT_FALSE(d.received_data_before_response());
752 EXPECT_TRUE(d.have_certificate_errors());
753
754 if (cert_err_allowed) {
755 EXPECT_NE(0, d.bytes_received());
756 CheckSSLInfo(r.ssl_info());
757 EXPECT_TRUE(d.data_received().find(UTF16ToUTF8(kUser)) !=
758 std::string::npos);
759 } else {
760 EXPECT_EQ(0, d.bytes_received());
761 }
762 }
763 }
764 }
765
766 TEST_F(HTTPSRequestTest, TLSSRPBadSecretFailureTest) {
767 net::TestServer::HTTPSOptions https_options;
768 https_options.use_tls_srp = true;
769 https_options.only_tls_srp = true;
770 net::TestServer test_server(https_options, FilePath());
771 ASSERT_TRUE(test_server.Start());
772
773 GURL https_url = test_server.GetURL("tlslogininfo");
774
775 {
776 TLSSRPClientLoginTestDelegate d;
777
778 TestURLRequest r(https_url, &d);
779 // Try wrong password.
780 r.SetTLSLogin(kUser, kWrongSecret);
781 r.Start();
782 EXPECT_TRUE(r.is_pending());
783 MessageLoop::current()->Run();
784 EXPECT_EQ(0, d.bytes_received());
785 EXPECT_EQ(1, d.on_tls_login_required_count());
786 EXPECT_FALSE(d.received_data_before_response());
787
788 // Now continue with the correct password.
789 r.SetTLSLogin(kUser, kSecret);
790 r.ContinueWithTLSLogin();
791
792 MessageLoop::current()->Run();
793 EXPECT_NE(0, d.bytes_received());
794 EXPECT_TRUE(d.data_received().find(UTF16ToUTF8(kUser)) !=
795 std::string::npos);
796 EXPECT_FALSE(d.received_data_before_response());
797 }
798 }
799
800 TEST_F(HTTPSRequestTest, TLSSRPBadUsernameTest) {
801 net::TestServer::HTTPSOptions https_options;
802 https_options.use_tls_srp = true;
803 https_options.only_tls_srp = true;
804 net::TestServer test_server(https_options, FilePath());
805 ASSERT_TRUE(test_server.Start());
806
807 GURL https_url = test_server.GetURL("tlslogininfo");
808
809 {
810 TLSSRPClientLoginTestDelegate d;
811
812 TestURLRequest r(https_url, &d);
813 // Try wrong password.
814 r.SetTLSLogin(kWrongUser, kSecret);
815 r.Start();
816 EXPECT_TRUE(r.is_pending());
817 MessageLoop::current()->Run();
818 EXPECT_EQ(0, d.bytes_received());
819 EXPECT_FALSE(d.received_data_before_response());
820 EXPECT_EQ(1, d.on_tls_login_required_count());
821 CheckTLSAuthChallengeInfo(d.last_login_request_info(), https_url);
822
823 // Now continue with the correct password.
824 r.SetTLSLogin(kUser, kSecret);
825 r.ContinueWithTLSLogin();
826
827 MessageLoop::current()->Run();
828 EXPECT_NE(0, d.bytes_received());
829 EXPECT_TRUE(d.data_received().find(UTF16ToUTF8(kUser)) !=
830 std::string::npos);
831 EXPECT_FALSE(d.received_data_before_response());
832 }
833 }
834
835 TEST_F(HTTPSRequestTest, TLSSRPCancelLoginTest) {
836 net::TestServer::HTTPSOptions https_options;
837 https_options.use_tls_srp = true;
838 https_options.only_tls_srp = true;
839 net::TestServer test_server(https_options, FilePath());
840 ASSERT_TRUE(test_server.Start());
841
842 GURL https_url = test_server.GetURL("");
843
844 {
845 TLSSRPClientLoginTestDelegate d;
846
847 TestURLRequest r(https_url, &d);
848 r.Start();
849 EXPECT_TRUE(r.is_pending());
850 MessageLoop::current()->Run();
851
852 EXPECT_EQ(0, d.bytes_received());
853 EXPECT_EQ(1, d.on_tls_login_required_count());
854 EXPECT_FALSE(d.received_data_before_response());
855
856 r.CancelTLSLogin();
857
858 MessageLoop::current()->Run();
859 EXPECT_EQ(0, d.bytes_received());
860 EXPECT_FALSE(d.received_data_before_response());
861 }
862 }
863
466 TEST_F(URLRequestTestHTTP, CancelTest) { 864 TEST_F(URLRequestTestHTTP, CancelTest) {
467 TestDelegate d; 865 TestDelegate d;
468 { 866 {
469 TestURLRequest r(GURL("http://www.google.com/"), &d); 867 TestURLRequest r(GURL("http://www.google.com/"), &d);
470 868
471 r.Start(); 869 r.Start();
472 EXPECT_TRUE(r.is_pending()); 870 EXPECT_TRUE(r.is_pending());
473 871
474 r.Cancel(); 872 r.Cancel();
475 873
(...skipping 2253 matching lines...) Expand 10 before | Expand all | Expand 10 after
2729 net::HttpRequestHeaders headers; 3127 net::HttpRequestHeaders headers;
2730 headers.SetHeader(net::HttpRequestHeaders::kUserAgent, "Lynx (textmode)"); 3128 headers.SetHeader(net::HttpRequestHeaders::kUserAgent, "Lynx (textmode)");
2731 req.SetExtraRequestHeaders(headers); 3129 req.SetExtraRequestHeaders(headers);
2732 req.Start(); 3130 req.Start();
2733 MessageLoop::current()->Run(); 3131 MessageLoop::current()->Run();
2734 // If the net tests are being run with ChromeFrame then we need to allow for 3132 // If the net tests are being run with ChromeFrame then we need to allow for
2735 // the 'chromeframe' suffix which is added to the user agent before the 3133 // the 'chromeframe' suffix which is added to the user agent before the
2736 // closing parentheses. 3134 // closing parentheses.
2737 EXPECT_TRUE(StartsWithASCII(d.data_received(), "Lynx (textmode", true)); 3135 EXPECT_TRUE(StartsWithASCII(d.data_received(), "Lynx (textmode", true));
2738 } 3136 }
OLDNEW
« no previous file with comments | « net/url_request/url_request_test_util.cc ('k') | third_party/tlslite/README.chromium » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698