| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #ifndef GOOGLE_APIS_GAIA_FAKE_GAIA_H_ | 5 #ifndef GOOGLE_APIS_GAIA_FAKE_GAIA_H_ |
| 6 #define GOOGLE_APIS_GAIA_FAKE_GAIA_H_ | 6 #define GOOGLE_APIS_GAIA_FAKE_GAIA_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 ScopeSet scopes; | 45 ScopeSet scopes; |
| 46 int expires_in; | 46 int expires_in; |
| 47 std::string email; | 47 std::string email; |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 // Cookies and tokens for /MergeSession call seqeunce. | 50 // Cookies and tokens for /MergeSession call seqeunce. |
| 51 struct MergeSessionParams { | 51 struct MergeSessionParams { |
| 52 MergeSessionParams(); | 52 MergeSessionParams(); |
| 53 ~MergeSessionParams(); | 53 ~MergeSessionParams(); |
| 54 | 54 |
| 55 // Values of SID and LSID cookie that are set by | 55 // Values of SID and LSID cookie that are set by /ServiceLoginAuth or its |
| 56 // equivalent at the end of the SAML login flow. |
| 56 std::string auth_sid_cookie; | 57 std::string auth_sid_cookie; |
| 57 std::string auth_lsid_cookie; | 58 std::string auth_lsid_cookie; |
| 58 | 59 |
| 59 // auth_code cookie value response for /o/oauth2/programmatic_auth call. | 60 // auth_code cookie value response for /o/oauth2/programmatic_auth call. |
| 60 std::string auth_code; | 61 std::string auth_code; |
| 61 | 62 |
| 62 // OAuth2 refresh and access token generated by /o/oauth2/token call | 63 // OAuth2 refresh and access token generated by /o/oauth2/token call |
| 63 // with "...&grant_type=authorization_code". | 64 // with "...&grant_type=authorization_code". |
| 64 std::string refresh_token; | 65 std::string refresh_token; |
| 65 std::string access_token; | 66 std::string access_token; |
| 66 | 67 |
| 67 // Uber token response from /OAuthLogin call. | 68 // Uber token response from /OAuthLogin call. |
| 68 std::string gaia_uber_token; | 69 std::string gaia_uber_token; |
| 69 | 70 |
| 70 // Values of SID and LSID cookie generated from /MergeSession call. | 71 // Values of SID and LSID cookie generated from /MergeSession call. |
| 71 std::string session_sid_cookie; | 72 std::string session_sid_cookie; |
| 72 std::string session_lsid_cookie; | 73 std::string session_lsid_cookie; |
| 74 |
| 75 // The e-mail address returned by /GetUserInfo. |
| 76 std::string email; |
| 73 }; | 77 }; |
| 74 | 78 |
| 75 FakeGaia(); | 79 FakeGaia(); |
| 76 virtual ~FakeGaia(); | 80 virtual ~FakeGaia(); |
| 77 | 81 |
| 78 // Sets the initial value of tokens and cookies. | 82 // Sets the initial value of tokens and cookies. |
| 79 void SetMergeSessionParams(const MergeSessionParams& params); | 83 void SetMergeSessionParams(const MergeSessionParams& params); |
| 80 | 84 |
| 81 // Initializes HTTP request handlers. Should be called after switches | 85 // Initializes HTTP request handlers. Should be called after switches |
| 82 // for tweaking GaiaUrls are in place. | 86 // for tweaking GaiaUrls are in place. |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 typedef std::map<std::string, HttpRequestHandlerCallback> RequestHandlerMap; | 130 typedef std::map<std::string, HttpRequestHandlerCallback> RequestHandlerMap; |
| 127 | 131 |
| 128 // HTTP request handlers. | 132 // HTTP request handlers. |
| 129 void HandleProgramaticAuth( | 133 void HandleProgramaticAuth( |
| 130 const net::test_server::HttpRequest& request, | 134 const net::test_server::HttpRequest& request, |
| 131 net::test_server::BasicHttpResponse* http_response); | 135 net::test_server::BasicHttpResponse* http_response); |
| 132 void HandleServiceLogin(const net::test_server::HttpRequest& request, | 136 void HandleServiceLogin(const net::test_server::HttpRequest& request, |
| 133 net::test_server::BasicHttpResponse* http_response); | 137 net::test_server::BasicHttpResponse* http_response); |
| 134 void HandleOAuthLogin(const net::test_server::HttpRequest& request, | 138 void HandleOAuthLogin(const net::test_server::HttpRequest& request, |
| 135 net::test_server::BasicHttpResponse* http_response); | 139 net::test_server::BasicHttpResponse* http_response); |
| 136 void HandleSSO(const net::test_server::HttpRequest& request, | |
| 137 net::test_server::BasicHttpResponse* http_response); | |
| 138 void HandleServiceLoginAuth( | 140 void HandleServiceLoginAuth( |
| 139 const net::test_server::HttpRequest& request, | 141 const net::test_server::HttpRequest& request, |
| 140 net::test_server::BasicHttpResponse* http_response); | 142 net::test_server::BasicHttpResponse* http_response); |
| 143 void HandleSSO(const net::test_server::HttpRequest& request, |
| 144 net::test_server::BasicHttpResponse* http_response); |
| 141 void HandleAuthToken(const net::test_server::HttpRequest& request, | 145 void HandleAuthToken(const net::test_server::HttpRequest& request, |
| 142 net::test_server::BasicHttpResponse* http_response); | 146 net::test_server::BasicHttpResponse* http_response); |
| 143 void HandleTokenInfo(const net::test_server::HttpRequest& request, | 147 void HandleTokenInfo(const net::test_server::HttpRequest& request, |
| 144 net::test_server::BasicHttpResponse* http_response); | 148 net::test_server::BasicHttpResponse* http_response); |
| 145 void HandleIssueToken(const net::test_server::HttpRequest& request, | 149 void HandleIssueToken(const net::test_server::HttpRequest& request, |
| 146 net::test_server::BasicHttpResponse* http_response); | 150 net::test_server::BasicHttpResponse* http_response); |
| 151 void HandleGetUserInfo(const net::test_server::HttpRequest& request, |
| 152 net::test_server::BasicHttpResponse* http_response); |
| 147 | 153 |
| 148 // Returns the access token associated with |auth_token| that matches the | 154 // Returns the access token associated with |auth_token| that matches the |
| 149 // given |client_id| and |scope_string|. If |scope_string| is empty, the first | 155 // given |client_id| and |scope_string|. If |scope_string| is empty, the first |
| 150 // token satisfying the other criteria is returned. Returns NULL if no token | 156 // token satisfying the other criteria is returned. Returns NULL if no token |
| 151 // matches. | 157 // matches. |
| 152 const AccessTokenInfo* FindAccessTokenInfo(const std::string& auth_token, | 158 const AccessTokenInfo* FindAccessTokenInfo(const std::string& auth_token, |
| 153 const std::string& client_id, | 159 const std::string& client_id, |
| 154 const std::string& scope_string) | 160 const std::string& scope_string) |
| 155 const; | 161 const; |
| 156 | 162 |
| 157 MergeSessionParams merge_session_params_; | 163 MergeSessionParams merge_session_params_; |
| 158 AccessTokenInfoMap access_token_info_map_; | 164 AccessTokenInfoMap access_token_info_map_; |
| 159 RequestHandlerMap request_handlers_; | 165 RequestHandlerMap request_handlers_; |
| 160 std::string service_login_response_; | 166 std::string service_login_response_; |
| 161 SamlAccountIdpMap saml_account_idp_map_; | 167 SamlAccountIdpMap saml_account_idp_map_; |
| 162 | 168 |
| 163 DISALLOW_COPY_AND_ASSIGN(FakeGaia); | 169 DISALLOW_COPY_AND_ASSIGN(FakeGaia); |
| 164 }; | 170 }; |
| 165 | 171 |
| 166 #endif // GOOGLE_APIS_GAIA_FAKE_GAIA_H_ | 172 #endif // GOOGLE_APIS_GAIA_FAKE_GAIA_H_ |
| OLD | NEW |