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

Unified Diff: google_apis/gaia/fake_gaia.cc

Issue 418043002: Add test for showing confirmation dialog for unsecure signin (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix EmbeddedTestServer on windows Created 6 years, 4 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
Index: google_apis/gaia/fake_gaia.cc
diff --git a/google_apis/gaia/fake_gaia.cc b/google_apis/gaia/fake_gaia.cc
index a1c04cb455a8331189e0ffa646bc040b9c91ab5f..e91872802556917d81fb8f17a9b5026fbb7ce533 100644
--- a/google_apis/gaia/fake_gaia.cc
+++ b/google_apis/gaia/fake_gaia.cc
@@ -41,6 +41,18 @@ using namespace net::test_server;
namespace {
+const char kTestAuthSIDCookie[] = "fake-auth-SID-cookie";
+const char kTestAuthLSIDCookie[] = "fake-auth-LSID-cookie";
+const char kTestAuthCode[] = "fake-auth-code";
+const char kTestGaiaUberToken[] = "fake-uber-token";
+const char kTestAuthLoginAccessToken[] = "fake-access-token";
+const char kTestRefreshToken[] = "fake-refresh-token";
+const char kTestSessionSIDCookie[] = "fake-session-SID-cookie";
+const char kTestSessionLSIDCookie[] = "fake-session-LSID-cookie";
+const char kTestOAuthLoginSID[] = "fake-oauth-SID-cookie";
+const char kTestOAuthLoginLSID[] = "fake-oauth-LSID-cookie";
+const char kTestOAuthLoginAuthCode[] = "fake-oauth-auth-code";
+
const base::FilePath::CharType kServiceLogin[] =
FILE_PATH_LITERAL("google_apis/test/service_login.html");
@@ -131,6 +143,20 @@ FakeGaia::FakeGaia() {
FakeGaia::~FakeGaia() {}
+void FakeGaia::SetFakeMergeSessionParamsForEmail(const std::string& email) {
+ FakeGaia::MergeSessionParams params;
+ params.auth_sid_cookie = kTestAuthSIDCookie;
+ params.auth_lsid_cookie = kTestAuthLSIDCookie;
+ params.auth_code = kTestAuthCode;
+ params.refresh_token = kTestRefreshToken;
+ params.access_token = kTestAuthLoginAccessToken;
+ params.gaia_uber_token = kTestGaiaUberToken;
+ params.session_sid_cookie = kTestSessionSIDCookie;
+ params.session_lsid_cookie = kTestSessionLSIDCookie;
+ params.email = email;
+ SetMergeSessionParams(params);
+}
+
void FakeGaia::SetMergeSessionParams(
const MergeSessionParams& params) {
merge_session_params_ = params;
@@ -176,6 +202,10 @@ void FakeGaia::Initialize() {
// Handles /ListAccounts GAIA call.
REGISTER_RESPONSE_HANDLER(
gaia_urls->list_accounts_url(), HandleListAccounts);
+
+ // Handles /GetUserInfo GAIA call.
+ REGISTER_RESPONSE_HANDLER(
+ gaia_urls->get_user_info_url(), HandleGetUserInfo);
}
scoped_ptr<HttpResponse> FakeGaia::HandleRequest(const HttpRequest& request) {
@@ -345,7 +375,7 @@ void FakeGaia::HandleOAuthLogin(const HttpRequest& request,
}
std::string access_token;
- if (!GetAccessToken(request, kAuthHeaderOAuth, &access_token)) {
+ if (!GetAccessToken(request, kAuthHeaderBearer, &access_token)) {
LOG(ERROR) << "/OAuthLogin missing access token in the header";
return;
}
@@ -354,7 +384,8 @@ void FakeGaia::HandleOAuthLogin(const HttpRequest& request,
std::string request_query = request_url.query();
std::string source;
- if (!GetQueryParameter(request_query, "source", &source)) {
+ if (!GetQueryParameter(request_query, "source", &source) &&
+ !GetQueryParameter(request.content, "source", &source)) {
LOG(ERROR) << "Missing 'source' param in /OAuthLogin call";
return;
}
@@ -366,7 +397,10 @@ void FakeGaia::HandleOAuthLogin(const HttpRequest& request,
http_response->set_code(net::HTTP_OK);
// Issue GAIA uber token.
} else {
- LOG(FATAL) << "/OAuthLogin for SID/LSID is not supported";
+ http_response->set_content(base::StringPrintf(
+ "SID=%s\nLSID=%s\nAuth=%s",
+ kTestOAuthLoginSID, kTestOAuthLoginLSID, kTestOAuthLoginAuthCode));
+ http_response->set_code(net::HTTP_OK);
}
}
@@ -394,6 +428,8 @@ void FakeGaia::HandleServiceLoginAuth(const HttpRequest& request,
http_response->set_code(net::HTTP_TEMPORARY_REDIRECT);
http_response->AddCustomHeader("Location", redirect_url);
+ http_response->AddCustomHeader("google-accounts-signin",
+ base::StringPrintf("email=\"%s\", sessionindex=0", email.c_str()));
}
void FakeGaia::HandleSSO(const HttpRequest& request,
@@ -526,8 +562,17 @@ void FakeGaia::HandleIssueToken(const HttpRequest& request,
}
void FakeGaia::HandleListAccounts(const HttpRequest& request,
- BasicHttpResponse* http_response) {
+ BasicHttpResponse* http_response) {
http_response->set_content(base::StringPrintf(
kListAccountsResponseFormat, merge_session_params_.email.c_str()));
http_response->set_code(net::HTTP_OK);
}
+
+void FakeGaia::HandleGetUserInfo(const HttpRequest& request,
+ BasicHttpResponse* http_response) {
+ http_response->set_content(base::StringPrintf(
+ "email=%s\ndisplayEmail=%s",
+ merge_session_params_.email.c_str(),
+ merge_session_params_.email.c_str()));
+ http_response->set_code(net::HTTP_OK);
+}

Powered by Google App Engine
This is Rietveld 408576698