OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 MockGaiaConsumer consumer; | 450 MockGaiaConsumer consumer; |
451 EXPECT_CALL(consumer, OnIssueAuthTokenSuccess("service", "token")) | 451 EXPECT_CALL(consumer, OnIssueAuthTokenSuccess("service", "token")) |
452 .Times(1); | 452 .Times(1); |
453 | 453 |
454 TestingProfile profile; | 454 TestingProfile profile; |
455 TestURLFetcherFactory factory; | 455 TestURLFetcherFactory factory; |
456 URLFetcher::set_factory(&factory); | 456 URLFetcher::set_factory(&factory); |
457 | 457 |
458 GaiaAuthFetcher auth(&consumer, std::string(), | 458 GaiaAuthFetcher auth(&consumer, std::string(), |
459 profile_.GetRequestContext()); | 459 profile_.GetRequestContext()); |
460 auth.StartIssueAuthToken("sid", "lsid", "service"); | 460 |
| 461 // auth.StartIssueAuthToken("sid", "lsid", "service"); |
| 462 GaiaAuthConsumer::ClientLoginResult credentials; |
| 463 credentials.sid = "sid"; |
| 464 credentials.lsid = "lsid"; |
| 465 auth.StartIssueAuthToken(credentials, "service"); |
461 | 466 |
462 URLFetcher::set_factory(NULL); | 467 URLFetcher::set_factory(NULL); |
463 EXPECT_TRUE(auth.HasPendingFetch()); | 468 EXPECT_TRUE(auth.HasPendingFetch()); |
464 auth.OnURLFetchComplete( | 469 auth.OnURLFetchComplete( |
465 NULL, | 470 NULL, |
466 issue_auth_token_source_, | 471 issue_auth_token_source_, |
467 net::URLRequestStatus(net::URLRequestStatus::SUCCESS, 0), | 472 net::URLRequestStatus(net::URLRequestStatus::SUCCESS, 0), |
468 RC_REQUEST_OK, | 473 RC_REQUEST_OK, |
469 cookies_, | 474 cookies_, |
470 "token"); | 475 "token"); |
471 EXPECT_FALSE(auth.HasPendingFetch()); | 476 EXPECT_FALSE(auth.HasPendingFetch()); |
472 } | 477 } |
473 | 478 |
474 TEST_F(GaiaAuthFetcherTest, FullTokenFailure) { | 479 TEST_F(GaiaAuthFetcherTest, FullTokenFailure) { |
475 MockGaiaConsumer consumer; | 480 MockGaiaConsumer consumer; |
476 EXPECT_CALL(consumer, OnIssueAuthTokenFailure("service", _)) | 481 EXPECT_CALL(consumer, OnIssueAuthTokenFailure("service", _)) |
477 .Times(1); | 482 .Times(1); |
478 | 483 |
479 TestingProfile profile; | 484 TestingProfile profile; |
480 TestURLFetcherFactory factory; | 485 TestURLFetcherFactory factory; |
481 URLFetcher::set_factory(&factory); | 486 URLFetcher::set_factory(&factory); |
482 | 487 |
483 GaiaAuthFetcher auth(&consumer, std::string(), | 488 GaiaAuthFetcher auth(&consumer, std::string(), |
484 profile_.GetRequestContext()); | 489 profile_.GetRequestContext()); |
485 auth.StartIssueAuthToken("sid", "lsid", "service"); | 490 // auth.StartIssueAuthToken("sid", "lsid", "service"); |
| 491 GaiaAuthConsumer::ClientLoginResult credentials; |
| 492 credentials.sid = "sid"; |
| 493 credentials.lsid = "lsid"; |
| 494 auth.StartIssueAuthToken(credentials, "service"); |
486 | 495 |
487 URLFetcher::set_factory(NULL); | 496 URLFetcher::set_factory(NULL); |
488 EXPECT_TRUE(auth.HasPendingFetch()); | 497 EXPECT_TRUE(auth.HasPendingFetch()); |
489 auth.OnURLFetchComplete( | 498 auth.OnURLFetchComplete( |
490 NULL, | 499 NULL, |
491 issue_auth_token_source_, | 500 issue_auth_token_source_, |
492 net::URLRequestStatus(net::URLRequestStatus::SUCCESS, 0), | 501 net::URLRequestStatus(net::URLRequestStatus::SUCCESS, 0), |
493 RC_FORBIDDEN, | 502 RC_FORBIDDEN, |
494 cookies_, | 503 cookies_, |
495 ""); | 504 ""); |
496 EXPECT_FALSE(auth.HasPendingFetch()); | 505 EXPECT_FALSE(auth.HasPendingFetch()); |
497 } | 506 } |
OLD | NEW |