diff options
author | zelidrag@chromium.org <zelidrag@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-17 22:26:55 +0000 |
---|---|---|
committer | zelidrag@chromium.org <zelidrag@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-17 22:26:55 +0000 |
commit | 8549686920da176eec64cddda42ba925b58eff20 (patch) | |
tree | 8804930c8e7467ddb3d16d3710455e19a3c64bcd /google_apis/gaia/fake_gaia.h | |
parent | c2d9d3dfbe090bc8cb5cee9b6c256908a73fadda (diff) | |
download | chromium_src-8549686920da176eec64cddda42ba925b58eff20.zip chromium_src-8549686920da176eec64cddda42ba925b58eff20.tar.gz chromium_src-8549686920da176eec64cddda42ba925b58eff20.tar.bz2 |
Added CrOS-specific OAuth2 browser test.
Expanded FakeGaia class to cover all other auth related calls.
BUG=none
TEST=OAuth2Test.*
R=rogerta@chromium.org, xiyuan@chromium.org
Review URL: https://codereview.chromium.org/99863007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@241389 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'google_apis/gaia/fake_gaia.h')
-rw-r--r-- | google_apis/gaia/fake_gaia.h | 64 |
1 files changed, 61 insertions, 3 deletions
diff --git a/google_apis/gaia/fake_gaia.h b/google_apis/gaia/fake_gaia.h index 7e211ae..6052c2b 100644 --- a/google_apis/gaia/fake_gaia.h +++ b/google_apis/gaia/fake_gaia.h @@ -10,6 +10,7 @@ #include <string> #include "base/basictypes.h" +#include "base/callback.h" #include "base/memory/scoped_ptr.h" #include "url/gurl.h" @@ -49,6 +50,18 @@ class FakeGaia { FakeGaia(); ~FakeGaia(); + // Sets the initial value of tokens and cookies. + void SetAuthTokens(const std::string& auth_code, + const std::string& refresh_token, + const std::string& access_token, + const std::string& gaia_uber_token, + const std::string& session_sid_cookie, + const std::string& session_lsid_cookie); + + // Initializes HTTP request handlers. Should be called after switches + // for tweaking GaiaUrls are in place. + void Initialize(); + // Handles a request and returns a response if the request was recognized as a // GAIA request. Note that this respects the switches::kGaiaUrl and friends so // that this can used with EmbeddedTestServer::RegisterRequestHandler(). @@ -81,16 +94,61 @@ class FakeGaia { void FormatJSONResponse(const base::DictionaryValue& response_dict, net::test_server::BasicHttpResponse* http_response); + typedef base::Callback<void( + const net::test_server::HttpRequest& request, + net::test_server::BasicHttpResponse* http_response)> + HttpRequestHandlerCallback; + typedef std::map<std::string, HttpRequestHandlerCallback> RequestHandlerMap; + + // HTTP request handlers. + void HandleProgramaticAuth( + const net::test_server::HttpRequest& request, + net::test_server::BasicHttpResponse* http_response); + void HandleServiceLogin(const net::test_server::HttpRequest& request, + net::test_server::BasicHttpResponse* http_response); + void HandleOAuthLogin(const net::test_server::HttpRequest& request, + net::test_server::BasicHttpResponse* http_response); + void HandleSSO(const net::test_server::HttpRequest& request, + net::test_server::BasicHttpResponse* http_response); + void HandleMergeSession(const net::test_server::HttpRequest& request, + net::test_server::BasicHttpResponse* http_response); + void HandleServiceLoginAuth( + const net::test_server::HttpRequest& request, + net::test_server::BasicHttpResponse* http_response); + void HandleAuthToken(const net::test_server::HttpRequest& request, + net::test_server::BasicHttpResponse* http_response); + void HandleTokenInfo(const net::test_server::HttpRequest& request, + net::test_server::BasicHttpResponse* http_response); + void HandleIssueToken(const net::test_server::HttpRequest& request, + net::test_server::BasicHttpResponse* http_response); + // Returns the access token associated with |auth_token| that matches the // given |client_id| and |scope_string|. If |scope_string| is empty, the first // token satisfying the other criteria is returned. Returns NULL if no token // matches. - const AccessTokenInfo* GetAccessTokenInfo(const std::string& auth_token, - const std::string& client_id, - const std::string& scope_string) + const AccessTokenInfo* FindAccessTokenInfo(const std::string& auth_token, + const std::string& client_id, + const std::string& scope_string) const; + // Extracts the |access_token| from authorization header of |request|. + static bool GetAccessToken(const net::test_server::HttpRequest& request, + const char* auth_token_prefix, + std::string* access_token); + + // auth_code cookie value response for /o/oauth2/programmatic_auth call. + std::string fake_auth_code_; + + // refresh_token field value response for the initial /o/oauth2/token call + // with ...&grant_type=authorization_code. + std::string fake_refresh_token_; + std::string fake_access_token_; + std::string fake_gaia_uber_token_; + std::string fake_session_sid_cookie_; + std::string fake_session_lsid_cookie_; + AccessTokenInfoMap access_token_info_map_; + RequestHandlerMap request_handlers_; std::string service_login_response_; SamlAccountIdpMap saml_account_idp_map_; |