diff options
author | vitalybuka@chromium.org <vitalybuka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-19 13:20:23 +0000 |
---|---|---|
committer | vitalybuka@chromium.org <vitalybuka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-19 13:20:23 +0000 |
commit | 2ca6ed82cc4e9603c7238aa95feabaa5784e812a (patch) | |
tree | d3e9186356e1fe7ddfb7d1c357463b47c415ce0b /google_apis/gaia | |
parent | 7ba621715515cb75d8d6ff720da52cb76c12c105 (diff) | |
download | chromium_src-2ca6ed82cc4e9603c7238aa95feabaa5784e812a.zip chromium_src-2ca6ed82cc4e9603c7238aa95feabaa5784e812a.tar.gz chromium_src-2ca6ed82cc4e9603c7238aa95feabaa5784e812a.tar.bz2 |
Removed LCID authentication from cloud print and cloud print setup dialog.
BUG=247359
Review URL: https://chromiumcodereview.appspot.com/16866014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@207223 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'google_apis/gaia')
-rw-r--r-- | google_apis/gaia/gaia_authenticator.cc | 400 | ||||
-rw-r--r-- | google_apis/gaia/gaia_authenticator.h | 271 | ||||
-rw-r--r-- | google_apis/gaia/gaia_authenticator_unittest.cc | 52 | ||||
-rw-r--r-- | google_apis/gaia/gaia_constants.cc | 2 | ||||
-rw-r--r-- | google_apis/gaia/gaia_constants.h | 1 |
5 files changed, 0 insertions, 726 deletions
diff --git a/google_apis/gaia/gaia_authenticator.cc b/google_apis/gaia/gaia_authenticator.cc deleted file mode 100644 index e5a40a2..0000000 --- a/google_apis/gaia/gaia_authenticator.cc +++ /dev/null @@ -1,400 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "google_apis/gaia/gaia_authenticator.h" - -#include <string> -#include <utility> -#include <vector> - -#include "base/basictypes.h" -#include "base/port.h" -#include "base/strings/string_split.h" -#include "googleurl/src/gurl.h" -#include "net/base/escape.h" -#include "net/http/http_status_code.h" - -using std::pair; -using std::string; -using std::vector; - -namespace gaia { - -static const char kGaiaV1IssueAuthTokenPath[] = "/accounts/IssueAuthToken"; - -static const char kGetUserInfoPath[] = "/accounts/GetUserInfo"; - -GaiaAuthenticator::AuthResults::AuthResults() : auth_error(None) {} - -GaiaAuthenticator::AuthResults::AuthResults(const AuthResults& other) - : email(other.email), - password(other.password), - sid(other.sid), - lsid(other.lsid), - auth_token(other.auth_token), - primary_email(other.primary_email), - error_msg(other.error_msg), - auth_error(other.auth_error), - auth_error_url(other.auth_error_url), - captcha_token(other.captcha_token), - captcha_url(other.captcha_url) { -} - -GaiaAuthenticator::AuthResults::~AuthResults() {} - -GaiaAuthenticator::AuthParams::AuthParams() : authenticator(NULL), - request_id(0) {} - -GaiaAuthenticator::AuthParams::~AuthParams() {} - -// Sole constructor with initializers for all fields. -GaiaAuthenticator::GaiaAuthenticator(const string& user_agent, - const string& service_id, - const string& gaia_url) - : user_agent_(user_agent), - service_id_(service_id), - gaia_url_(gaia_url), - request_count_(0), - delay_(0), - next_allowed_auth_attempt_time_(0), - early_auth_attempt_count_(0), - message_loop_(NULL) { -} - -GaiaAuthenticator::~GaiaAuthenticator() { -} - -// mutex_ must be entered before calling this function. -GaiaAuthenticator::AuthParams GaiaAuthenticator::MakeParams( - const string& user_name, - const string& password, - const string& captcha_token, - const string& captcha_value) { - AuthParams params; - params.request_id = ++request_count_; - params.email = user_name; - params.password = password; - params.captcha_token = captcha_token; - params.captcha_value = captcha_value; - params.authenticator = this; - return params; -} - -bool GaiaAuthenticator::Authenticate(const string& user_name, - const string& password, - const string& captcha_token, - const string& captcha_value) { - DCHECK_EQ(base::MessageLoop::current(), message_loop_); - - AuthParams const params = - MakeParams(user_name, password, captcha_token, captcha_value); - return AuthenticateImpl(params); -} - -bool GaiaAuthenticator::AuthenticateWithLsid(const string& lsid) { - auth_results_.lsid = lsid; - // We need to lookup the email associated with this LSID cookie in order to - // update |auth_results_| with the correct values. - if (LookupEmail(&auth_results_)) { - auth_results_.email = auth_results_.primary_email; - return IssueAuthToken(&auth_results_, service_id_); - } - return false; -} - -bool GaiaAuthenticator::AuthenticateImpl(const AuthParams& params) { - DCHECK_EQ(base::MessageLoop::current(), message_loop_); - AuthResults results; - const bool succeeded = AuthenticateImpl(params, &results); - return succeeded; -} - -// This method makes an HTTP request to the Gaia server, and calls other -// methods to help parse the response. If authentication succeeded, then -// Gaia-issued cookies are available in the respective variables; if -// authentication failed, then the exact error is available as an enum. If the -// client wishes to save the credentials, the last parameter must be true. -// If a subsequent request is made with fresh credentials, the saved credentials -// are wiped out; any subsequent request to the zero-parameter overload of this -// method preserves the saved credentials. -bool GaiaAuthenticator::AuthenticateImpl(const AuthParams& params, - AuthResults* results) { - DCHECK_EQ(base::MessageLoop::current(), message_loop_); - results->auth_error = ConnectionUnavailable; - results->email = params.email.data(); - results->password = params.password; - - // The aim of this code is to start failing requests if due to a logic error - // in the program we're hammering GAIA. -#if defined(OS_WIN) - __time32_t now = _time32(0); -#else // defined(OS_WIN) - time_t now = time(0); -#endif // defined(OS_WIN) - - if (now > next_allowed_auth_attempt_time_) { - next_allowed_auth_attempt_time_ = now + 1; - // If we're more than 2 minutes past the allowed time we reset the early - // attempt count. - if (now - next_allowed_auth_attempt_time_ > 2 * 60) { - delay_ = 1; - early_auth_attempt_count_ = 0; - } - } else { - ++early_auth_attempt_count_; - // Allow 3 attempts, but then limit. - if (early_auth_attempt_count_ > 3) { - delay_ = GetBackoffDelaySeconds(delay_); - next_allowed_auth_attempt_time_ = now + delay_; - return false; - } - } - - return PerformGaiaRequest(params, results); -} - -bool GaiaAuthenticator::PerformGaiaRequest(const AuthParams& params, - AuthResults* results) { - DCHECK_EQ(base::MessageLoop::current(), message_loop_); - GURL gaia_auth_url(gaia_url_); - - string post_body; - post_body += "Email=" + net::EscapeUrlEncodedData(params.email, true); - post_body += "&Passwd=" + net::EscapeUrlEncodedData(params.password, true); - post_body += "&source=" + net::EscapeUrlEncodedData(user_agent_, true); - post_body += "&service=" + service_id_; - if (!params.captcha_token.empty() && !params.captcha_value.empty()) { - post_body += "&logintoken=" + - net::EscapeUrlEncodedData(params.captcha_token, true); - post_body += "&logincaptcha=" + - net::EscapeUrlEncodedData(params.captcha_value, true); - } - post_body += "&PersistentCookie=true"; - // We set it to GOOGLE (and not HOSTED or HOSTED_OR_GOOGLE) because we only - // allow consumer logins. - post_body += "&accountType=GOOGLE"; - - string message_text; - unsigned long server_response_code; - if (!Post(gaia_auth_url, post_body, &server_response_code, &message_text)) { - results->auth_error = ConnectionUnavailable; - return false; - } - - // Parse reply in two different ways, depending on if request failed or - // succeeded. - if (net::HTTP_FORBIDDEN == server_response_code) { - ExtractAuthErrorFrom(message_text, results); - return false; - } else if (net::HTTP_OK == server_response_code) { - ExtractTokensFrom(message_text, results); - if (!IssueAuthToken(results, service_id_)) { - return false; - } - - return LookupEmail(results); - } else { - results->auth_error = Unknown; - return false; - } -} - -bool GaiaAuthenticator::Post(const GURL& url, - const std::string& post_body, - unsigned long* response_code, - std::string* response_body) { - return false; -} - -bool GaiaAuthenticator::LookupEmail(AuthResults* results) { - DCHECK_EQ(base::MessageLoop::current(), message_loop_); - // Use the provided Gaia server, but change the path to what V1 expects. - GURL url(gaia_url_); // Gaia server. - GURL::Replacements repl; - // Needs to stay in scope till GURL is out of scope. - string path(kGetUserInfoPath); - repl.SetPathStr(path); - url = url.ReplaceComponents(repl); - - string post_body; - post_body += "LSID="; - post_body += net::EscapeUrlEncodedData(results->lsid, true); - - unsigned long server_response_code; - string message_text; - if (!Post(url, post_body, &server_response_code, &message_text)) { - return false; - } - - // Check if we received a valid AuthToken; if not, ignore it. - if (net::HTTP_FORBIDDEN == server_response_code) { - // Server says we're not authenticated. - ExtractAuthErrorFrom(message_text, results); - return false; - } else if (net::HTTP_OK == server_response_code) { - typedef vector<pair<string, string> > Tokens; - Tokens tokens; - base::SplitStringIntoKeyValuePairs(message_text, '=', '\n', &tokens); - for (Tokens::iterator i = tokens.begin(); i != tokens.end(); ++i) { - if ("accountType" == i->first) { - // We never authenticate an email as a hosted account. - DCHECK_EQ("GOOGLE", i->second); - } else if ("email" == i->first) { - results->primary_email = i->second; - } - } - return true; - } - return false; -} - -int GaiaAuthenticator::GetBackoffDelaySeconds(int current_backoff_delay) { - NOTREACHED(); - return current_backoff_delay; -} - -// We need to call this explicitly when we need to obtain a long-lived session -// token. -bool GaiaAuthenticator::IssueAuthToken(AuthResults* results, - const string& service_id) { - DCHECK_EQ(base::MessageLoop::current(), message_loop_); - // Use the provided Gaia server, but change the path to what V1 expects. - GURL url(gaia_url_); // Gaia server. - GURL::Replacements repl; - // Needs to stay in scope till GURL is out of scope. - string path(kGaiaV1IssueAuthTokenPath); - repl.SetPathStr(path); - url = url.ReplaceComponents(repl); - - string post_body; - post_body += "LSID="; - post_body += net::EscapeUrlEncodedData(results->lsid, true); - post_body += "&service=" + service_id; - post_body += "&Session=true"; - - unsigned long server_response_code; - string message_text; - if (!Post(url, post_body, &server_response_code, &message_text)) { - return false; - } - - // Check if we received a valid AuthToken; if not, ignore it. - if (net::HTTP_FORBIDDEN == server_response_code) { - // Server says we're not authenticated. - ExtractAuthErrorFrom(message_text, results); - return false; - } else if (net::HTTP_OK == server_response_code) { - // Note that the format of message_text is different from what is returned - // in the first request, or to the sole request that is made to Gaia V2. - // Specifically, the entire string is the AuthToken, and looks like: - // "<token>" rather than "AuthToken=<token>". Thus, we need not use - // ExtractTokensFrom(...), but simply assign the token. - int last_index = message_text.length() - 1; - if ('\n' == message_text[last_index]) - message_text.erase(last_index); - results->auth_token = message_text; - return true; - } - return false; -} - -// Helper method that extracts tokens from a successful reply, and saves them -// in the right fields. -void GaiaAuthenticator::ExtractTokensFrom(const string& response, - AuthResults* results) { - vector<pair<string, string> > tokens; - base::SplitStringIntoKeyValuePairs(response, '=', '\n', &tokens); - for (vector<pair<string, string> >::iterator i = tokens.begin(); - i != tokens.end(); ++i) { - if (i->first == "SID") { - results->sid = i->second; - } else if (i->first == "LSID") { - results->lsid = i->second; - } else if (i->first == "Auth") { - results->auth_token = i->second; - } - } -} - -// Helper method that extracts tokens from a failure response, and saves them -// in the right fields. -void GaiaAuthenticator::ExtractAuthErrorFrom(const string& response, - AuthResults* results) { - vector<pair<string, string> > tokens; - base::SplitStringIntoKeyValuePairs(response, '=', '\n', &tokens); - for (vector<pair<string, string> >::iterator i = tokens.begin(); - i != tokens.end(); ++i) { - if (i->first == "Error") { - results->error_msg = i->second; - } else if (i->first == "Url") { - results->auth_error_url = i->second; - } else if (i->first == "CaptchaToken") { - results->captcha_token = i->second; - } else if (i->first == "CaptchaUrl") { - results->captcha_url = i->second; - } - } - - // Convert string error messages to enum values. Each case has two different - // strings; the first one is the most current and the second one is - // deprecated, but available. - const string& error_msg = results->error_msg; - if (error_msg == "BadAuthentication" || error_msg == "badauth") { - results->auth_error = BadAuthentication; - } else if (error_msg == "NotVerified" || error_msg == "nv") { - results->auth_error = NotVerified; - } else if (error_msg == "TermsNotAgreed" || error_msg == "tna") { - results->auth_error = TermsNotAgreed; - } else if (error_msg == "Unknown" || error_msg == "unknown") { - results->auth_error = Unknown; - } else if (error_msg == "AccountDeleted" || error_msg == "adel") { - results->auth_error = AccountDeleted; - } else if (error_msg == "AccountDisabled" || error_msg == "adis") { - results->auth_error = AccountDisabled; - } else if (error_msg == "CaptchaRequired" || error_msg == "cr") { - results->auth_error = CaptchaRequired; - } else if (error_msg == "ServiceUnavailable" || error_msg == "ire") { - results->auth_error = ServiceUnavailable; - } -} - -// Reset all stored credentials, perhaps in preparation for letting a different -// user sign in. -void GaiaAuthenticator::ResetCredentials() { - DCHECK_EQ(base::MessageLoop::current(), message_loop_); - AuthResults blank; - auth_results_ = blank; -} - -void GaiaAuthenticator::SetUsernamePassword(const string& username, - const string& password) { - DCHECK_EQ(base::MessageLoop::current(), message_loop_); - auth_results_.password = password; - auth_results_.email = username; -} - -void GaiaAuthenticator::SetUsername(const string& username) { - DCHECK_EQ(base::MessageLoop::current(), message_loop_); - auth_results_.email = username; -} - -void GaiaAuthenticator::RenewAuthToken(const string& auth_token) { - DCHECK_EQ(base::MessageLoop::current(), message_loop_); - DCHECK(!this->auth_token().empty()); - auth_results_.auth_token = auth_token; -} -void GaiaAuthenticator::SetAuthToken(const string& auth_token) { - DCHECK_EQ(base::MessageLoop::current(), message_loop_); - auth_results_.auth_token = auth_token; -} - -bool GaiaAuthenticator::Authenticate(const string& user_name, - const string& password) { - DCHECK_EQ(base::MessageLoop::current(), message_loop_); - const string empty; - return Authenticate(user_name, password, empty, - empty); -} - -} // namespace gaia diff --git a/google_apis/gaia/gaia_authenticator.h b/google_apis/gaia/gaia_authenticator.h deleted file mode 100644 index c9bf3bc..0000000 --- a/google_apis/gaia/gaia_authenticator.h +++ /dev/null @@ -1,271 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. -// -// Use this class to authenticate users with Gaia and access cookies sent -// by the Gaia servers. This class cannot be used on its own becaue it relies -// on a subclass to provide the virtual Post and GetBackoffDelaySeconds methods. -// -// Sample usage: -// class ActualGaiaAuthenticator : public gaia::GaiaAuthenticator { -// Provides actual implementation of Post and GetBackoffDelaySeconds. -// }; -// ActualGaiaAuthenticator gaia_auth("User-Agent", SERVICE_NAME, kGaiaUrl); -// if (gaia_auth.Authenticate("email", "passwd", SAVE_IN_MEMORY_ONLY, -// true)) { // Synchronous -// // Do something with: gaia_auth.auth_token(), or gaia_auth.sid(), -// // or gaia_auth.lsid() -// } -// -// Credentials can also be preserved for subsequent requests, though these are -// saved in plain-text in memory, and not very secure on client systems. The -// email address associated with the Gaia account can be read; the password is -// write-only. - -// TODO(sanjeevr): This class has been moved here from the bookmarks sync code. -// While it is a generic class that handles GAIA authentication, there are some -// artifacts of the sync code which needs to be cleaned up. -#ifndef GOOGLE_APIS_GAIA_GAIA_AUTHENTICATOR_H_ -#define GOOGLE_APIS_GAIA_GAIA_AUTHENTICATOR_H_ - -#include <string> - -#include "base/basictypes.h" -#include "base/gtest_prod_util.h" -#include "base/message_loop.h" -#include "googleurl/src/gurl.h" - -namespace gaia { - -// Error codes from Gaia. These will be set correctly for both Gaia V1 -// (/ClientAuth) and V2 (/ClientLogin) -enum AuthenticationError { - None = 0, - BadAuthentication = 1, - NotVerified = 2, - TermsNotAgreed = 3, - Unknown = 4, - AccountDeleted = 5, - AccountDisabled = 6, - CaptchaRequired = 7, - ServiceUnavailable = 8, - // Errors generated by this class not Gaia. - CredentialsNotSet = 9, - ConnectionUnavailable = 10 -}; - -class GaiaAuthenticator; - -// GaiaAuthenticator can be used to pass user credentials to Gaia and obtain -// cookies set by the Gaia servers. -class GaiaAuthenticator { - FRIEND_TEST_ALL_PREFIXES(GaiaAuthenticatorTest, - TestNewlineAtEndOfAuthTokenRemoved); - public: - - // Since GaiaAuthenticator can be used for any service, or by any client, you - // must include a user-agent and a service-id when creating one. The - // user_agent is a short string used for simple log analysis. gaia_url is used - // to choose the server to authenticate with (e.g. - // http://accounts.google.com/ClientLogin). - GaiaAuthenticator(const std::string& user_agent, - const std::string& service_id, - const std::string& gaia_url); - - virtual ~GaiaAuthenticator(); - - // This object should only be invoked from the AuthWatcherThread message - // loop, which is injected here. - void set_message_loop(const base::MessageLoop* loop) { message_loop_ = loop; } - - // Pass credentials to authenticate with, or use saved credentials via an - // overload. If authentication succeeds, you can retrieve the authentication - // token via the respective accessors. Returns a boolean indicating whether - // authentication succeeded or not. - bool Authenticate(const std::string& user_name, const std::string& password, - const std::string& captcha_token, - const std::string& captcha_value); - - bool Authenticate(const std::string& user_name, const std::string& password); - - // Pass the LSID to authenticate with. If the authentication succeeds, you can - // retrieve the authetication token via the respective accessors. Returns a - // boolean indicating whether authentication succeeded or not. - // Always returns a long lived token. - bool AuthenticateWithLsid(const std::string& lsid); - - // Resets all stored cookies to their default values. - void ResetCredentials(); - - void SetUsernamePassword(const std::string& username, - const std::string& password); - - void SetUsername(const std::string& username); - - // Virtual for testing - virtual void RenewAuthToken(const std::string& auth_token); - void SetAuthToken(const std::string& auth_token); - - struct AuthResults { - AuthResults(); - AuthResults(const AuthResults& other); - ~AuthResults(); - - std::string email; - std::string password; - - // Fields that store various cookies. - std::string sid; - std::string lsid; - std::string auth_token; - - std::string primary_email; - - // Fields for items returned when authentication fails. - std::string error_msg; - enum AuthenticationError auth_error; - std::string auth_error_url; - std::string captcha_token; - std::string captcha_url; - }; - - protected: - - struct AuthParams { - AuthParams(); - ~AuthParams(); - - GaiaAuthenticator* authenticator; - uint32 request_id; - std::string email; - std::string password; - std::string captcha_token; - std::string captcha_value; - }; - - // mutex_ must be entered before calling this function. - AuthParams MakeParams(const std::string& user_name, - const std::string& password, - const std::string& captcha_token, - const std::string& captcha_value); - - // The real Authenticate implementations. - bool AuthenticateImpl(const AuthParams& params); - bool AuthenticateImpl(const AuthParams& params, AuthResults* results); - - // virtual for testing purposes. - virtual bool PerformGaiaRequest(const AuthParams& params, - AuthResults* results); - virtual bool Post(const GURL& url, const std::string& post_body, - unsigned long* response_code, std::string* response_body); - - // Caller should fill in results->LSID before calling. Result in - // results->primary_email. - virtual bool LookupEmail(AuthResults* results); - - // Subclasses must override to provide a backoff delay. It is virtual instead - // of pure virtual for testing purposes. - // TODO(sanjeevr): This should be made pure virtual. But this class is - // currently directly being used in sync/engine/authenticator.cc, which is - // wrong. - virtual int GetBackoffDelaySeconds(int current_backoff_delay); - - public: - // Retrieve email. - inline std::string email() const { - DCHECK_EQ(base::MessageLoop::current(), message_loop_); - return auth_results_.email; - } - - // Retrieve password. - inline std::string password() const { - DCHECK_EQ(base::MessageLoop::current(), message_loop_); - return auth_results_.password; - } - - // Retrieve AuthToken, if previously authenticated; otherwise returns "". - inline std::string auth_token() const { - DCHECK_EQ(base::MessageLoop::current(), message_loop_); - return auth_results_.auth_token; - } - - // Retrieve SID cookie. For details, see the Google Accounts documentation. - inline std::string sid() const { - DCHECK_EQ(base::MessageLoop::current(), message_loop_); - return auth_results_.sid; - } - - // Retrieve LSID cookie. For details, see the Google Accounts documentation. - inline std::string lsid() const { - DCHECK_EQ(base::MessageLoop::current(), message_loop_); - return auth_results_.lsid; - } - - // Get last authentication error. - inline enum AuthenticationError auth_error() const { - DCHECK_EQ(base::MessageLoop::current(), message_loop_); - return auth_results_.auth_error; - } - - inline std::string auth_error_url() const { - DCHECK_EQ(base::MessageLoop::current(), message_loop_); - return auth_results_.auth_error_url; - } - - inline std::string captcha_token() const { - DCHECK_EQ(base::MessageLoop::current(), message_loop_); - return auth_results_.captcha_token; - } - - inline std::string captcha_url() const { - DCHECK_EQ(base::MessageLoop::current(), message_loop_); - return auth_results_.captcha_url; - } - - inline AuthResults results() const { - DCHECK_EQ(base::MessageLoop::current(), message_loop_); - return auth_results_; - } - - private: - bool IssueAuthToken(AuthResults* results, const std::string& service_id); - - // Helper method to parse response when authentication succeeds. - void ExtractTokensFrom(const std::string& response, AuthResults* results); - // Helper method to parse response when authentication fails. - void ExtractAuthErrorFrom(const std::string& response, AuthResults* results); - - // Fields for the obvious data items. - const std::string user_agent_; - const std::string service_id_; - const std::string gaia_url_; - - AuthResults auth_results_; - - // When multiple async requests are running, only the one that started most - // recently updates the values. - // - // Note that even though this code was written to handle multiple requests - // simultaneously, the sync code issues auth requests one at a time. - uint32 request_count_; - - // Used to compute backoff time for next allowed authentication. - int delay_; // In seconds. - // On Windows, time_t is 64-bit by default. Even though we have defined the - // _USE_32BIT_TIME_T preprocessor flag, other libraries including this header - // may not have that preprocessor flag defined resulting in mismatched class - // sizes. So we explicitly define it as 32-bit on Windows. - // TODO(sanjeevr): Change this to to use base::Time -#if defined(OS_WIN) - __time32_t next_allowed_auth_attempt_time_; -#else // defined(OS_WIN) - time_t next_allowed_auth_attempt_time_; -#endif // defined(OS_WIN) - int early_auth_attempt_count_; - - // The message loop all our methods are invoked on. - const base::MessageLoop* message_loop_; -}; - -} // namespace gaia -#endif // GOOGLE_APIS_GAIA_GAIA_AUTHENTICATOR_H_ diff --git a/google_apis/gaia/gaia_authenticator_unittest.cc b/google_apis/gaia/gaia_authenticator_unittest.cc deleted file mode 100644 index de979e2..0000000 --- a/google_apis/gaia/gaia_authenticator_unittest.cc +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "google_apis/gaia/gaia_authenticator.h" - -#include <string> - -#include "googleurl/src/gurl.h" -#include "net/http/http_status_code.h" -#include "testing/gtest/include/gtest/gtest.h" - -using std::string; - -namespace gaia { - -class GaiaAuthenticatorTest : public testing::Test { }; - -class GaiaAuthMockForGaiaAuthenticator : public GaiaAuthenticator { - public: - GaiaAuthMockForGaiaAuthenticator() - : GaiaAuthenticator("useragent", "serviceid", "http://gaia_url") {} - virtual ~GaiaAuthMockForGaiaAuthenticator() {} - protected: - virtual bool Post( - const GURL& url, - const string& post_body, - unsigned long* response_code, - string* response_body) OVERRIDE { - *response_code = net::HTTP_OK; - response_body->assign("body\n"); - return true; - } - - virtual int GetBackoffDelaySeconds( - int current_backoff_delay) OVERRIDE { - // Dummy delay value. - return 5; - } -}; - -TEST(GaiaAuthenticatorTest, TestNewlineAtEndOfAuthTokenRemoved) { - GaiaAuthMockForGaiaAuthenticator mock_auth; - base::MessageLoop message_loop; - mock_auth.set_message_loop(&message_loop); - GaiaAuthenticator::AuthResults results; - EXPECT_TRUE(mock_auth.IssueAuthToken(&results, "sid")); - EXPECT_EQ(0, results.auth_token.compare("body")); -} - -} // namespace gaia - diff --git a/google_apis/gaia/gaia_constants.cc b/google_apis/gaia/gaia_constants.cc index c4086fe..fed899a 100644 --- a/google_apis/gaia/gaia_constants.cc +++ b/google_apis/gaia/gaia_constants.cc @@ -22,8 +22,6 @@ const char kSyncService[] = "chromiumsync"; // Service name for remoting. const char kRemotingService[] = "chromoting"; -// Service name for cloud print. -const char kCloudPrintService[] = "cloudprint"; // Service/scope names for device management (cloud-based policy) server. const char kDeviceManagementServiceOAuth[] = diff --git a/google_apis/gaia/gaia_constants.h b/google_apis/gaia/gaia_constants.h index 0b09b27..ad469c2 100644 --- a/google_apis/gaia/gaia_constants.h +++ b/google_apis/gaia/gaia_constants.h @@ -18,7 +18,6 @@ extern const char kGaiaService[]; // uber token extern const char kPicasaService[]; extern const char kSyncService[]; extern const char kRemotingService[]; -extern const char kCloudPrintService[]; extern const char kDeviceManagementServiceOAuth[]; extern const char kAnyApiOAuth2Scope[]; extern const char kChromeSyncOAuth2Scope[]; |