| 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/message_loop.h" | |
| 11 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| 12 #include "base/values.h" | 11 #include "base/values.h" |
| 13 #include "google_apis/gaia/gaia_oauth_client.h" | 12 #include "google_apis/gaia/gaia_oauth_client.h" |
| 14 #include "net/base/net_errors.h" | 13 #include "net/base/net_errors.h" |
| 15 #include "net/http/http_status_code.h" | 14 #include "net/http/http_status_code.h" |
| 16 #include "net/url_request/test_url_fetcher_factory.h" | 15 #include "net/url_request/test_url_fetcher_factory.h" |
| 17 #include "net/url_request/url_fetcher_delegate.h" | 16 #include "net/url_request/url_fetcher_delegate.h" |
| 18 #include "net/url_request/url_request_status.h" | 17 #include "net/url_request/url_request_status.h" |
| 19 #include "net/url_request/url_request_test_util.h" | 18 #include "net/url_request/url_request_test_util.h" |
| 20 #include "testing/gmock/include/gmock/gmock.h" | 19 #include "testing/gmock/include/gmock/gmock.h" |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 const std::string kDummyTokenInfoResult = | 147 const std::string kDummyTokenInfoResult = |
| 149 "{\"issued_to\": \"1234567890.apps.googleusercontent.com\"," | 148 "{\"issued_to\": \"1234567890.apps.googleusercontent.com\"," |
| 150 "\"audience\": \"1234567890.apps.googleusercontent.com\"," | 149 "\"audience\": \"1234567890.apps.googleusercontent.com\"," |
| 151 "\"scope\": \"https://googleapis.com/oauth2/v2/tokeninfo\"," | 150 "\"scope\": \"https://googleapis.com/oauth2/v2/tokeninfo\"," |
| 152 "\"expires_in\":" + base::IntToString(kTestExpiresIn) + "}"; | 151 "\"expires_in\":" + base::IntToString(kTestExpiresIn) + "}"; |
| 153 } | 152 } |
| 154 | 153 |
| 155 namespace gaia { | 154 namespace gaia { |
| 156 | 155 |
| 157 class GaiaOAuthClientTest : public testing::Test { | 156 class GaiaOAuthClientTest : public testing::Test { |
| 158 public: | 157 protected: |
| 159 GaiaOAuthClientTest() {} | |
| 160 virtual void SetUp() OVERRIDE { | 158 virtual void SetUp() OVERRIDE { |
| 161 client_info_.client_id = "test_client_id"; | 159 client_info_.client_id = "test_client_id"; |
| 162 client_info_.client_secret = "test_client_secret"; | 160 client_info_.client_secret = "test_client_secret"; |
| 163 client_info_.redirect_uri = "test_redirect_uri"; | 161 client_info_.redirect_uri = "test_redirect_uri"; |
| 164 }; | 162 }; |
| 165 | 163 |
| 166 protected: | 164 protected: |
| 167 net::TestURLRequestContextGetter* GetRequestContext() { | 165 net::TestURLRequestContextGetter* GetRequestContext() { |
| 168 if (!request_context_getter_) { | 166 if (!request_context_getter_) { |
| 169 request_context_getter_ = new net::TestURLRequestContextGetter( | 167 request_context_getter_ = new net::TestURLRequestContextGetter( |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 | 323 |
| 326 GaiaOAuthClient auth(GetRequestContext()); | 324 GaiaOAuthClient auth(GetRequestContext()); |
| 327 auth.GetTokenInfo("access_token", 1, &delegate); | 325 auth.GetTokenInfo("access_token", 1, &delegate); |
| 328 | 326 |
| 329 std::string issued_to; | 327 std::string issued_to; |
| 330 ASSERT_TRUE(captured_result->GetString("issued_to", &issued_to)); | 328 ASSERT_TRUE(captured_result->GetString("issued_to", &issued_to)); |
| 331 ASSERT_EQ("1234567890.apps.googleusercontent.com", issued_to); | 329 ASSERT_EQ("1234567890.apps.googleusercontent.com", issued_to); |
| 332 } | 330 } |
| 333 | 331 |
| 334 } // namespace gaia | 332 } // namespace gaia |
| OLD | NEW |