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 // A complete set of unit tests for GaiaAuthFetcher. | 5 // A complete set of unit tests for GaiaAuthFetcher. |
6 // Originally ported from GoogleAuthenticator tests. | 6 // Originally ported from GoogleAuthenticator tests. |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
12 #include "base/stringprintf.h" | 12 #include "base/stringprintf.h" |
13 #include "base/values.h" | 13 #include "base/values.h" |
14 #include "chrome/common/net/gaia/gaia_auth_consumer.h" | 14 #include "chrome/common/net/gaia/gaia_auth_consumer.h" |
15 #include "chrome/common/net/gaia/gaia_auth_fetcher.h" | 15 #include "chrome/common/net/gaia/gaia_auth_fetcher.h" |
16 #include "chrome/common/net/gaia/gaia_urls.h" | 16 #include "chrome/common/net/gaia/gaia_urls.h" |
17 #include "chrome/common/net/gaia/google_service_auth_error.h" | 17 #include "chrome/common/net/gaia/google_service_auth_error.h" |
18 #include "chrome/common/net/gaia/mock_url_fetcher_factory.h" | 18 #include "chrome/common/net/gaia/mock_url_fetcher_factory.h" |
19 #include "chrome/test/base/testing_profile.h" | 19 #include "chrome/test/base/testing_profile.h" |
20 #include "content/public/test/test_url_fetcher_factory.h" | |
21 #include "googleurl/src/gurl.h" | 20 #include "googleurl/src/gurl.h" |
22 #include "net/base/load_flags.h" | 21 #include "net/base/load_flags.h" |
23 #include "net/base/net_errors.h" | 22 #include "net/base/net_errors.h" |
24 #include "net/http/http_status_code.h" | 23 #include "net/http/http_status_code.h" |
| 24 #include "net/url_request/test_url_fetcher_factory.h" |
25 #include "net/url_request/url_fetcher_delegate.h" | 25 #include "net/url_request/url_fetcher_delegate.h" |
26 #include "net/url_request/url_request_status.h" | 26 #include "net/url_request/url_request_status.h" |
27 #include "testing/gmock/include/gmock/gmock.h" | 27 #include "testing/gmock/include/gmock/gmock.h" |
28 #include "testing/gtest/include/gtest/gtest.h" | 28 #include "testing/gtest/include/gtest/gtest.h" |
29 | 29 |
30 using ::testing::_; | 30 using ::testing::_; |
31 using ::testing::Invoke; | 31 using ::testing::Invoke; |
32 | 32 |
33 namespace { | 33 namespace { |
34 static const char kGetAuthCodeValidCookie[] = | 34 static const char kGetAuthCodeValidCookie[] = |
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 std::string(), | 524 std::string(), |
525 std::string(), | 525 std::string(), |
526 GaiaAuthFetcher::HostedAccountsAllowed); | 526 GaiaAuthFetcher::HostedAccountsAllowed); |
527 } | 527 } |
528 | 528 |
529 TEST_F(GaiaAuthFetcherTest, ClientFetchPending) { | 529 TEST_F(GaiaAuthFetcherTest, ClientFetchPending) { |
530 MockGaiaConsumer consumer; | 530 MockGaiaConsumer consumer; |
531 EXPECT_CALL(consumer, OnClientLoginSuccess(_)) | 531 EXPECT_CALL(consumer, OnClientLoginSuccess(_)) |
532 .Times(1); | 532 .Times(1); |
533 | 533 |
534 TestURLFetcherFactory factory; | 534 net::TestURLFetcherFactory factory; |
535 | 535 |
536 GaiaAuthFetcher auth(&consumer, std::string(), | 536 GaiaAuthFetcher auth(&consumer, std::string(), |
537 profile_.GetRequestContext()); | 537 profile_.GetRequestContext()); |
538 auth.StartClientLogin("username", | 538 auth.StartClientLogin("username", |
539 "password", | 539 "password", |
540 "service", | 540 "service", |
541 std::string(), | 541 std::string(), |
542 std::string(), | 542 std::string(), |
543 GaiaAuthFetcher::HostedAccountsAllowed); | 543 GaiaAuthFetcher::HostedAccountsAllowed); |
544 | 544 |
545 EXPECT_TRUE(auth.HasPendingFetch()); | 545 EXPECT_TRUE(auth.HasPendingFetch()); |
546 MockFetcher mock_fetcher( | 546 MockFetcher mock_fetcher( |
547 client_login_source_, | 547 client_login_source_, |
548 net::URLRequestStatus(net::URLRequestStatus::SUCCESS, 0), | 548 net::URLRequestStatus(net::URLRequestStatus::SUCCESS, 0), |
549 net::HTTP_OK, cookies_, "SID=sid\nLSID=lsid\nAuth=auth\n", | 549 net::HTTP_OK, cookies_, "SID=sid\nLSID=lsid\nAuth=auth\n", |
550 net::URLFetcher::GET, &auth); | 550 net::URLFetcher::GET, &auth); |
551 auth.OnURLFetchComplete(&mock_fetcher); | 551 auth.OnURLFetchComplete(&mock_fetcher); |
552 EXPECT_FALSE(auth.HasPendingFetch()); | 552 EXPECT_FALSE(auth.HasPendingFetch()); |
553 } | 553 } |
554 | 554 |
555 TEST_F(GaiaAuthFetcherTest, FullTokenSuccess) { | 555 TEST_F(GaiaAuthFetcherTest, FullTokenSuccess) { |
556 MockGaiaConsumer consumer; | 556 MockGaiaConsumer consumer; |
557 EXPECT_CALL(consumer, OnIssueAuthTokenSuccess("service", "token")) | 557 EXPECT_CALL(consumer, OnIssueAuthTokenSuccess("service", "token")) |
558 .Times(1); | 558 .Times(1); |
559 | 559 |
560 TestURLFetcherFactory factory; | 560 net::TestURLFetcherFactory factory; |
561 GaiaAuthFetcher auth(&consumer, std::string(), | 561 GaiaAuthFetcher auth(&consumer, std::string(), |
562 profile_.GetRequestContext()); | 562 profile_.GetRequestContext()); |
563 auth.StartIssueAuthToken("sid", "lsid", "service"); | 563 auth.StartIssueAuthToken("sid", "lsid", "service"); |
564 | 564 |
565 EXPECT_TRUE(auth.HasPendingFetch()); | 565 EXPECT_TRUE(auth.HasPendingFetch()); |
566 MockFetcher mock_fetcher( | 566 MockFetcher mock_fetcher( |
567 issue_auth_token_source_, | 567 issue_auth_token_source_, |
568 net::URLRequestStatus(net::URLRequestStatus::SUCCESS, 0), | 568 net::URLRequestStatus(net::URLRequestStatus::SUCCESS, 0), |
569 net::HTTP_OK, cookies_, "token", | 569 net::HTTP_OK, cookies_, "token", |
570 net::URLFetcher::GET, &auth); | 570 net::URLFetcher::GET, &auth); |
571 auth.OnURLFetchComplete(&mock_fetcher); | 571 auth.OnURLFetchComplete(&mock_fetcher); |
572 EXPECT_FALSE(auth.HasPendingFetch()); | 572 EXPECT_FALSE(auth.HasPendingFetch()); |
573 } | 573 } |
574 | 574 |
575 TEST_F(GaiaAuthFetcherTest, FullTokenFailure) { | 575 TEST_F(GaiaAuthFetcherTest, FullTokenFailure) { |
576 MockGaiaConsumer consumer; | 576 MockGaiaConsumer consumer; |
577 EXPECT_CALL(consumer, OnIssueAuthTokenFailure("service", _)) | 577 EXPECT_CALL(consumer, OnIssueAuthTokenFailure("service", _)) |
578 .Times(1); | 578 .Times(1); |
579 | 579 |
580 TestURLFetcherFactory factory; | 580 net::TestURLFetcherFactory factory; |
581 | 581 |
582 GaiaAuthFetcher auth(&consumer, std::string(), | 582 GaiaAuthFetcher auth(&consumer, std::string(), |
583 profile_.GetRequestContext()); | 583 profile_.GetRequestContext()); |
584 auth.StartIssueAuthToken("sid", "lsid", "service"); | 584 auth.StartIssueAuthToken("sid", "lsid", "service"); |
585 | 585 |
586 EXPECT_TRUE(auth.HasPendingFetch()); | 586 EXPECT_TRUE(auth.HasPendingFetch()); |
587 MockFetcher mock_fetcher( | 587 MockFetcher mock_fetcher( |
588 issue_auth_token_source_, | 588 issue_auth_token_source_, |
589 net::URLRequestStatus(net::URLRequestStatus::SUCCESS, 0), | 589 net::URLRequestStatus(net::URLRequestStatus::SUCCESS, 0), |
590 net::HTTP_FORBIDDEN, cookies_, "", net::URLFetcher::GET, &auth); | 590 net::HTTP_FORBIDDEN, cookies_, "", net::URLFetcher::GET, &auth); |
591 auth.OnURLFetchComplete(&mock_fetcher); | 591 auth.OnURLFetchComplete(&mock_fetcher); |
592 EXPECT_FALSE(auth.HasPendingFetch()); | 592 EXPECT_FALSE(auth.HasPendingFetch()); |
593 } | 593 } |
594 | 594 |
595 TEST_F(GaiaAuthFetcherTest, OAuthLoginTokenSuccess) { | 595 TEST_F(GaiaAuthFetcherTest, OAuthLoginTokenSuccess) { |
596 MockGaiaConsumer consumer; | 596 MockGaiaConsumer consumer; |
597 EXPECT_CALL(consumer, OnClientOAuthSuccess( | 597 EXPECT_CALL(consumer, OnClientOAuthSuccess( |
598 GaiaAuthConsumer::ClientOAuthResult("rt1", "at1", 3600))).Times(1); | 598 GaiaAuthConsumer::ClientOAuthResult("rt1", "at1", 3600))).Times(1); |
599 | 599 |
600 TestURLFetcherFactory factory; | 600 net::TestURLFetcherFactory factory; |
601 GaiaAuthFetcher auth(&consumer, std::string(), | 601 GaiaAuthFetcher auth(&consumer, std::string(), |
602 profile_.GetRequestContext()); | 602 profile_.GetRequestContext()); |
603 auth.StartLsoForOAuthLoginTokenExchange("lso_token"); | 603 auth.StartLsoForOAuthLoginTokenExchange("lso_token"); |
604 TestURLFetcher* fetcher = factory.GetFetcherByID(0); | 604 net::TestURLFetcher* fetcher = factory.GetFetcherByID(0); |
605 EXPECT_TRUE(NULL != fetcher); | 605 EXPECT_TRUE(NULL != fetcher); |
606 EXPECT_EQ(net::LOAD_DO_NOT_SEND_COOKIES | net::LOAD_DO_NOT_SAVE_COOKIES, | 606 EXPECT_EQ(net::LOAD_DO_NOT_SEND_COOKIES | net::LOAD_DO_NOT_SAVE_COOKIES, |
607 fetcher->GetLoadFlags()); | 607 fetcher->GetLoadFlags()); |
608 | 608 |
609 net::ResponseCookies cookies; | 609 net::ResponseCookies cookies; |
610 cookies.push_back(kGetAuthCodeValidCookie); | 610 cookies.push_back(kGetAuthCodeValidCookie); |
611 EXPECT_TRUE(auth.HasPendingFetch()); | 611 EXPECT_TRUE(auth.HasPendingFetch()); |
612 MockFetcher mock_fetcher1( | 612 MockFetcher mock_fetcher1( |
613 client_login_to_oauth2_source_, | 613 client_login_to_oauth2_source_, |
614 net::URLRequestStatus(net::URLRequestStatus::SUCCESS, 0), | 614 net::URLRequestStatus(net::URLRequestStatus::SUCCESS, 0), |
615 net::HTTP_OK, cookies, "", | 615 net::HTTP_OK, cookies, "", |
616 net::URLFetcher::POST, &auth); | 616 net::URLFetcher::POST, &auth); |
617 auth.OnURLFetchComplete(&mock_fetcher1); | 617 auth.OnURLFetchComplete(&mock_fetcher1); |
618 EXPECT_TRUE(auth.HasPendingFetch()); | 618 EXPECT_TRUE(auth.HasPendingFetch()); |
619 MockFetcher mock_fetcher2( | 619 MockFetcher mock_fetcher2( |
620 oauth2_token_source_, | 620 oauth2_token_source_, |
621 net::URLRequestStatus(net::URLRequestStatus::SUCCESS, 0), | 621 net::URLRequestStatus(net::URLRequestStatus::SUCCESS, 0), |
622 net::HTTP_OK, cookies_, kGetTokenPairValidResponse, | 622 net::HTTP_OK, cookies_, kGetTokenPairValidResponse, |
623 net::URLFetcher::POST, &auth); | 623 net::URLFetcher::POST, &auth); |
624 auth.OnURLFetchComplete(&mock_fetcher2); | 624 auth.OnURLFetchComplete(&mock_fetcher2); |
625 EXPECT_FALSE(auth.HasPendingFetch()); | 625 EXPECT_FALSE(auth.HasPendingFetch()); |
626 } | 626 } |
627 | 627 |
628 TEST_F(GaiaAuthFetcherTest, OAuthLoginTokenWithCookies) { | 628 TEST_F(GaiaAuthFetcherTest, OAuthLoginTokenWithCookies) { |
629 MockGaiaConsumer consumer; | 629 MockGaiaConsumer consumer; |
630 TestURLFetcherFactory factory; | 630 net::TestURLFetcherFactory factory; |
631 GaiaAuthFetcher auth(&consumer, std::string(), | 631 GaiaAuthFetcher auth(&consumer, std::string(), |
632 profile_.GetRequestContext()); | 632 profile_.GetRequestContext()); |
633 auth.StartCookieForOAuthLoginTokenExchange("0"); | 633 auth.StartCookieForOAuthLoginTokenExchange("0"); |
634 TestURLFetcher* fetcher = factory.GetFetcherByID(0); | 634 net::TestURLFetcher* fetcher = factory.GetFetcherByID(0); |
635 EXPECT_TRUE(NULL != fetcher); | 635 EXPECT_TRUE(NULL != fetcher); |
636 EXPECT_EQ(net::LOAD_NORMAL, fetcher->GetLoadFlags()); | 636 EXPECT_EQ(net::LOAD_NORMAL, fetcher->GetLoadFlags()); |
637 } | 637 } |
638 | 638 |
639 TEST_F(GaiaAuthFetcherTest, OAuthLoginTokenClientLoginToOAuth2Failure) { | 639 TEST_F(GaiaAuthFetcherTest, OAuthLoginTokenClientLoginToOAuth2Failure) { |
640 MockGaiaConsumer consumer; | 640 MockGaiaConsumer consumer; |
641 EXPECT_CALL(consumer, OnClientOAuthFailure(_)) | 641 EXPECT_CALL(consumer, OnClientOAuthFailure(_)) |
642 .Times(1); | 642 .Times(1); |
643 | 643 |
644 TestURLFetcherFactory factory; | 644 net::TestURLFetcherFactory factory; |
645 GaiaAuthFetcher auth(&consumer, std::string(), | 645 GaiaAuthFetcher auth(&consumer, std::string(), |
646 profile_.GetRequestContext()); | 646 profile_.GetRequestContext()); |
647 auth.StartLsoForOAuthLoginTokenExchange("lso_token"); | 647 auth.StartLsoForOAuthLoginTokenExchange("lso_token"); |
648 | 648 |
649 net::ResponseCookies cookies; | 649 net::ResponseCookies cookies; |
650 EXPECT_TRUE(auth.HasPendingFetch()); | 650 EXPECT_TRUE(auth.HasPendingFetch()); |
651 MockFetcher mock_fetcher( | 651 MockFetcher mock_fetcher( |
652 client_login_to_oauth2_source_, | 652 client_login_to_oauth2_source_, |
653 net::URLRequestStatus(net::URLRequestStatus::SUCCESS, 0), | 653 net::URLRequestStatus(net::URLRequestStatus::SUCCESS, 0), |
654 net::HTTP_FORBIDDEN, cookies, "", | 654 net::HTTP_FORBIDDEN, cookies, "", |
655 net::URLFetcher::POST, &auth); | 655 net::URLFetcher::POST, &auth); |
656 auth.OnURLFetchComplete(&mock_fetcher); | 656 auth.OnURLFetchComplete(&mock_fetcher); |
657 EXPECT_FALSE(auth.HasPendingFetch()); | 657 EXPECT_FALSE(auth.HasPendingFetch()); |
658 } | 658 } |
659 | 659 |
660 TEST_F(GaiaAuthFetcherTest, OAuthLoginTokenOAuth2TokenPairFailure) { | 660 TEST_F(GaiaAuthFetcherTest, OAuthLoginTokenOAuth2TokenPairFailure) { |
661 MockGaiaConsumer consumer; | 661 MockGaiaConsumer consumer; |
662 EXPECT_CALL(consumer, OnClientOAuthFailure(_)) | 662 EXPECT_CALL(consumer, OnClientOAuthFailure(_)) |
663 .Times(1); | 663 .Times(1); |
664 | 664 |
665 TestURLFetcherFactory factory; | 665 net::TestURLFetcherFactory factory; |
666 GaiaAuthFetcher auth(&consumer, std::string(), | 666 GaiaAuthFetcher auth(&consumer, std::string(), |
667 profile_.GetRequestContext()); | 667 profile_.GetRequestContext()); |
668 auth.StartLsoForOAuthLoginTokenExchange("lso_token"); | 668 auth.StartLsoForOAuthLoginTokenExchange("lso_token"); |
669 | 669 |
670 net::ResponseCookies cookies; | 670 net::ResponseCookies cookies; |
671 cookies.push_back(kGetAuthCodeValidCookie); | 671 cookies.push_back(kGetAuthCodeValidCookie); |
672 EXPECT_TRUE(auth.HasPendingFetch()); | 672 EXPECT_TRUE(auth.HasPendingFetch()); |
673 MockFetcher mock_fetcher1( | 673 MockFetcher mock_fetcher1( |
674 client_login_to_oauth2_source_, | 674 client_login_to_oauth2_source_, |
675 net::URLRequestStatus(net::URLRequestStatus::SUCCESS, 0), | 675 net::URLRequestStatus(net::URLRequestStatus::SUCCESS, 0), |
676 net::HTTP_OK, cookies, "", | 676 net::HTTP_OK, cookies, "", |
677 net::URLFetcher::POST, &auth); | 677 net::URLFetcher::POST, &auth); |
678 auth.OnURLFetchComplete(&mock_fetcher1); | 678 auth.OnURLFetchComplete(&mock_fetcher1); |
679 EXPECT_TRUE(auth.HasPendingFetch()); | 679 EXPECT_TRUE(auth.HasPendingFetch()); |
680 MockFetcher mock_fetcher2( | 680 MockFetcher mock_fetcher2( |
681 oauth2_token_source_, | 681 oauth2_token_source_, |
682 net::URLRequestStatus(net::URLRequestStatus::SUCCESS, 0), | 682 net::URLRequestStatus(net::URLRequestStatus::SUCCESS, 0), |
683 net::HTTP_FORBIDDEN, cookies_, "", | 683 net::HTTP_FORBIDDEN, cookies_, "", |
684 net::URLFetcher::POST, &auth); | 684 net::URLFetcher::POST, &auth); |
685 auth.OnURLFetchComplete(&mock_fetcher2); | 685 auth.OnURLFetchComplete(&mock_fetcher2); |
686 EXPECT_FALSE(auth.HasPendingFetch()); | 686 EXPECT_FALSE(auth.HasPendingFetch()); |
687 } | 687 } |
688 | 688 |
689 TEST_F(GaiaAuthFetcherTest, MergeSessionSuccess) { | 689 TEST_F(GaiaAuthFetcherTest, MergeSessionSuccess) { |
690 MockGaiaConsumer consumer; | 690 MockGaiaConsumer consumer; |
691 EXPECT_CALL(consumer, OnMergeSessionSuccess("<html></html>")) | 691 EXPECT_CALL(consumer, OnMergeSessionSuccess("<html></html>")) |
692 .Times(1); | 692 .Times(1); |
693 | 693 |
694 TestURLFetcherFactory factory; | 694 net::TestURLFetcherFactory factory; |
695 | 695 |
696 GaiaAuthFetcher auth(&consumer, std::string(), | 696 GaiaAuthFetcher auth(&consumer, std::string(), |
697 profile_.GetRequestContext()); | 697 profile_.GetRequestContext()); |
698 auth.StartMergeSession("myubertoken"); | 698 auth.StartMergeSession("myubertoken"); |
699 | 699 |
700 EXPECT_TRUE(auth.HasPendingFetch()); | 700 EXPECT_TRUE(auth.HasPendingFetch()); |
701 MockFetcher mock_fetcher( | 701 MockFetcher mock_fetcher( |
702 merge_session_source_, | 702 merge_session_source_, |
703 net::URLRequestStatus(net::URLRequestStatus::SUCCESS, 0), | 703 net::URLRequestStatus(net::URLRequestStatus::SUCCESS, 0), |
704 net::HTTP_OK, cookies_, "<html></html>", net::URLFetcher::GET, | 704 net::HTTP_OK, cookies_, "<html></html>", net::URLFetcher::GET, |
705 &auth); | 705 &auth); |
706 auth.OnURLFetchComplete(&mock_fetcher); | 706 auth.OnURLFetchComplete(&mock_fetcher); |
707 EXPECT_FALSE(auth.HasPendingFetch()); | 707 EXPECT_FALSE(auth.HasPendingFetch()); |
708 } | 708 } |
709 | 709 |
710 TEST_F(GaiaAuthFetcherTest, MergeSessionSuccessRedirect) { | 710 TEST_F(GaiaAuthFetcherTest, MergeSessionSuccessRedirect) { |
711 MockGaiaConsumer consumer; | 711 MockGaiaConsumer consumer; |
712 EXPECT_CALL(consumer, OnMergeSessionSuccess("<html></html>")) | 712 EXPECT_CALL(consumer, OnMergeSessionSuccess("<html></html>")) |
713 .Times(1); | 713 .Times(1); |
714 | 714 |
715 TestURLFetcherFactory factory; | 715 net::TestURLFetcherFactory factory; |
716 | 716 |
717 GaiaAuthFetcher auth(&consumer, std::string(), | 717 GaiaAuthFetcher auth(&consumer, std::string(), |
718 profile_.GetRequestContext()); | 718 profile_.GetRequestContext()); |
719 auth.StartMergeSession("myubertoken"); | 719 auth.StartMergeSession("myubertoken"); |
720 | 720 |
721 // Make sure the fetcher created has the expected flags. Set its url() | 721 // Make sure the fetcher created has the expected flags. Set its url() |
722 // properties to reflect a redirect. | 722 // properties to reflect a redirect. |
723 TestURLFetcher* test_fetcher = factory.GetFetcherByID(0); | 723 net::TestURLFetcher* test_fetcher = factory.GetFetcherByID(0); |
724 EXPECT_TRUE(test_fetcher != NULL); | 724 EXPECT_TRUE(test_fetcher != NULL); |
725 EXPECT_TRUE(test_fetcher->GetLoadFlags() == net::LOAD_NORMAL); | 725 EXPECT_TRUE(test_fetcher->GetLoadFlags() == net::LOAD_NORMAL); |
726 EXPECT_TRUE(auth.HasPendingFetch()); | 726 EXPECT_TRUE(auth.HasPendingFetch()); |
727 | 727 |
728 GURL final_url("http://www.google.com/CheckCookie"); | 728 GURL final_url("http://www.google.com/CheckCookie"); |
729 test_fetcher->set_url(final_url); | 729 test_fetcher->set_url(final_url); |
730 test_fetcher->set_status( | 730 test_fetcher->set_status( |
731 net::URLRequestStatus(net::URLRequestStatus::SUCCESS, 0)); | 731 net::URLRequestStatus(net::URLRequestStatus::SUCCESS, 0)); |
732 test_fetcher->set_response_code(net::HTTP_OK); | 732 test_fetcher->set_response_code(net::HTTP_OK); |
733 test_fetcher->set_cookies(cookies_); | 733 test_fetcher->set_cookies(cookies_); |
734 test_fetcher->SetResponseString("<html></html>"); | 734 test_fetcher->SetResponseString("<html></html>"); |
735 | 735 |
736 auth.OnURLFetchComplete(test_fetcher); | 736 auth.OnURLFetchComplete(test_fetcher); |
737 EXPECT_FALSE(auth.HasPendingFetch()); | 737 EXPECT_FALSE(auth.HasPendingFetch()); |
738 } | 738 } |
739 | 739 |
740 TEST_F(GaiaAuthFetcherTest, UberAuthTokenSuccess) { | 740 TEST_F(GaiaAuthFetcherTest, UberAuthTokenSuccess) { |
741 MockGaiaConsumer consumer; | 741 MockGaiaConsumer consumer; |
742 EXPECT_CALL(consumer, OnUberAuthTokenSuccess("uberToken")) | 742 EXPECT_CALL(consumer, OnUberAuthTokenSuccess("uberToken")) |
743 .Times(1); | 743 .Times(1); |
744 | 744 |
745 TestURLFetcherFactory factory; | 745 net::TestURLFetcherFactory factory; |
746 | 746 |
747 GaiaAuthFetcher auth(&consumer, std::string(), | 747 GaiaAuthFetcher auth(&consumer, std::string(), |
748 profile_.GetRequestContext()); | 748 profile_.GetRequestContext()); |
749 auth.StartTokenFetchForUberAuthExchange("myAccessToken"); | 749 auth.StartTokenFetchForUberAuthExchange("myAccessToken"); |
750 | 750 |
751 EXPECT_TRUE(auth.HasPendingFetch()); | 751 EXPECT_TRUE(auth.HasPendingFetch()); |
752 MockFetcher mock_fetcher( | 752 MockFetcher mock_fetcher( |
753 uberauth_token_source_, | 753 uberauth_token_source_, |
754 net::URLRequestStatus(net::URLRequestStatus::SUCCESS, 0), | 754 net::URLRequestStatus(net::URLRequestStatus::SUCCESS, 0), |
755 net::HTTP_OK, cookies_, "uberToken", net::URLFetcher::POST, | 755 net::HTTP_OK, cookies_, "uberToken", net::URLFetcher::POST, |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1012 .Times(1); | 1012 .Times(1); |
1013 | 1013 |
1014 GaiaAuthFetcher auth(&consumer, std::string(), | 1014 GaiaAuthFetcher auth(&consumer, std::string(), |
1015 profile_.GetRequestContext()); | 1015 profile_.GetRequestContext()); |
1016 net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0); | 1016 net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0); |
1017 MockFetcher mock_fetcher( | 1017 MockFetcher mock_fetcher( |
1018 oauth_login_gurl_, status, net::HTTP_OK, cookies_, data, | 1018 oauth_login_gurl_, status, net::HTTP_OK, cookies_, data, |
1019 net::URLFetcher::GET, &auth); | 1019 net::URLFetcher::GET, &auth); |
1020 auth.OnURLFetchComplete(&mock_fetcher); | 1020 auth.OnURLFetchComplete(&mock_fetcher); |
1021 } | 1021 } |
OLD | NEW |