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

Side by Side Diff: google_apis/gaia/gaia_auth_fetcher_unittest.cc

Issue 973953002: Implement the calls to GAIA for the IDP IFrame protocol. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Roger and Guibin's nits and comments Created 5 years, 9 months 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
« no previous file with comments | « google_apis/gaia/gaia_auth_fetcher.cc ('k') | google_apis/gaia/gaia_urls.h » ('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) 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"
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 MOCK_METHOD2(OnIssueAuthTokenFailure, void(const std::string& service, 182 MOCK_METHOD2(OnIssueAuthTokenFailure, void(const std::string& service,
183 const GoogleServiceAuthError& error)); 183 const GoogleServiceAuthError& error));
184 MOCK_METHOD1(OnClientOAuthFailure, 184 MOCK_METHOD1(OnClientOAuthFailure,
185 void(const GoogleServiceAuthError& error)); 185 void(const GoogleServiceAuthError& error));
186 MOCK_METHOD1(OnMergeSessionFailure, void( 186 MOCK_METHOD1(OnMergeSessionFailure, void(
187 const GoogleServiceAuthError& error)); 187 const GoogleServiceAuthError& error));
188 MOCK_METHOD1(OnUberAuthTokenFailure, void( 188 MOCK_METHOD1(OnUberAuthTokenFailure, void(
189 const GoogleServiceAuthError& error)); 189 const GoogleServiceAuthError& error));
190 MOCK_METHOD1(OnListAccountsSuccess, void(const std::string& data)); 190 MOCK_METHOD1(OnListAccountsSuccess, void(const std::string& data));
191 MOCK_METHOD1(OnGetCheckConnectionInfoSuccess, void(const std::string& data)); 191 MOCK_METHOD1(OnGetCheckConnectionInfoSuccess, void(const std::string& data));
192 MOCK_METHOD1(OnListIdpSessionsSuccess, void(const std::string& data));
193 MOCK_METHOD1(OnGetTokenResponseSuccess,
194 void(const GaiaAuthConsumer::ClientOAuthResult& result));
192 }; 195 };
193 196
194 #if defined(OS_WIN) 197 #if defined(OS_WIN)
195 #define MAYBE_ErrorComparator DISABLED_ErrorComparator 198 #define MAYBE_ErrorComparator DISABLED_ErrorComparator
196 #else 199 #else
197 #define MAYBE_ErrorComparator ErrorComparator 200 #define MAYBE_ErrorComparator ErrorComparator
198 #endif 201 #endif
199 202
200 TEST_F(GaiaAuthFetcherTest, MAYBE_ErrorComparator) { 203 TEST_F(GaiaAuthFetcherTest, MAYBE_ErrorComparator) {
201 GoogleServiceAuthError expected_error = 204 GoogleServiceAuthError expected_error =
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 EXPECT_CALL(consumer, OnGetCheckConnectionInfoSuccess(data)).Times(1); 823 EXPECT_CALL(consumer, OnGetCheckConnectionInfoSuccess(data)).Times(1);
821 824
822 GaiaAuthFetcher auth(&consumer, std::string(), GetRequestContext()); 825 GaiaAuthFetcher auth(&consumer, std::string(), GetRequestContext());
823 net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0); 826 net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0);
824 MockFetcher mock_fetcher( 827 MockFetcher mock_fetcher(
825 GaiaUrls::GetInstance()->GetCheckConnectionInfoURLWithSource( 828 GaiaUrls::GetInstance()->GetCheckConnectionInfoURLWithSource(
826 std::string()), 829 std::string()),
827 status, net::HTTP_OK, cookies_, data, net::URLFetcher::GET, &auth); 830 status, net::HTTP_OK, cookies_, data, net::URLFetcher::GET, &auth);
828 auth.OnURLFetchComplete(&mock_fetcher); 831 auth.OnURLFetchComplete(&mock_fetcher);
829 } 832 }
833
834 TEST_F(GaiaAuthFetcherTest, ListIDPSessions) {
835 std::string data("{\"sessions\":[{\"login_hint\":\"abcdefghijklmnop\"}]}");
836 MockGaiaConsumer consumer;
837 EXPECT_CALL(consumer, OnListIdpSessionsSuccess("abcdefghijklmnop")).Times(1);
838
839 GaiaAuthFetcher auth(&consumer, std::string(), GetRequestContext());
840 auth.StartListIDPSessions(std::string(), std::string());
841
842 net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0);
843 MockFetcher mock_fetcher(
844 GaiaUrls::GetInstance()->oauth2_iframe_url(),
845 status, net::HTTP_OK, cookies_, data, net::URLFetcher::GET, &auth);
846 auth.OnURLFetchComplete(&mock_fetcher);
847 }
848
849 TEST_F(GaiaAuthFetcherTest, GetTokenResponse) {
850 MockGaiaConsumer consumer;
851 EXPECT_CALL(consumer,
852 OnGetTokenResponseSuccess(
853 GaiaAuthConsumer::ClientOAuthResult(std::string(),
854 "at1",
855 3600))).Times(1);
856
857 GaiaAuthFetcher auth(&consumer, std::string(), GetRequestContext());
858 auth.StartGetTokenResponse(std::string(), std::string(), std::string());
859
860 net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0);
861 MockFetcher mock_fetcher(
862 GaiaUrls::GetInstance()->oauth2_iframe_url(),
863 status, net::HTTP_OK, cookies_, kGetTokenPairValidResponse,
864 net::URLFetcher::GET, &auth);
865 auth.OnURLFetchComplete(&mock_fetcher);
866 }
OLDNEW
« no previous file with comments | « google_apis/gaia/gaia_auth_fetcher.cc ('k') | google_apis/gaia/gaia_urls.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698