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

Side by Side Diff: chrome/common/net/gaia/gaia_auth_fetcher_unittest.cc

Issue 5309007: [ChromeOS] Make GaiaAutheFetcher parsing logic default to service_unavailable (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 10 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 auth.OnURLFetchComplete(NULL, 150 auth.OnURLFetchComplete(NULL,
151 issue_auth_token_source_, 151 issue_auth_token_source_,
152 status, 152 status,
153 0, 153 0,
154 cookies_, 154 cookies_,
155 std::string()); 155 std::string());
156 } 156 }
157 157
158 158
159 TEST_F(GaiaAuthFetcherTest, LoginDenied) { 159 TEST_F(GaiaAuthFetcherTest, LoginDenied) {
160 std::string data("Error: NO!"); 160 std::string data("Error=BadAuthentication");
161 URLRequestStatus status(URLRequestStatus::SUCCESS, 0); 161 URLRequestStatus status(URLRequestStatus::SUCCESS, 0);
162 162
163 GoogleServiceAuthError expected_error( 163 GoogleServiceAuthError expected_error(
164 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); 164 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS);
165 165
166 MockGaiaConsumer consumer; 166 MockGaiaConsumer consumer;
167 EXPECT_CALL(consumer, OnClientLoginFailure(expected_error)) 167 EXPECT_CALL(consumer, OnClientLoginFailure(expected_error))
168 .Times(1); 168 .Times(1);
169 169
170 GaiaAuthFetcher auth(&consumer, std::string(), 170 GaiaAuthFetcher auth(&consumer, std::string(),
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 } 305 }
306 306
307 TEST_F(GaiaAuthFetcherTest, AccountDisabledError) { 307 TEST_F(GaiaAuthFetcherTest, AccountDisabledError) {
308 URLRequestStatus status(URLRequestStatus::SUCCESS, 0); 308 URLRequestStatus status(URLRequestStatus::SUCCESS, 0);
309 std::string data = "Error=AccountDisabled\n"; 309 std::string data = "Error=AccountDisabled\n";
310 GoogleServiceAuthError error = 310 GoogleServiceAuthError error =
311 GaiaAuthFetcher::GenerateAuthError(data, status); 311 GaiaAuthFetcher::GenerateAuthError(data, status);
312 EXPECT_EQ(error.state(), GoogleServiceAuthError::ACCOUNT_DISABLED); 312 EXPECT_EQ(error.state(), GoogleServiceAuthError::ACCOUNT_DISABLED);
313 } 313 }
314 314
315 TEST_F(GaiaAuthFetcherTest,BadAuthenticationError) {
316 URLRequestStatus status(URLRequestStatus::SUCCESS, 0);
317 std::string data = "Error=BadAuthentication\n";
318 GoogleServiceAuthError error =
319 GaiaAuthFetcher::GenerateAuthError(data, status);
320 EXPECT_EQ(error.state(), GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS);
321 }
322
323 TEST_F(GaiaAuthFetcherTest,IncomprehensibleError) {
324 URLRequestStatus status(URLRequestStatus::SUCCESS, 0);
325 std::string data = "Error=Gobbledygook\n";
326 GoogleServiceAuthError error =
327 GaiaAuthFetcher::GenerateAuthError(data, status);
328 EXPECT_EQ(error.state(), GoogleServiceAuthError::SERVICE_UNAVAILABLE);
329 }
330
315 TEST_F(GaiaAuthFetcherTest,ServiceUnavailableError) { 331 TEST_F(GaiaAuthFetcherTest,ServiceUnavailableError) {
316 URLRequestStatus status(URLRequestStatus::SUCCESS, 0); 332 URLRequestStatus status(URLRequestStatus::SUCCESS, 0);
317 std::string data = "Error=ServiceUnavailable\n"; 333 std::string data = "Error=ServiceUnavailable\n";
318 GoogleServiceAuthError error = 334 GoogleServiceAuthError error =
319 GaiaAuthFetcher::GenerateAuthError(data, status); 335 GaiaAuthFetcher::GenerateAuthError(data, status);
320 EXPECT_EQ(error.state(), GoogleServiceAuthError::SERVICE_UNAVAILABLE); 336 EXPECT_EQ(error.state(), GoogleServiceAuthError::SERVICE_UNAVAILABLE);
321 } 337 }
322 338
323 TEST_F(GaiaAuthFetcherTest, FullLogin) { 339 TEST_F(GaiaAuthFetcherTest, FullLogin) {
324 MockGaiaConsumer consumer; 340 MockGaiaConsumer consumer;
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 URLFetcher::set_factory(NULL); 450 URLFetcher::set_factory(NULL);
435 EXPECT_TRUE(auth.HasPendingFetch()); 451 EXPECT_TRUE(auth.HasPendingFetch());
436 auth.OnURLFetchComplete(NULL, 452 auth.OnURLFetchComplete(NULL,
437 issue_auth_token_source_, 453 issue_auth_token_source_,
438 URLRequestStatus(URLRequestStatus::SUCCESS, 0), 454 URLRequestStatus(URLRequestStatus::SUCCESS, 0),
439 RC_FORBIDDEN, 455 RC_FORBIDDEN,
440 cookies_, 456 cookies_,
441 ""); 457 "");
442 EXPECT_FALSE(auth.HasPendingFetch()); 458 EXPECT_FALSE(auth.HasPendingFetch());
443 } 459 }
OLDNEW
« chrome/common/net/gaia/gaia_auth_fetcher.cc ('K') | « chrome/common/net/gaia/gaia_auth_fetcher.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698