OLD | NEW |
1 // Copyright (c) 2011 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 "chrome/common/net/gaia/gaia_auth_fetcher_unittest.h" | 8 #include "chrome/common/net/gaia/gaia_auth_fetcher_unittest.h" |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 | 11 |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 TEST_F(GaiaAuthFetcherTest, CaptchaParse) { | 373 TEST_F(GaiaAuthFetcherTest, CaptchaParse) { |
374 net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0); | 374 net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0); |
375 std::string data = "Url=http://www.google.com/login/captcha\n" | 375 std::string data = "Url=http://www.google.com/login/captcha\n" |
376 "Error=CaptchaRequired\n" | 376 "Error=CaptchaRequired\n" |
377 "CaptchaToken=CCTOKEN\n" | 377 "CaptchaToken=CCTOKEN\n" |
378 "CaptchaUrl=Captcha?ctoken=CCTOKEN\n"; | 378 "CaptchaUrl=Captcha?ctoken=CCTOKEN\n"; |
379 GoogleServiceAuthError error = | 379 GoogleServiceAuthError error = |
380 GaiaAuthFetcher::GenerateAuthError(data, status); | 380 GaiaAuthFetcher::GenerateAuthError(data, status); |
381 | 381 |
382 std::string token = "CCTOKEN"; | 382 std::string token = "CCTOKEN"; |
383 GURL image_url("http://www.google.com/accounts/Captcha?ctoken=CCTOKEN"); | 383 GURL image_url("http://accounts.google.com/Captcha?ctoken=CCTOKEN"); |
384 GURL unlock_url("http://www.google.com/login/captcha"); | 384 GURL unlock_url("http://www.google.com/login/captcha"); |
385 | 385 |
386 EXPECT_EQ(error.state(), GoogleServiceAuthError::CAPTCHA_REQUIRED); | 386 EXPECT_EQ(error.state(), GoogleServiceAuthError::CAPTCHA_REQUIRED); |
387 EXPECT_EQ(error.captcha().token, token); | 387 EXPECT_EQ(error.captcha().token, token); |
388 EXPECT_EQ(error.captcha().image_url, image_url); | 388 EXPECT_EQ(error.captcha().image_url, image_url); |
389 EXPECT_EQ(error.captcha().unlock_url, unlock_url); | 389 EXPECT_EQ(error.captcha().unlock_url, unlock_url); |
390 } | 390 } |
391 | 391 |
392 TEST_F(GaiaAuthFetcherTest, AccountDeletedError) { | 392 TEST_F(GaiaAuthFetcherTest, AccountDeletedError) { |
393 net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0); | 393 net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0); |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
856 std::string rt; | 856 std::string rt; |
857 std::string at; | 857 std::string at; |
858 int exp = -1; | 858 int exp = -1; |
859 EXPECT_TRUE(GaiaAuthFetcher::ParseOAuth2TokenPairResponse( | 859 EXPECT_TRUE(GaiaAuthFetcher::ParseOAuth2TokenPairResponse( |
860 kGetTokenPairValidResponse, &rt, &at, &exp)); | 860 kGetTokenPairValidResponse, &rt, &at, &exp)); |
861 EXPECT_EQ("rt1", rt); | 861 EXPECT_EQ("rt1", rt); |
862 EXPECT_EQ("at1", at); | 862 EXPECT_EQ("at1", at); |
863 EXPECT_EQ(3600, exp); | 863 EXPECT_EQ(3600, exp); |
864 } | 864 } |
865 } | 865 } |
OLD | NEW |