diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-10 22:47:26 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-10 22:47:26 +0000 |
commit | 1d8fe71d8b35b23eba23b3b7dd53bf04ac521428 (patch) | |
tree | 7528d4f3797ba0937df79a46b6c7d2963a1fd621 /chrome/common | |
parent | 99a6e3cb88a8966b04d272f2194f06f32112cf64 (diff) | |
download | chromium_src-1d8fe71d8b35b23eba23b3b7dd53bf04ac521428.zip chromium_src-1d8fe71d8b35b23eba23b3b7dd53bf04ac521428.tar.gz chromium_src-1d8fe71d8b35b23eba23b3b7dd53bf04ac521428.tar.bz2 |
Rename GaiaAuthenticator2 to GaiaAuthFetcher.
(Note: This was a TODO for chron).
BUG=None
TEST=trybots
Review URL: http://codereview.chromium.org/4155010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65719 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rw-r--r-- | chrome/common/net/gaia/gaia_auth_consumer.h | 2 | ||||
-rw-r--r-- | chrome/common/net/gaia/gaia_auth_fetcher.cc (renamed from chrome/common/net/gaia/gaia_authenticator2.cc) | 110 | ||||
-rw-r--r-- | chrome/common/net/gaia/gaia_auth_fetcher.h (renamed from chrome/common/net/gaia/gaia_authenticator2.h) | 41 | ||||
-rw-r--r-- | chrome/common/net/gaia/gaia_auth_fetcher_unittest.cc (renamed from chrome/common/net/gaia/gaia_authenticator2_unittest.cc) | 102 | ||||
-rw-r--r-- | chrome/common/net/gaia/gaia_auth_fetcher_unittest.h (renamed from chrome/common/net/gaia/gaia_authenticator2_unittest.h) | 10 |
5 files changed, 132 insertions, 133 deletions
diff --git a/chrome/common/net/gaia/gaia_auth_consumer.h b/chrome/common/net/gaia/gaia_auth_consumer.h index 429ab7f..706d19e 100644 --- a/chrome/common/net/gaia/gaia_auth_consumer.h +++ b/chrome/common/net/gaia/gaia_auth_consumer.h @@ -11,7 +11,7 @@ class GoogleServiceAuthError; // An interface that defines the callbacks for objects that -// GaiaAuthenticator2 can return data to. +// GaiaAuthFetcher can return data to. class GaiaAuthConsumer { public: struct ClientLoginResult { diff --git a/chrome/common/net/gaia/gaia_authenticator2.cc b/chrome/common/net/gaia/gaia_auth_fetcher.cc index 21b8190..ec6e808 100644 --- a/chrome/common/net/gaia/gaia_authenticator2.cc +++ b/chrome/common/net/gaia/gaia_auth_fetcher.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/common/net/gaia/gaia_authenticator2.h" +#include "chrome/common/net/gaia/gaia_auth_fetcher.h" #include <string> #include <utility> @@ -21,7 +21,7 @@ // TODO(chron): Add sourceless version of this formatter. // static -const char GaiaAuthenticator2::kClientLoginFormat[] = +const char GaiaAuthFetcher::kClientLoginFormat[] = "Email=%s&" "Passwd=%s&" "PersistentCookie=%s&" @@ -29,7 +29,7 @@ const char GaiaAuthenticator2::kClientLoginFormat[] = "source=%s&" "service=%s"; // static -const char GaiaAuthenticator2::kClientLoginCaptchaFormat[] = +const char GaiaAuthFetcher::kClientLoginCaptchaFormat[] = "Email=%s&" "Passwd=%s&" "PersistentCookie=%s&" @@ -39,59 +39,59 @@ const char GaiaAuthenticator2::kClientLoginCaptchaFormat[] = "logintoken=%s&" "logincaptcha=%s"; // static -const char GaiaAuthenticator2::kIssueAuthTokenFormat[] = +const char GaiaAuthFetcher::kIssueAuthTokenFormat[] = "SID=%s&" "LSID=%s&" "service=%s&" "Session=%s"; // static -const char GaiaAuthenticator2::kGetUserInfoFormat[] = +const char GaiaAuthFetcher::kGetUserInfoFormat[] = "LSID=%s"; // static -const char GaiaAuthenticator2::kAccountDeletedError[] = "AccountDeleted"; +const char GaiaAuthFetcher::kAccountDeletedError[] = "AccountDeleted"; // static -const char GaiaAuthenticator2::kAccountDisabledError[] = "AccountDisabled"; +const char GaiaAuthFetcher::kAccountDisabledError[] = "AccountDisabled"; // static -const char GaiaAuthenticator2::kCaptchaError[] = "CaptchaRequired"; +const char GaiaAuthFetcher::kCaptchaError[] = "CaptchaRequired"; // static -const char GaiaAuthenticator2::kServiceUnavailableError[] = +const char GaiaAuthFetcher::kServiceUnavailableError[] = "ServiceUnavailable"; // static -const char GaiaAuthenticator2::kErrorParam[] = "Error"; +const char GaiaAuthFetcher::kErrorParam[] = "Error"; // static -const char GaiaAuthenticator2::kErrorUrlParam[] = "Url"; +const char GaiaAuthFetcher::kErrorUrlParam[] = "Url"; // static -const char GaiaAuthenticator2::kCaptchaUrlParam[] = "CaptchaUrl"; +const char GaiaAuthFetcher::kCaptchaUrlParam[] = "CaptchaUrl"; // static -const char GaiaAuthenticator2::kCaptchaTokenParam[] = "CaptchaToken"; +const char GaiaAuthFetcher::kCaptchaTokenParam[] = "CaptchaToken"; // static -const char GaiaAuthenticator2::kCaptchaUrlPrefix[] = +const char GaiaAuthFetcher::kCaptchaUrlPrefix[] = "http://www.google.com/accounts/"; // static -const char GaiaAuthenticator2::kCookiePersistence[] = "true"; +const char GaiaAuthFetcher::kCookiePersistence[] = "true"; // static // TODO(johnnyg): When hosted accounts are supported by sync, // we can always use "HOSTED_OR_GOOGLE" -const char GaiaAuthenticator2::kAccountTypeHostedOrGoogle[] = +const char GaiaAuthFetcher::kAccountTypeHostedOrGoogle[] = "HOSTED_OR_GOOGLE"; -const char GaiaAuthenticator2::kAccountTypeGoogle[] = +const char GaiaAuthFetcher::kAccountTypeGoogle[] = "GOOGLE"; // static -const char GaiaAuthenticator2::kSecondFactor[] = "Info=InvalidSecondFactor"; +const char GaiaAuthFetcher::kSecondFactor[] = "Info=InvalidSecondFactor"; // TODO(chron): These urls are also in auth_response_handler.h. // The URLs for different calls in the Google Accounts programmatic login API. -const char GaiaAuthenticator2::kClientLoginUrl[] = +const char GaiaAuthFetcher::kClientLoginUrl[] = "https://www.google.com/accounts/ClientLogin"; -const char GaiaAuthenticator2::kIssueAuthTokenUrl[] = +const char GaiaAuthFetcher::kIssueAuthTokenUrl[] = "https://www.google.com/accounts/IssueAuthToken"; -const char GaiaAuthenticator2::kGetUserInfoUrl[] = +const char GaiaAuthFetcher::kGetUserInfoUrl[] = "https://www.google.com/accounts/GetUserInfo"; -GaiaAuthenticator2::GaiaAuthenticator2(GaiaAuthConsumer* consumer, +GaiaAuthFetcher::GaiaAuthFetcher(GaiaAuthConsumer* consumer, const std::string& source, URLRequestContextGetter* getter) : consumer_(consumer), @@ -102,19 +102,19 @@ GaiaAuthenticator2::GaiaAuthenticator2(GaiaAuthConsumer* consumer, get_user_info_gurl_(kGetUserInfoUrl), fetch_pending_(false) {} -GaiaAuthenticator2::~GaiaAuthenticator2() {} +GaiaAuthFetcher::~GaiaAuthFetcher() {} -bool GaiaAuthenticator2::HasPendingFetch() { +bool GaiaAuthFetcher::HasPendingFetch() { return fetch_pending_; } -void GaiaAuthenticator2::CancelRequest() { +void GaiaAuthFetcher::CancelRequest() { fetcher_.reset(); fetch_pending_ = false; } // static -URLFetcher* GaiaAuthenticator2::CreateGaiaFetcher( +URLFetcher* GaiaAuthFetcher::CreateGaiaFetcher( URLRequestContextGetter* getter, const std::string& body, const GURL& gaia_gurl, @@ -132,7 +132,7 @@ URLFetcher* GaiaAuthenticator2::CreateGaiaFetcher( } // static -std::string GaiaAuthenticator2::MakeClientLoginBody( +std::string GaiaAuthFetcher::MakeClientLoginBody( const std::string& username, const std::string& password, const std::string& source, @@ -172,7 +172,7 @@ std::string GaiaAuthenticator2::MakeClientLoginBody( } // static -std::string GaiaAuthenticator2::MakeIssueAuthTokenBody( +std::string GaiaAuthFetcher::MakeIssueAuthTokenBody( const std::string& sid, const std::string& lsid, const char* const service) { @@ -192,14 +192,14 @@ std::string GaiaAuthenticator2::MakeIssueAuthTokenBody( } // static -std::string GaiaAuthenticator2::MakeGetUserInfoBody(const std::string& lsid) { +std::string GaiaAuthFetcher::MakeGetUserInfoBody(const std::string& lsid) { std::string encoded_lsid = UrlEncodeString(lsid); return base::StringPrintf(kGetUserInfoFormat, encoded_lsid.c_str()); } // Helper method that extracts tokens from a successful reply. // static -void GaiaAuthenticator2::ParseClientLoginResponse(const std::string& data, +void GaiaAuthFetcher::ParseClientLoginResponse(const std::string& data, std::string* sid, std::string* lsid, std::string* token) { @@ -222,11 +222,11 @@ void GaiaAuthenticator2::ParseClientLoginResponse(const std::string& data, } // static -void GaiaAuthenticator2::ParseClientLoginFailure(const std::string& data, - std::string* error, - std::string* error_url, - std::string* captcha_url, - std::string* captcha_token) { +void GaiaAuthFetcher::ParseClientLoginFailure(const std::string& data, + std::string* error, + std::string* error_url, + std::string* captcha_url, + std::string* captcha_token) { using std::vector; using std::pair; using std::string; @@ -234,7 +234,7 @@ void GaiaAuthenticator2::ParseClientLoginFailure(const std::string& data, vector<pair<string, string> > tokens; base::SplitStringIntoKeyValuePairs(data, '=', '\n', &tokens); for (vector<pair<string, string> >::iterator i = tokens.begin(); - i != tokens.end(); ++i) { + i != tokens.end(); ++i) { if (i->first == kErrorParam) { error->assign(i->second); } else if (i->first == kErrorUrlParam) { @@ -247,7 +247,7 @@ void GaiaAuthenticator2::ParseClientLoginFailure(const std::string& data, } } -void GaiaAuthenticator2::StartClientLogin( +void GaiaAuthFetcher::StartClientLogin( const std::string& username, const std::string& password, const char* const service, @@ -277,9 +277,9 @@ void GaiaAuthenticator2::StartClientLogin( fetcher_->Start(); } -void GaiaAuthenticator2::StartIssueAuthToken(const std::string& sid, - const std::string& lsid, - const char* const service) { +void GaiaAuthFetcher::StartIssueAuthToken(const std::string& sid, + const std::string& lsid, + const char* const service) { DCHECK(!fetch_pending_) << "Tried to fetch two things at once!"; @@ -294,8 +294,8 @@ void GaiaAuthenticator2::StartIssueAuthToken(const std::string& sid, fetcher_->Start(); } -void GaiaAuthenticator2::StartGetUserInfo(const std::string& lsid, - const std::string& info_key) { +void GaiaAuthFetcher::StartGetUserInfo(const std::string& lsid, + const std::string& info_key) { DCHECK(!fetch_pending_) << "Tried to fetch two things at once!"; VLOG(1) << "Starting GetUserInfo for lsid=" << lsid; @@ -310,7 +310,7 @@ void GaiaAuthenticator2::StartGetUserInfo(const std::string& lsid, } // static -GoogleServiceAuthError GaiaAuthenticator2::GenerateAuthError( +GoogleServiceAuthError GaiaAuthFetcher::GenerateAuthError( const std::string& data, const URLRequestStatus& status) { @@ -356,9 +356,9 @@ GoogleServiceAuthError GaiaAuthenticator2::GenerateAuthError( NOTREACHED(); } -void GaiaAuthenticator2::OnClientLoginFetched(const std::string& data, - const URLRequestStatus& status, - int response_code) { +void GaiaAuthFetcher::OnClientLoginFetched(const std::string& data, + const URLRequestStatus& status, + int response_code) { if (status.is_success() && response_code == RC_REQUEST_OK) { VLOG(1) << "ClientLogin successful!"; @@ -373,7 +373,7 @@ void GaiaAuthenticator2::OnClientLoginFetched(const std::string& data, } } -void GaiaAuthenticator2::OnIssueAuthTokenFetched( +void GaiaAuthFetcher::OnIssueAuthTokenFetched( const std::string& data, const URLRequestStatus& status, int response_code) { @@ -387,7 +387,7 @@ void GaiaAuthenticator2::OnIssueAuthTokenFetched( } } -void GaiaAuthenticator2::OnGetUserInfoFetched( +void GaiaAuthFetcher::OnGetUserInfoFetched( const std::string& data, const URLRequestStatus& status, int response_code) { @@ -411,12 +411,12 @@ void GaiaAuthenticator2::OnGetUserInfoFetched( } } -void GaiaAuthenticator2::OnURLFetchComplete(const URLFetcher* source, - const GURL& url, - const URLRequestStatus& status, - int response_code, - const ResponseCookies& cookies, - const std::string& data) { +void GaiaAuthFetcher::OnURLFetchComplete(const URLFetcher* source, + const GURL& url, + const URLRequestStatus& status, + int response_code, + const ResponseCookies& cookies, + const std::string& data) { fetch_pending_ = false; if (url == client_login_gurl_) { OnClientLoginFetched(data, status, response_code); @@ -430,7 +430,7 @@ void GaiaAuthenticator2::OnURLFetchComplete(const URLFetcher* source, } // static -bool GaiaAuthenticator2::IsSecondFactorSuccess( +bool GaiaAuthFetcher::IsSecondFactorSuccess( const std::string& alleged_error) { return alleged_error.find(kSecondFactor) != std::string::npos; diff --git a/chrome/common/net/gaia/gaia_authenticator2.h b/chrome/common/net/gaia/gaia_auth_fetcher.h index fece7db..fd644a3 100644 --- a/chrome/common/net/gaia/gaia_authenticator2.h +++ b/chrome/common/net/gaia/gaia_auth_fetcher.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_COMMON_NET_GAIA_GAIA_AUTHENTICATOR2_H_ -#define CHROME_COMMON_NET_GAIA_GAIA_AUTHENTICATOR2_H_ +#ifndef CHROME_COMMON_NET_GAIA_GAIA_AUTH_FETCHER_H_ +#define CHROME_COMMON_NET_GAIA_GAIA_AUTH_FETCHER_H_ #pragma once #include <string> @@ -22,12 +22,11 @@ // that you like. // // This class can handle one request at a time. To parallelize requests, -// create multiple GaiaAuthenticator2's. +// create multiple GaiaAuthFetcher's. -class GaiaAuthenticator2Test; +class GaiaAuthFetcherTest; -// TODO(chron): Rename this to GaiaAuthFetcher or something. -class GaiaAuthenticator2 : public URLFetcher::Delegate { +class GaiaAuthFetcher : public URLFetcher::Delegate { public: enum HostedAccountsSetting { HostedAccountsAllowed, @@ -45,10 +44,10 @@ class GaiaAuthenticator2 : public URLFetcher::Delegate { // This will later be hidden behind an auth service which caches // tokens. - GaiaAuthenticator2(GaiaAuthConsumer* consumer, - const std::string& source, - URLRequestContextGetter* getter); - virtual ~GaiaAuthenticator2(); + GaiaAuthFetcher(GaiaAuthConsumer* consumer, + const std::string& source, + URLRequestContextGetter* getter); + virtual ~GaiaAuthFetcher(); // GaiaAuthConsumer will be called on the original thread // after results come back. This class is thread agnostic. @@ -174,7 +173,7 @@ class GaiaAuthenticator2 : public URLFetcher::Delegate { URLFetcher::Delegate* delegate); - // These fields are common to GaiaAuthenticator2, same every request + // These fields are common to GaiaAuthFetcher, same every request GaiaAuthConsumer* const consumer_; URLRequestContextGetter* const getter_; std::string source_; @@ -189,16 +188,16 @@ class GaiaAuthenticator2 : public URLFetcher::Delegate { std::string requested_info_key_; // Currently tracked for GetUserInfo only bool fetch_pending_; - friend class GaiaAuthenticator2Test; - FRIEND_TEST_ALL_PREFIXES(GaiaAuthenticator2Test, CaptchaParse); - FRIEND_TEST_ALL_PREFIXES(GaiaAuthenticator2Test, AccountDeletedError); - FRIEND_TEST_ALL_PREFIXES(GaiaAuthenticator2Test, AccountDisabledError); - FRIEND_TEST_ALL_PREFIXES(GaiaAuthenticator2Test, ServiceUnavailableError); - FRIEND_TEST_ALL_PREFIXES(GaiaAuthenticator2Test, CheckNormalErrorCode); - FRIEND_TEST_ALL_PREFIXES(GaiaAuthenticator2Test, CheckTwoFactorResponse); - FRIEND_TEST_ALL_PREFIXES(GaiaAuthenticator2Test, LoginNetFailure); + friend class GaiaAuthFetcherTest; + FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, CaptchaParse); + FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, AccountDeletedError); + FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, AccountDisabledError); + FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, ServiceUnavailableError); + FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, CheckNormalErrorCode); + FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, CheckTwoFactorResponse); + FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, LoginNetFailure); - DISALLOW_COPY_AND_ASSIGN(GaiaAuthenticator2); + DISALLOW_COPY_AND_ASSIGN(GaiaAuthFetcher); }; -#endif // CHROME_COMMON_NET_GAIA_GAIA_AUTHENTICATOR2_H_ +#endif // CHROME_COMMON_NET_GAIA_GAIA_AUTH_FETCHER_H_ diff --git a/chrome/common/net/gaia/gaia_authenticator2_unittest.cc b/chrome/common/net/gaia/gaia_auth_fetcher_unittest.cc index 6ef0a51..47df6b7 100644 --- a/chrome/common/net/gaia/gaia_authenticator2_unittest.cc +++ b/chrome/common/net/gaia/gaia_auth_fetcher_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -// A complete set of unit tests for GaiaAuthenticator2. +// A complete set of unit tests for GaiaAuthFetcher. // Originally ported from GoogleAuthenticator tests. #include <string> @@ -10,8 +10,8 @@ #include "base/message_loop.h" #include "base/string_util.h" #include "chrome/common/net/gaia/gaia_auth_consumer.h" -#include "chrome/common/net/gaia/gaia_authenticator2.h" -#include "chrome/common/net/gaia/gaia_authenticator2_unittest.h" +#include "chrome/common/net/gaia/gaia_auth_fetcher.h" +#include "chrome/common/net/gaia/gaia_auth_fetcher_unittest.h" #include "chrome/common/net/gaia/google_service_auth_error.h" #include "chrome/common/net/http_return.h" #include "chrome/common/net/test_url_fetcher_factory.h" @@ -25,11 +25,11 @@ using ::testing::_; -class GaiaAuthenticator2Test : public testing::Test { +class GaiaAuthFetcherTest : public testing::Test { public: - GaiaAuthenticator2Test() - : client_login_source_(GaiaAuthenticator2::kClientLoginUrl), - issue_auth_token_source_(GaiaAuthenticator2::kIssueAuthTokenUrl) {} + GaiaAuthFetcherTest() + : client_login_source_(GaiaAuthFetcher::kClientLoginUrl), + issue_auth_token_source_(GaiaAuthFetcher::kIssueAuthTokenUrl) {} void RunParsingTest(const std::string& data, const std::string& sid, @@ -39,7 +39,7 @@ class GaiaAuthenticator2Test : public testing::Test { std::string out_lsid; std::string out_token; - GaiaAuthenticator2::ParseClientLoginResponse(data, + GaiaAuthFetcher::ParseClientLoginResponse(data, &out_sid, &out_lsid, &out_token); @@ -58,7 +58,7 @@ class GaiaAuthenticator2Test : public testing::Test { std::string out_captcha_url; std::string out_captcha_token; - GaiaAuthenticator2::ParseClientLoginFailure(data, + GaiaAuthFetcher::ParseClientLoginFailure(data, &out_error, &out_error_url, &out_captcha_url, @@ -89,7 +89,7 @@ class MockGaiaConsumer : public GaiaAuthConsumer { const GoogleServiceAuthError& error)); }; -TEST_F(GaiaAuthenticator2Test, ErrorComparator) { +TEST_F(GaiaAuthFetcherTest, ErrorComparator) { GoogleServiceAuthError expected_error = GoogleServiceAuthError::FromConnectionError(-101); @@ -111,7 +111,7 @@ TEST_F(GaiaAuthenticator2Test, ErrorComparator) { EXPECT_TRUE(expected_error == matching_error); } -TEST_F(GaiaAuthenticator2Test, LoginNetFailure) { +TEST_F(GaiaAuthFetcherTest, LoginNetFailure) { int error_no = net::ERR_CONNECTION_RESET; URLRequestStatus status(URLRequestStatus::FAILED, error_no); @@ -122,7 +122,7 @@ TEST_F(GaiaAuthenticator2Test, LoginNetFailure) { EXPECT_CALL(consumer, OnClientLoginFailure(expected_error)) .Times(1); - GaiaAuthenticator2 auth(&consumer, std::string(), + GaiaAuthFetcher auth(&consumer, std::string(), profile_.GetRequestContext()); auth.OnURLFetchComplete(NULL, @@ -133,7 +133,7 @@ TEST_F(GaiaAuthenticator2Test, LoginNetFailure) { std::string()); } -TEST_F(GaiaAuthenticator2Test, TokenNetFailure) { +TEST_F(GaiaAuthFetcherTest, TokenNetFailure) { int error_no = net::ERR_CONNECTION_RESET; URLRequestStatus status(URLRequestStatus::FAILED, error_no); @@ -144,7 +144,7 @@ TEST_F(GaiaAuthenticator2Test, TokenNetFailure) { EXPECT_CALL(consumer, OnIssueAuthTokenFailure(_, expected_error)) .Times(1); - GaiaAuthenticator2 auth(&consumer, std::string(), + GaiaAuthFetcher auth(&consumer, std::string(), profile_.GetRequestContext()); auth.OnURLFetchComplete(NULL, @@ -156,7 +156,7 @@ TEST_F(GaiaAuthenticator2Test, TokenNetFailure) { } -TEST_F(GaiaAuthenticator2Test, LoginDenied) { +TEST_F(GaiaAuthFetcherTest, LoginDenied) { std::string data("Error: NO!"); URLRequestStatus status(URLRequestStatus::SUCCESS, 0); @@ -167,7 +167,7 @@ TEST_F(GaiaAuthenticator2Test, LoginDenied) { EXPECT_CALL(consumer, OnClientLoginFailure(expected_error)) .Times(1); - GaiaAuthenticator2 auth(&consumer, std::string(), + GaiaAuthFetcher auth(&consumer, std::string(), profile_.GetRequestContext()); auth.OnURLFetchComplete(NULL, client_login_source_, @@ -177,7 +177,7 @@ TEST_F(GaiaAuthenticator2Test, LoginDenied) { data); } -TEST_F(GaiaAuthenticator2Test, ParseRequest) { +TEST_F(GaiaAuthFetcherTest, ParseRequest) { RunParsingTest("SID=sid\nLSID=lsid\nAuth=auth\n", "sid", "lsid", "auth"); RunParsingTest("LSID=lsid\nSID=sid\nAuth=auth\n", "sid", "lsid", "auth"); RunParsingTest("SID=sid\nLSID=lsid\nAuth=auth", "sid", "lsid", "auth"); @@ -187,7 +187,7 @@ TEST_F(GaiaAuthenticator2Test, ParseRequest) { RunParsingTest("SID=sid", "sid", "", ""); } -TEST_F(GaiaAuthenticator2Test, ParseErrorRequest) { +TEST_F(GaiaAuthFetcherTest, ParseErrorRequest) { RunErrorParsingTest("Url=U\n" "Error=E\n" "CaptchaToken=T\n" @@ -203,7 +203,7 @@ TEST_F(GaiaAuthenticator2Test, ParseErrorRequest) { } -TEST_F(GaiaAuthenticator2Test, OnlineLogin) { +TEST_F(GaiaAuthFetcherTest, OnlineLogin) { std::string data("SID=sid\nLSID=lsid\nAuth=auth\n"); GaiaAuthConsumer::ClientLoginResult result; @@ -216,7 +216,7 @@ TEST_F(GaiaAuthenticator2Test, OnlineLogin) { EXPECT_CALL(consumer, OnClientLoginSuccess(result)) .Times(1); - GaiaAuthenticator2 auth(&consumer, std::string(), + GaiaAuthFetcher auth(&consumer, std::string(), profile_.GetRequestContext()); URLRequestStatus status(URLRequestStatus::SUCCESS, 0); auth.OnURLFetchComplete(NULL, @@ -227,12 +227,12 @@ TEST_F(GaiaAuthenticator2Test, OnlineLogin) { data); } -TEST_F(GaiaAuthenticator2Test, WorkingIssueAuthToken) { +TEST_F(GaiaAuthFetcherTest, WorkingIssueAuthToken) { MockGaiaConsumer consumer; EXPECT_CALL(consumer, OnIssueAuthTokenSuccess(_, "token")) .Times(1); - GaiaAuthenticator2 auth(&consumer, std::string(), + GaiaAuthFetcher auth(&consumer, std::string(), profile_.GetRequestContext()); URLRequestStatus status(URLRequestStatus::SUCCESS, 0); auth.OnURLFetchComplete(NULL, @@ -243,21 +243,21 @@ TEST_F(GaiaAuthenticator2Test, WorkingIssueAuthToken) { "token"); } -TEST_F(GaiaAuthenticator2Test, CheckTwoFactorResponse) { +TEST_F(GaiaAuthFetcherTest, CheckTwoFactorResponse) { std::string response = base::StringPrintf("Error=BadAuthentication\n%s\n", - GaiaAuthenticator2::kSecondFactor); - EXPECT_TRUE(GaiaAuthenticator2::IsSecondFactorSuccess(response)); + GaiaAuthFetcher::kSecondFactor); + EXPECT_TRUE(GaiaAuthFetcher::IsSecondFactorSuccess(response)); } -TEST_F(GaiaAuthenticator2Test, CheckNormalErrorCode) { +TEST_F(GaiaAuthFetcherTest, CheckNormalErrorCode) { std::string response = "Error=BadAuthentication\n"; - EXPECT_FALSE(GaiaAuthenticator2::IsSecondFactorSuccess(response)); + EXPECT_FALSE(GaiaAuthFetcher::IsSecondFactorSuccess(response)); } -TEST_F(GaiaAuthenticator2Test, TwoFactorLogin) { +TEST_F(GaiaAuthFetcherTest, TwoFactorLogin) { std::string response = base::StringPrintf("Error=BadAuthentication\n%s\n", - GaiaAuthenticator2::kSecondFactor); + GaiaAuthFetcher::kSecondFactor); GoogleServiceAuthError error = GoogleServiceAuthError(GoogleServiceAuthError::TWO_FACTOR); @@ -266,7 +266,7 @@ TEST_F(GaiaAuthenticator2Test, TwoFactorLogin) { EXPECT_CALL(consumer, OnClientLoginFailure(error)) .Times(1); - GaiaAuthenticator2 auth(&consumer, std::string(), + GaiaAuthFetcher auth(&consumer, std::string(), profile_.GetRequestContext()); URLRequestStatus status(URLRequestStatus::SUCCESS, 0); auth.OnURLFetchComplete(NULL, @@ -277,14 +277,14 @@ TEST_F(GaiaAuthenticator2Test, TwoFactorLogin) { response); } -TEST_F(GaiaAuthenticator2Test, CaptchaParse) { +TEST_F(GaiaAuthFetcherTest, CaptchaParse) { URLRequestStatus status(URLRequestStatus::SUCCESS, 0); std::string data = "Url=http://www.google.com/login/captcha\n" "Error=CaptchaRequired\n" "CaptchaToken=CCTOKEN\n" "CaptchaUrl=Captcha?ctoken=CCTOKEN\n"; GoogleServiceAuthError error = - GaiaAuthenticator2::GenerateAuthError(data, status); + GaiaAuthFetcher::GenerateAuthError(data, status); std::string token = "CCTOKEN"; GURL image_url("http://www.google.com/accounts/Captcha?ctoken=CCTOKEN"); @@ -296,31 +296,31 @@ TEST_F(GaiaAuthenticator2Test, CaptchaParse) { EXPECT_EQ(error.captcha().unlock_url, unlock_url); } -TEST_F(GaiaAuthenticator2Test, AccountDeletedError) { +TEST_F(GaiaAuthFetcherTest, AccountDeletedError) { URLRequestStatus status(URLRequestStatus::SUCCESS, 0); std::string data = "Error=AccountDeleted\n"; GoogleServiceAuthError error = - GaiaAuthenticator2::GenerateAuthError(data, status); + GaiaAuthFetcher::GenerateAuthError(data, status); EXPECT_EQ(error.state(), GoogleServiceAuthError::ACCOUNT_DELETED); } -TEST_F(GaiaAuthenticator2Test, AccountDisabledError) { +TEST_F(GaiaAuthFetcherTest, AccountDisabledError) { URLRequestStatus status(URLRequestStatus::SUCCESS, 0); std::string data = "Error=AccountDisabled\n"; GoogleServiceAuthError error = - GaiaAuthenticator2::GenerateAuthError(data, status); + GaiaAuthFetcher::GenerateAuthError(data, status); EXPECT_EQ(error.state(), GoogleServiceAuthError::ACCOUNT_DISABLED); } -TEST_F(GaiaAuthenticator2Test,ServiceUnavailableError) { +TEST_F(GaiaAuthFetcherTest,ServiceUnavailableError) { URLRequestStatus status(URLRequestStatus::SUCCESS, 0); std::string data = "Error=ServiceUnavailable\n"; GoogleServiceAuthError error = - GaiaAuthenticator2::GenerateAuthError(data, status); + GaiaAuthFetcher::GenerateAuthError(data, status); EXPECT_EQ(error.state(), GoogleServiceAuthError::SERVICE_UNAVAILABLE); } -TEST_F(GaiaAuthenticator2Test, FullLogin) { +TEST_F(GaiaAuthFetcherTest, FullLogin) { MockGaiaConsumer consumer; EXPECT_CALL(consumer, OnClientLoginSuccess(_)) .Times(1); @@ -330,19 +330,19 @@ TEST_F(GaiaAuthenticator2Test, FullLogin) { MockFactory<MockFetcher> factory; URLFetcher::set_factory(&factory); - GaiaAuthenticator2 auth(&consumer, std::string(), + GaiaAuthFetcher auth(&consumer, std::string(), profile_.GetRequestContext()); auth.StartClientLogin("username", "password", "service", std::string(), std::string(), - GaiaAuthenticator2::HostedAccountsAllowed); + GaiaAuthFetcher::HostedAccountsAllowed); URLFetcher::set_factory(NULL); } -TEST_F(GaiaAuthenticator2Test, FullLoginFailure) { +TEST_F(GaiaAuthFetcherTest, FullLoginFailure) { MockGaiaConsumer consumer; EXPECT_CALL(consumer, OnClientLoginFailure(_)) .Times(1); @@ -353,19 +353,19 @@ TEST_F(GaiaAuthenticator2Test, FullLoginFailure) { URLFetcher::set_factory(&factory); factory.set_success(false); - GaiaAuthenticator2 auth(&consumer, std::string(), + GaiaAuthFetcher auth(&consumer, std::string(), profile_.GetRequestContext()); auth.StartClientLogin("username", "password", "service", std::string(), std::string(), - GaiaAuthenticator2::HostedAccountsAllowed); + GaiaAuthFetcher::HostedAccountsAllowed); URLFetcher::set_factory(NULL); } -TEST_F(GaiaAuthenticator2Test, ClientFetchPending) { +TEST_F(GaiaAuthFetcherTest, ClientFetchPending) { MockGaiaConsumer consumer; EXPECT_CALL(consumer, OnClientLoginSuccess(_)) .Times(1); @@ -374,14 +374,14 @@ TEST_F(GaiaAuthenticator2Test, ClientFetchPending) { TestURLFetcherFactory factory; URLFetcher::set_factory(&factory); - GaiaAuthenticator2 auth(&consumer, std::string(), + GaiaAuthFetcher auth(&consumer, std::string(), profile_.GetRequestContext()); auth.StartClientLogin("username", "password", "service", std::string(), std::string(), - GaiaAuthenticator2::HostedAccountsAllowed); + GaiaAuthFetcher::HostedAccountsAllowed); URLFetcher::set_factory(NULL); EXPECT_TRUE(auth.HasPendingFetch()); @@ -394,7 +394,7 @@ TEST_F(GaiaAuthenticator2Test, ClientFetchPending) { EXPECT_FALSE(auth.HasPendingFetch()); } -TEST_F(GaiaAuthenticator2Test, FullTokenSuccess) { +TEST_F(GaiaAuthFetcherTest, FullTokenSuccess) { MockGaiaConsumer consumer; EXPECT_CALL(consumer, OnIssueAuthTokenSuccess("service", "token")) .Times(1); @@ -403,7 +403,7 @@ TEST_F(GaiaAuthenticator2Test, FullTokenSuccess) { TestURLFetcherFactory factory; URLFetcher::set_factory(&factory); - GaiaAuthenticator2 auth(&consumer, std::string(), + GaiaAuthFetcher auth(&consumer, std::string(), profile_.GetRequestContext()); auth.StartIssueAuthToken("sid", "lsid", "service"); @@ -418,7 +418,7 @@ TEST_F(GaiaAuthenticator2Test, FullTokenSuccess) { EXPECT_FALSE(auth.HasPendingFetch()); } -TEST_F(GaiaAuthenticator2Test, FullTokenFailure) { +TEST_F(GaiaAuthFetcherTest, FullTokenFailure) { MockGaiaConsumer consumer; EXPECT_CALL(consumer, OnIssueAuthTokenFailure("service", _)) .Times(1); @@ -427,7 +427,7 @@ TEST_F(GaiaAuthenticator2Test, FullTokenFailure) { TestURLFetcherFactory factory; URLFetcher::set_factory(&factory); - GaiaAuthenticator2 auth(&consumer, std::string(), + GaiaAuthFetcher auth(&consumer, std::string(), profile_.GetRequestContext()); auth.StartIssueAuthToken("sid", "lsid", "service"); diff --git a/chrome/common/net/gaia/gaia_authenticator2_unittest.h b/chrome/common/net/gaia/gaia_auth_fetcher_unittest.h index 3c6f22c..4676a26 100644 --- a/chrome/common/net/gaia/gaia_authenticator2_unittest.h +++ b/chrome/common/net/gaia/gaia_auth_fetcher_unittest.h @@ -3,15 +3,15 @@ // found in the LICENSE file. // // A collection of classes that are useful when testing things that use a -// GaiaAuthenticator2. +// GaiaAuthFetcher. -#ifndef CHROME_COMMON_NET_GAIA_GAIA_AUTHENTICATOR2_UNITTEST_H_ -#define CHROME_COMMON_NET_GAIA_GAIA_AUTHENTICATOR2_UNITTEST_H_ +#ifndef CHROME_COMMON_NET_GAIA_GAIA_AUTH_FETCHER_UNITTEST_H_ +#define CHROME_COMMON_NET_GAIA_GAIA_AUTH_FETCHER_UNITTEST_H_ #pragma once #include <string> -#include "chrome/common/net/gaia/gaia_authenticator2.h" +#include "chrome/common/net/gaia/gaia_auth_fetcher.h" #include "chrome/common/net/url_fetcher.h" #include "chrome/common/net/http_return.h" #include "net/url_request/url_request_status.h" @@ -81,4 +81,4 @@ class MockFactory : public URLFetcher::Factory { DISALLOW_COPY_AND_ASSIGN(MockFactory); }; -#endif // CHROME_COMMON_NET_GAIA_GAIA_AUTHENTICATOR2_UNITTEST_H_ +#endif // CHROME_COMMON_NET_GAIA_GAIA_AUTH_FETCHER_UNITTEST_H_ |