| 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 GaiaAuthFetcher. | 5 // A complete set of unit tests for GaiaAuthFetcher. |
| 6 // Originally ported from GoogleAuthenticator tests. | 6 // Originally ported from GoogleAuthenticator tests. |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
| 11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "google_apis/gaia/gaia_auth_consumer.h" | 14 #include "google_apis/gaia/gaia_auth_consumer.h" |
| 15 #include "google_apis/gaia/gaia_auth_fetcher.h" | 15 #include "google_apis/gaia/gaia_auth_fetcher.h" |
| 16 #include "google_apis/gaia/gaia_urls.h" | 16 #include "google_apis/gaia/gaia_urls.h" |
| 17 #include "google_apis/gaia/google_service_auth_error.h" | 17 #include "google_apis/gaia/google_service_auth_error.h" |
| 18 #include "google_apis/gaia/mock_url_fetcher_factory.h" | 18 #include "google_apis/gaia/mock_url_fetcher_factory.h" |
| 19 #include "google_apis/google_api_keys.h" | 19 #include "google_apis/google_api_keys.h" |
| 20 #include "googleurl/src/gurl.h" | |
| 21 #include "net/base/load_flags.h" | 20 #include "net/base/load_flags.h" |
| 22 #include "net/base/net_errors.h" | 21 #include "net/base/net_errors.h" |
| 23 #include "net/http/http_status_code.h" | 22 #include "net/http/http_status_code.h" |
| 24 #include "net/url_request/test_url_fetcher_factory.h" | 23 #include "net/url_request/test_url_fetcher_factory.h" |
| 25 #include "net/url_request/url_fetcher_delegate.h" | 24 #include "net/url_request/url_fetcher_delegate.h" |
| 26 #include "net/url_request/url_request_status.h" | 25 #include "net/url_request/url_request_status.h" |
| 27 #include "net/url_request/url_request_test_util.h" | 26 #include "net/url_request/url_request_test_util.h" |
| 28 #include "testing/gmock/include/gmock/gmock.h" | 27 #include "testing/gmock/include/gmock/gmock.h" |
| 29 #include "testing/gtest/include/gtest/gtest.h" | 28 #include "testing/gtest/include/gtest/gtest.h" |
| 29 #include "url/gurl.h" |
| 30 | 30 |
| 31 using ::testing::_; | 31 using ::testing::_; |
| 32 using ::testing::Invoke; | 32 using ::testing::Invoke; |
| 33 | 33 |
| 34 namespace { | 34 namespace { |
| 35 static const char kGetAuthCodeValidCookie[] = | 35 static const char kGetAuthCodeValidCookie[] = |
| 36 "oauth_code=test-code; Path=/test; Secure; HttpOnly"; | 36 "oauth_code=test-code; Path=/test; Secure; HttpOnly"; |
| 37 static const char kGetAuthCodeCookieNoSecure[] = | 37 static const char kGetAuthCodeCookieNoSecure[] = |
| 38 "oauth_code=test-code; Path=/test; HttpOnly"; | 38 "oauth_code=test-code; Path=/test; HttpOnly"; |
| 39 static const char kGetAuthCodeCookieNoHttpOnly[] = | 39 static const char kGetAuthCodeCookieNoHttpOnly[] = |
| (...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 795 EXPECT_CALL(consumer, OnClientLoginSuccess(result)) | 795 EXPECT_CALL(consumer, OnClientLoginSuccess(result)) |
| 796 .Times(1); | 796 .Times(1); |
| 797 | 797 |
| 798 GaiaAuthFetcher auth(&consumer, std::string(), GetRequestContext()); | 798 GaiaAuthFetcher auth(&consumer, std::string(), GetRequestContext()); |
| 799 net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0); | 799 net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0); |
| 800 MockFetcher mock_fetcher( | 800 MockFetcher mock_fetcher( |
| 801 oauth_login_gurl_, status, net::HTTP_OK, cookies_, data, | 801 oauth_login_gurl_, status, net::HTTP_OK, cookies_, data, |
| 802 net::URLFetcher::GET, &auth); | 802 net::URLFetcher::GET, &auth); |
| 803 auth.OnURLFetchComplete(&mock_fetcher); | 803 auth.OnURLFetchComplete(&mock_fetcher); |
| 804 } | 804 } |
| OLD | NEW |