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

Unified Diff: components/autofill/content/browser/wallet/wallet_signin_helper_unittest.cc

Issue 16858016: Respect the new Online Wallet sign-in response. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addresses Dan's comments. Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/autofill/content/browser/wallet/wallet_signin_helper.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/autofill/content/browser/wallet/wallet_signin_helper_unittest.cc
diff --git a/components/autofill/content/browser/wallet/wallet_signin_helper_unittest.cc b/components/autofill/content/browser/wallet/wallet_signin_helper_unittest.cc
index c768151d3d609f7892f6bf893813fbb3571b0cd3..942fba1bdfa20a351be58e84a87fe09d7df11cac 100644
--- a/components/autofill/content/browser/wallet/wallet_signin_helper_unittest.cc
+++ b/components/autofill/content/browser/wallet/wallet_signin_helper_unittest.cc
@@ -14,6 +14,7 @@
#include "google_apis/gaia/gaia_constants.h"
#include "google_apis/gaia/gaia_urls.h"
#include "google_apis/gaia/google_service_auth_error.h"
+#include "net/http/http_status_code.h"
#include "net/url_request/test_url_fetcher_factory.h"
#include "net/url_request/url_request.h"
#include "net/url_request/url_request_context_getter.h"
@@ -113,7 +114,7 @@ class WalletSigninHelperTest : public testing::Test {
void MockSuccessfulOAuthLoginResponse() {
SetUpFetcherResponseAndCompleteRequest(
- GaiaUrls::GetInstance()->client_login_url(), 200,
+ GaiaUrls::GetInstance()->client_login_url(), net::HTTP_OK,
net::ResponseCookies(),
"SID=sid\nLSID=lsid\nAuth=auth");
}
@@ -121,14 +122,14 @@ class WalletSigninHelperTest : public testing::Test {
void MockFailedOAuthLoginResponse404() {
SetUpFetcherResponseAndCompleteRequest(
GaiaUrls::GetInstance()->client_login_url(),
- 404,
+ net::HTTP_NOT_FOUND,
net::ResponseCookies(),
std::string());
}
void MockSuccessfulGaiaUserInfoResponse(const std::string& username) {
SetUpFetcherResponseAndCompleteRequest(
- GaiaUrls::GetInstance()->get_user_info_url(), 200,
+ GaiaUrls::GetInstance()->get_user_info_url(), net::HTTP_OK,
net::ResponseCookies(),
"email=" + username);
}
@@ -136,14 +137,14 @@ class WalletSigninHelperTest : public testing::Test {
void MockFailedGaiaUserInfoResponse404() {
SetUpFetcherResponseAndCompleteRequest(
GaiaUrls::GetInstance()->get_user_info_url(),
- 404,
+ net::HTTP_NOT_FOUND,
net::ResponseCookies(),
std::string());
}
void MockSuccessfulGetAccountInfoResponse(const std::string& username) {
SetUpFetcherResponseAndCompleteRequest(
- signin_helper_->GetGetAccountInfoUrlForTesting(), 200,
+ signin_helper_->GetGetAccountInfoUrlForTesting(), net::HTTP_OK,
net::ResponseCookies(),
base::StringPrintf(
kGetAccountInfoValidResponseFormat,
@@ -153,21 +154,28 @@ class WalletSigninHelperTest : public testing::Test {
void MockFailedGetAccountInfoResponse404() {
SetUpFetcherResponseAndCompleteRequest(
signin_helper_->GetGetAccountInfoUrlForTesting(),
- 404,
+ net::HTTP_NOT_FOUND,
net::ResponseCookies(),
std::string());
}
- void MockSuccessfulPassiveAuthUrlMergeAndRedirectResponse() {
+ void MockSuccessfulPassiveSignInResponse() {
SetUpFetcherResponseAndCompleteRequest(wallet::GetPassiveAuthUrl().spec(),
- 200,
+ net::HTTP_OK,
net::ResponseCookies(),
- std::string());
+ "YES");
+ }
+
+ void MockFailedPassiveSignInResponseNo() {
+ SetUpFetcherResponseAndCompleteRequest(wallet::GetPassiveAuthUrl().spec(),
+ net::HTTP_OK,
+ net::ResponseCookies(),
+ "NOOOOOOOOOOOOOOO");
}
- void MockFailedPassiveAuthUrlMergeAndRedirectResponse404() {
+ void MockFailedPassiveSignInResponse404() {
SetUpFetcherResponseAndCompleteRequest(wallet::GetPassiveAuthUrl().spec(),
- 404,
+ net::HTTP_NOT_FOUND,
net::ResponseCookies(),
std::string());
}
@@ -189,20 +197,26 @@ class WalletSigninHelperTest : public testing::Test {
TEST_F(WalletSigninHelperTest, PassiveSigninSuccessful) {
EXPECT_CALL(mock_delegate_, OnPassiveSigninSuccess("user@gmail.com"));
signin_helper_->StartPassiveSignin();
- MockSuccessfulPassiveAuthUrlMergeAndRedirectResponse();
+ MockSuccessfulPassiveSignInResponse();
MockSuccessfulGetAccountInfoResponse("user@gmail.com");
}
-TEST_F(WalletSigninHelperTest, PassiveSigninFailedSignin) {
+TEST_F(WalletSigninHelperTest, PassiveSigninFailedSignin404) {
EXPECT_CALL(mock_delegate_, OnPassiveSigninFailure(_));
signin_helper_->StartPassiveSignin();
- MockFailedPassiveAuthUrlMergeAndRedirectResponse404();
+ MockFailedPassiveSignInResponse404();
+}
+
+TEST_F(WalletSigninHelperTest, PassiveSigninFailedSigninNo) {
+ EXPECT_CALL(mock_delegate_, OnPassiveSigninFailure(_));
+ signin_helper_->StartPassiveSignin();
+ MockFailedPassiveSignInResponseNo();
}
TEST_F(WalletSigninHelperTest, PassiveSigninFailedUserInfo) {
EXPECT_CALL(mock_delegate_, OnPassiveSigninFailure(_));
signin_helper_->StartPassiveSignin();
- MockSuccessfulPassiveAuthUrlMergeAndRedirectResponse();
+ MockSuccessfulPassiveSignInResponse();
MockFailedGetAccountInfoResponse404();
}
@@ -223,7 +237,7 @@ TEST_F(WalletSigninHelperTest, AutomaticSigninSuccessful) {
signin_helper_->StartAutomaticSignin("123SID", "123LSID");
MockSuccessfulGaiaUserInfoResponse("user@gmail.com");
MockSuccessfulOAuthLoginResponse();
- MockSuccessfulPassiveAuthUrlMergeAndRedirectResponse();
+ MockSuccessfulPassiveSignInResponse();
}
TEST_F(WalletSigninHelperTest, AutomaticSigninFailedGetUserInfo) {
@@ -239,12 +253,20 @@ TEST_F(WalletSigninHelperTest, AutomaticSigninFailedOAuthLogin) {
MockFailedOAuthLoginResponse404();
}
-TEST_F(WalletSigninHelperTest, AutomaticSigninFailedSignin) {
+TEST_F(WalletSigninHelperTest, AutomaticSigninFailedSignin404) {
+ EXPECT_CALL(mock_delegate_, OnAutomaticSigninFailure(_));
+ signin_helper_->StartAutomaticSignin("123SID", "123LSID");
+ MockSuccessfulGaiaUserInfoResponse("user@gmail.com");
+ MockSuccessfulOAuthLoginResponse();
+ MockFailedPassiveSignInResponse404();
+}
+
+TEST_F(WalletSigninHelperTest, AutomaticSigninFailedSigninNo) {
EXPECT_CALL(mock_delegate_, OnAutomaticSigninFailure(_));
signin_helper_->StartAutomaticSignin("123SID", "123LSID");
MockSuccessfulGaiaUserInfoResponse("user@gmail.com");
MockSuccessfulOAuthLoginResponse();
- MockFailedPassiveAuthUrlMergeAndRedirectResponse404();
+ MockFailedPassiveSignInResponseNo();
}
// TODO(aruslan): http://crbug.com/188317 Need more tests.
« no previous file with comments | « components/autofill/content/browser/wallet/wallet_signin_helper.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698