OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // A complete set of unit tests for GaiaOAuthClient. | 5 // A complete set of unit tests for GaiaOAuthClient. |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 }; | 127 }; |
128 | 128 |
129 const std::string kTestAccessToken = "1/fFAGRNJru1FTz70BzhT3Zg"; | 129 const std::string kTestAccessToken = "1/fFAGRNJru1FTz70BzhT3Zg"; |
130 const std::string kTestRefreshToken = | 130 const std::string kTestRefreshToken = |
131 "1/6BMfW9j53gdGImsixUH6kU5RsR4zwI9lUVX-tqf8JXQ"; | 131 "1/6BMfW9j53gdGImsixUH6kU5RsR4zwI9lUVX-tqf8JXQ"; |
132 const std::string kTestUserEmail = "a_user@gmail.com"; | 132 const std::string kTestUserEmail = "a_user@gmail.com"; |
133 const std::string kTestUserId = "8675309"; | 133 const std::string kTestUserId = "8675309"; |
134 const int kTestExpiresIn = 3920; | 134 const int kTestExpiresIn = 3920; |
135 | 135 |
136 const std::string kDummyGetTokensResult = | 136 const std::string kDummyGetTokensResult = |
137 "{\"access_token\":\"" + kTestAccessToken + "\"," | 137 "{\"access_token\":\"" + kTestAccessToken + "\"," |
138 "\"expires_in\":" + base::IntToString(kTestExpiresIn) + "," | 138 "\"expires_in\":" + base::IntToString(kTestExpiresIn) + "," |
139 "\"refresh_token\":\"" + kTestRefreshToken + "\"}"; | 139 "\"refresh_token\":\"" + kTestRefreshToken + "\"}"; |
140 | 140 |
141 const std::string kDummyRefreshTokenResult = | 141 const std::string kDummyRefreshTokenResult = |
142 "{\"access_token\":\"" + kTestAccessToken + "\"," | 142 "{\"access_token\":\"" + kTestAccessToken + "\"," |
143 "\"expires_in\":" + base::IntToString(kTestExpiresIn) + "}"; | 143 "\"expires_in\":" + base::IntToString(kTestExpiresIn) + "}"; |
144 | 144 |
145 const std::string kDummyUserInfoResult = | 145 const std::string kDummyUserInfoResult = |
146 "{\"email\":\"" + kTestUserEmail + "\"}"; | 146 "{\"emails\": [{\"value\":\"" + kTestUserEmail + |
| 147 "\", \"type\":\"account\"}]}"; |
147 | 148 |
148 const std::string kDummyUserIdResult = | 149 const std::string kDummyUserIdResult = |
149 "{\"id\":\"" + kTestUserId + "\"}"; | 150 "{\"id\":\"" + kTestUserId + "\"}"; |
150 | 151 |
151 const std::string kDummyTokenInfoResult = | 152 const std::string kDummyTokenInfoResult = |
152 "{\"issued_to\": \"1234567890.apps.googleusercontent.com\"," | 153 "{\"issued_to\": \"1234567890.apps.googleusercontent.com\"," |
153 "\"audience\": \"1234567890.apps.googleusercontent.com\"," | 154 "\"audience\": \"1234567890.apps.googleusercontent.com\"," |
154 "\"scope\": \"https://googleapis.com/oauth2/v2/tokeninfo\"," | 155 "\"scope\": \"https://googleapis.com/oauth2/v2/tokeninfo\"," |
155 "\"expires_in\":" + base::IntToString(kTestExpiresIn) + "}"; | 156 "\"expires_in\":" + base::IntToString(kTestExpiresIn) + "}"; |
156 } | 157 } |
157 | 158 |
158 namespace gaia { | 159 namespace gaia { |
159 | 160 |
160 class GaiaOAuthClientTest : public testing::Test { | 161 class GaiaOAuthClientTest : public testing::Test { |
161 protected: | 162 protected: |
162 virtual void SetUp() OVERRIDE { | 163 virtual void SetUp() OVERRIDE { |
163 client_info_.client_id = "test_client_id"; | 164 client_info_.client_id = "test_client_id"; |
164 client_info_.client_secret = "test_client_secret"; | 165 client_info_.client_secret = "test_client_secret"; |
165 client_info_.redirect_uri = "test_redirect_uri"; | 166 client_info_.redirect_uri = "test_redirect_uri"; |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 | 340 |
340 GaiaOAuthClient auth(GetRequestContext()); | 341 GaiaOAuthClient auth(GetRequestContext()); |
341 auth.GetTokenInfo("access_token", 1, &delegate); | 342 auth.GetTokenInfo("access_token", 1, &delegate); |
342 | 343 |
343 std::string issued_to; | 344 std::string issued_to; |
344 ASSERT_TRUE(captured_result->GetString("issued_to", &issued_to)); | 345 ASSERT_TRUE(captured_result->GetString("issued_to", &issued_to)); |
345 ASSERT_EQ("1234567890.apps.googleusercontent.com", issued_to); | 346 ASSERT_EQ("1234567890.apps.googleusercontent.com", issued_to); |
346 } | 347 } |
347 | 348 |
348 } // namespace gaia | 349 } // namespace gaia |
OLD | NEW |