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

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
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 28 matching lines...) Expand all
39 39
40 std::string token; 40 std::string token;
41 std::string issued_to; 41 std::string issued_to;
42 std::string audience; 42 std::string audience;
43 std::string user_id; 43 std::string user_id;
44 ScopeSet scopes; 44 ScopeSet scopes;
45 int expires_in; 45 int expires_in;
46 std::string email; 46 std::string email;
47 }; 47 };
48 48
49 // Cookies and tokens for /MergeSession call seqeunce.
50 struct MergeSessionParams {
51 // Values of SID and LSID cookie that are set by
52 std::string auth_sid_cookie;
53 std::string auth_lsid_cookie;
54
55 // auth_code cookie value response for /o/oauth2/programmatic_auth call.
56 std::string auth_code;
57
58 // OAuth2 refresh and access token generated by /o/oauth2/token call
59 // with "...&grant_type=authorization_code".
60 std::string refresh_token;
61 std::string access_token;
62
63 // Uber token response from /OAuthLogin call.
64 std::string gaia_uber_token;
65
66 // Values of SID and LSID cookie generated from /MergeSession call.
67 std::string session_sid_cookie;
68 std::string session_lsid_cookie;
69 };
70
49 FakeGaia(); 71 FakeGaia();
50 ~FakeGaia(); 72 ~FakeGaia();
51 73
52 // Sets the initial value of tokens and cookies. 74 // Sets the initial value of tokens and cookies.
53 void SetAuthTokens(const std::string& auth_code, 75 void SetMergeSessionParams(const MergeSessionParams& params);
54 const std::string& refresh_token,
55 const std::string& access_token,
56 const std::string& gaia_uber_token,
57 const std::string& session_sid_cookie,
58 const std::string& session_lsid_cookie);
59 76
60 // Initializes HTTP request handlers. Should be called after switches 77 // Initializes HTTP request handlers. Should be called after switches
61 // for tweaking GaiaUrls are in place. 78 // for tweaking GaiaUrls are in place.
62 void Initialize(); 79 void Initialize();
63 80
64 // Handles a request and returns a response if the request was recognized as a 81 // Handles a request and returns a response if the request was recognized as a
65 // GAIA request. Note that this respects the switches::kGaiaUrl and friends so 82 // GAIA request. Note that this respects the switches::kGaiaUrl and friends so
66 // that this can used with EmbeddedTestServer::RegisterRequestHandler(). 83 // that this can used with EmbeddedTestServer::RegisterRequestHandler().
67 scoped_ptr<net::test_server::HttpResponse> HandleRequest( 84 scoped_ptr<net::test_server::HttpResponse> HandleRequest(
68 const net::test_server::HttpRequest& request); 85 const net::test_server::HttpRequest& request);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 126
110 // Returns the access token associated with |auth_token| that matches the 127 // Returns the access token associated with |auth_token| that matches the
111 // given |client_id| and |scope_string|. If |scope_string| is empty, the first 128 // given |client_id| and |scope_string|. If |scope_string| is empty, the first
112 // token satisfying the other criteria is returned. Returns NULL if no token 129 // token satisfying the other criteria is returned. Returns NULL if no token
113 // matches. 130 // matches.
114 const AccessTokenInfo* FindAccessTokenInfo(const std::string& auth_token, 131 const AccessTokenInfo* FindAccessTokenInfo(const std::string& auth_token,
115 const std::string& client_id, 132 const std::string& client_id,
116 const std::string& scope_string) 133 const std::string& scope_string)
117 const; 134 const;
118 135
119 // Extracts the |access_token| from authorization header of |request|. 136 MergeSessionParams merge_session_params_;
120 static bool GetAccessToken(const net::test_server::HttpRequest& request,
121 const char* auth_token_prefix,
122 std::string* access_token);
123
124 // Extracts the parameter named |key| from |query| and places it in |value|.
125 // Returns false if no parameter is found.
126 static bool GetQueryParameter(const std::string& query,
127 const std::string& key,
128 std::string* value);
xiyuan 2013/12/17 17:12:57 My SAMLTest CL uses GetQueryParameter to extract f
zel 2013/12/17 17:23:15 I will expose this method once I merge everything.
129
130 // auth_code cookie value response for /o/oauth2/programmatic_auth call.
131 std::string fake_auth_code_;
132
133 // refresh_token field value response for the initial /o/oauth2/token call
134 // with ...&grant_type=authorization_code.
135 std::string fake_refresh_token_;
136 std::string fake_access_token_;
137 std::string fake_gaia_uber_token_;
138 std::string fake_session_sid_cookie_;
139 std::string fake_session_lsid_cookie_;
140
141 AccessTokenInfoMap access_token_info_map_; 137 AccessTokenInfoMap access_token_info_map_;
142 RequestHandlerMap request_handlers_; 138 RequestHandlerMap request_handlers_;
143 std::string service_login_response_; 139 std::string service_login_response_;
144 140
145 DISALLOW_COPY_AND_ASSIGN(FakeGaia); 141 DISALLOW_COPY_AND_ASSIGN(FakeGaia);
146 }; 142 };
147 143
148 #endif // GOOGLE_APIS_GAIA_FAKE_GAIA_H_ 144 #endif // GOOGLE_APIS_GAIA_FAKE_GAIA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698