| 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/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 EXPECT_TRUE(auth.HasPendingFetch()); | 611 EXPECT_TRUE(auth.HasPendingFetch()); |
| 612 MockFetcher mock_fetcher2( | 612 MockFetcher mock_fetcher2( |
| 613 oauth2_token_source_, | 613 oauth2_token_source_, |
| 614 net::URLRequestStatus(net::URLRequestStatus::SUCCESS, 0), | 614 net::URLRequestStatus(net::URLRequestStatus::SUCCESS, 0), |
| 615 net::HTTP_OK, cookies_, kGetTokenPairValidResponse, | 615 net::HTTP_OK, cookies_, kGetTokenPairValidResponse, |
| 616 content::URLFetcher::POST, &auth); | 616 content::URLFetcher::POST, &auth); |
| 617 auth.OnURLFetchComplete(&mock_fetcher2); | 617 auth.OnURLFetchComplete(&mock_fetcher2); |
| 618 EXPECT_FALSE(auth.HasPendingFetch()); | 618 EXPECT_FALSE(auth.HasPendingFetch()); |
| 619 } | 619 } |
| 620 | 620 |
| 621 TEST_F(GaiaAuthFetcherTest, OAuthLoginTokenWithEmptyToken) { | 621 TEST_F(GaiaAuthFetcherTest, OAuthLoginTokenWithCookies) { |
| 622 MockGaiaConsumer consumer; | 622 MockGaiaConsumer consumer; |
| 623 TestingProfile profile; | 623 TestingProfile profile; |
| 624 TestURLFetcherFactory factory; | 624 TestURLFetcherFactory factory; |
| 625 GaiaAuthFetcher auth(&consumer, std::string(), | 625 GaiaAuthFetcher auth(&consumer, std::string(), |
| 626 profile_.GetRequestContext()); | 626 profile_.GetRequestContext()); |
| 627 auth.StartOAuthLoginTokenFetch(""); | 627 auth.StartOAuthLoginTokenFetchWithCookies("0"); |
| 628 TestURLFetcher* fetcher = factory.GetFetcherByID(0); | 628 TestURLFetcher* fetcher = factory.GetFetcherByID(0); |
| 629 EXPECT_TRUE(NULL != fetcher); | 629 EXPECT_TRUE(NULL != fetcher); |
| 630 EXPECT_EQ(net::LOAD_NORMAL, fetcher->GetLoadFlags()); | 630 EXPECT_EQ(net::LOAD_NORMAL, fetcher->GetLoadFlags()); |
| 631 } | 631 } |
| 632 | 632 |
| 633 TEST_F(GaiaAuthFetcherTest, OAuthLoginTokenClientLoginToOAuth2Failure) { | 633 TEST_F(GaiaAuthFetcherTest, OAuthLoginTokenClientLoginToOAuth2Failure) { |
| 634 MockGaiaConsumer consumer; | 634 MockGaiaConsumer consumer; |
| 635 EXPECT_CALL(consumer, OnOAuthLoginTokenFailure(_)) | 635 EXPECT_CALL(consumer, OnOAuthLoginTokenFailure(_)) |
| 636 .Times(1); | 636 .Times(1); |
| 637 | 637 |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 908 std::string rt; | 908 std::string rt; |
| 909 std::string at; | 909 std::string at; |
| 910 int exp = -1; | 910 int exp = -1; |
| 911 EXPECT_TRUE(GaiaAuthFetcher::ParseOAuth2TokenPairResponse( | 911 EXPECT_TRUE(GaiaAuthFetcher::ParseOAuth2TokenPairResponse( |
| 912 kGetTokenPairValidResponse, &rt, &at, &exp)); | 912 kGetTokenPairValidResponse, &rt, &at, &exp)); |
| 913 EXPECT_EQ("rt1", rt); | 913 EXPECT_EQ("rt1", rt); |
| 914 EXPECT_EQ("at1", at); | 914 EXPECT_EQ("at1", at); |
| 915 EXPECT_EQ(3600, exp); | 915 EXPECT_EQ(3600, exp); |
| 916 } | 916 } |
| 917 } | 917 } |
| OLD | NEW |