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" |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 TEST_F(GaiaAuthFetcherTest, CaptchaParse) { | 406 TEST_F(GaiaAuthFetcherTest, CaptchaParse) { |
407 net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0); | 407 net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0); |
408 std::string data = "Url=http://www.google.com/login/captcha\n" | 408 std::string data = "Url=http://www.google.com/login/captcha\n" |
409 "Error=CaptchaRequired\n" | 409 "Error=CaptchaRequired\n" |
410 "CaptchaToken=CCTOKEN\n" | 410 "CaptchaToken=CCTOKEN\n" |
411 "CaptchaUrl=Captcha?ctoken=CCTOKEN\n"; | 411 "CaptchaUrl=Captcha?ctoken=CCTOKEN\n"; |
412 GoogleServiceAuthError error = | 412 GoogleServiceAuthError error = |
413 GaiaAuthFetcher::GenerateAuthError(data, status); | 413 GaiaAuthFetcher::GenerateAuthError(data, status); |
414 | 414 |
415 std::string token = "CCTOKEN"; | 415 std::string token = "CCTOKEN"; |
416 GURL image_url("http://www.google.com/accounts/Captcha?ctoken=CCTOKEN"); | 416 GURL image_url("http://accounts.google.com/Captcha?ctoken=CCTOKEN"); |
417 GURL unlock_url("http://www.google.com/login/captcha"); | 417 GURL unlock_url("http://www.google.com/login/captcha"); |
418 | 418 |
419 EXPECT_EQ(error.state(), GoogleServiceAuthError::CAPTCHA_REQUIRED); | 419 EXPECT_EQ(error.state(), GoogleServiceAuthError::CAPTCHA_REQUIRED); |
420 EXPECT_EQ(error.captcha().token, token); | 420 EXPECT_EQ(error.captcha().token, token); |
421 EXPECT_EQ(error.captcha().image_url, image_url); | 421 EXPECT_EQ(error.captcha().image_url, image_url); |
422 EXPECT_EQ(error.captcha().unlock_url, unlock_url); | 422 EXPECT_EQ(error.captcha().unlock_url, unlock_url); |
423 } | 423 } |
424 | 424 |
425 TEST_F(GaiaAuthFetcherTest, AccountDeletedError) { | 425 TEST_F(GaiaAuthFetcherTest, AccountDeletedError) { |
426 net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0); | 426 net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0); |
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1025 .Times(1); | 1025 .Times(1); |
1026 | 1026 |
1027 GaiaAuthFetcher auth(&consumer, std::string(), | 1027 GaiaAuthFetcher auth(&consumer, std::string(), |
1028 profile_.GetRequestContext()); | 1028 profile_.GetRequestContext()); |
1029 net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0); | 1029 net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0); |
1030 MockFetcher mock_fetcher( | 1030 MockFetcher mock_fetcher( |
1031 oauth_login_gurl_, status, net::HTTP_OK, cookies_, data, | 1031 oauth_login_gurl_, status, net::HTTP_OK, cookies_, data, |
1032 content::URLFetcher::GET, &auth); | 1032 content::URLFetcher::GET, &auth); |
1033 auth.OnURLFetchComplete(&mock_fetcher); | 1033 auth.OnURLFetchComplete(&mock_fetcher); |
1034 } | 1034 } |
OLD | NEW |