Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(222)

Side by Side Diff: google_apis/gaia/fake_gaia.h

Issue 108663008: Additional OAuth2 tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/chromeos/login/saml_browsertest.cc ('k') | google_apis/gaia/fake_gaia.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 29 matching lines...) Expand all
40 40
41 std::string token; 41 std::string token;
42 std::string issued_to; 42 std::string issued_to;
43 std::string audience; 43 std::string audience;
44 std::string user_id; 44 std::string user_id;
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.
51 struct MergeSessionParams {
52 MergeSessionParams();
53 ~MergeSessionParams();
54
55 // Values of SID and LSID cookie that are set by
56 std::string auth_sid_cookie;
57 std::string auth_lsid_cookie;
58
59 // auth_code cookie value response for /o/oauth2/programmatic_auth call.
60 std::string auth_code;
61
62 // OAuth2 refresh and access token generated by /o/oauth2/token call
63 // with "...&grant_type=authorization_code".
64 std::string refresh_token;
65 std::string access_token;
66
67 // Uber token response from /OAuthLogin call.
68 std::string gaia_uber_token;
69
70 // Values of SID and LSID cookie generated from /MergeSession call.
71 std::string session_sid_cookie;
72 std::string session_lsid_cookie;
73 };
74
50 FakeGaia(); 75 FakeGaia();
51 ~FakeGaia(); 76 ~FakeGaia();
52 77
53 // Sets the initial value of tokens and cookies. 78 // Sets the initial value of tokens and cookies.
54 void SetAuthTokens(const std::string& auth_code, 79 void SetMergeSessionParams(const MergeSessionParams& params);
55 const std::string& refresh_token,
56 const std::string& access_token,
57 const std::string& gaia_uber_token,
58 const std::string& session_sid_cookie,
59 const std::string& session_lsid_cookie);
60 80
61 // Initializes HTTP request handlers. Should be called after switches 81 // Initializes HTTP request handlers. Should be called after switches
62 // for tweaking GaiaUrls are in place. 82 // for tweaking GaiaUrls are in place.
63 void Initialize(); 83 void Initialize();
64 84
65 // Handles a request and returns a response if the request was recognized as a 85 // Handles a request and returns a response if the request was recognized as a
66 // GAIA request. Note that this respects the switches::kGaiaUrl and friends so 86 // GAIA request. Note that this respects the switches::kGaiaUrl and friends so
67 // that this can used with EmbeddedTestServer::RegisterRequestHandler(). 87 // that this can used with EmbeddedTestServer::RegisterRequestHandler().
68 scoped_ptr<net::test_server::HttpResponse> HandleRequest( 88 scoped_ptr<net::test_server::HttpResponse> HandleRequest(
69 const net::test_server::HttpRequest& request); 89 const net::test_server::HttpRequest& request);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 144
125 // Returns the access token associated with |auth_token| that matches the 145 // Returns the access token associated with |auth_token| that matches the
126 // given |client_id| and |scope_string|. If |scope_string| is empty, the first 146 // given |client_id| and |scope_string|. If |scope_string| is empty, the first
127 // token satisfying the other criteria is returned. Returns NULL if no token 147 // token satisfying the other criteria is returned. Returns NULL if no token
128 // matches. 148 // matches.
129 const AccessTokenInfo* FindAccessTokenInfo(const std::string& auth_token, 149 const AccessTokenInfo* FindAccessTokenInfo(const std::string& auth_token,
130 const std::string& client_id, 150 const std::string& client_id,
131 const std::string& scope_string) 151 const std::string& scope_string)
132 const; 152 const;
133 153
134 // Extracts the |access_token| from authorization header of |request|. 154 MergeSessionParams merge_session_params_;
135 static bool GetAccessToken(const net::test_server::HttpRequest& request,
136 const char* auth_token_prefix,
137 std::string* access_token);
138
139 // auth_code cookie value response for /o/oauth2/programmatic_auth call.
140 std::string fake_auth_code_;
141
142 // refresh_token field value response for the initial /o/oauth2/token call
143 // with ...&grant_type=authorization_code.
144 std::string fake_refresh_token_;
145 std::string fake_access_token_;
146 std::string fake_gaia_uber_token_;
147 std::string fake_session_sid_cookie_;
148 std::string fake_session_lsid_cookie_;
149
150 AccessTokenInfoMap access_token_info_map_; 155 AccessTokenInfoMap access_token_info_map_;
151 RequestHandlerMap request_handlers_; 156 RequestHandlerMap request_handlers_;
152 std::string service_login_response_; 157 std::string service_login_response_;
153 SamlAccountIdpMap saml_account_idp_map_; 158 SamlAccountIdpMap saml_account_idp_map_;
154 159
155 DISALLOW_COPY_AND_ASSIGN(FakeGaia); 160 DISALLOW_COPY_AND_ASSIGN(FakeGaia);
156 }; 161 };
157 162
158 #endif // GOOGLE_APIS_GAIA_FAKE_GAIA_H_ 163 #endif // GOOGLE_APIS_GAIA_FAKE_GAIA_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/saml_browsertest.cc ('k') | google_apis/gaia/fake_gaia.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698