From 12e14dbb1ead667d243bd746f1cb2460f8326d47 Mon Sep 17 00:00:00 2001 From: dzhioev Date: Fri, 9 Oct 2015 01:09:02 -0700 Subject: Do not rely on a continue URL when the new GAIA flow is used. When I tried to disable the GAIA extension in Chrome OS, I noticed that this makes several SAML tests to fail. That happens because: a) FakeGAIA is configured to redirect to chrome-extension:///success.html on SAML authentication success. b) The logic that reacts on "success.html" redirect is still enabled in authenticator.js. As it doesn't matter for the new flow which continue URL is used (in fact we don't even pass "continue" to GAIA anymore), I disabled this logic for the new flow. TBR=bartfab@chromium.org BUG=470893 TEST=existing tests Review URL: https://codereview.chromium.org/1361423005 Cr-Commit-Position: refs/heads/master@{#353248} --- .../resources/gaia_auth_host/authenticator.js | 3 ++- google_apis/gaia/fake_gaia.cc | 20 +++++++++++++++++--- google_apis/gaia/fake_gaia.h | 3 +++ 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/chrome/browser/resources/gaia_auth_host/authenticator.js b/chrome/browser/resources/gaia_auth_host/authenticator.js index 9895736..6f7be92 100644 --- a/chrome/browser/resources/gaia_auth_host/authenticator.js +++ b/chrome/browser/resources/gaia_auth_host/authenticator.js @@ -313,7 +313,8 @@ cr.define('cr.login', function() { Authenticator.prototype.onRequestCompleted_ = function(details) { var currentUrl = details.url; - if (currentUrl.lastIndexOf(this.continueUrlWithoutParams_, 0) == 0) { + if (!this.isNewGaiaFlow && + currentUrl.lastIndexOf(this.continueUrlWithoutParams_, 0) == 0) { if (currentUrl.indexOf('ntp=1') >= 0) this.skipForNow_ = true; diff --git a/google_apis/gaia/fake_gaia.cc b/google_apis/gaia/fake_gaia.cc index 699c2c6..60c048b 100644 --- a/google_apis/gaia/fake_gaia.cc +++ b/google_apis/gaia/fake_gaia.cc @@ -66,6 +66,8 @@ const char kAuthHeaderOAuth[] = "OAuth "; const char kListAccountsResponseFormat[] = "[\"gaia.l.a.r\",[[\"gaia.l.a\",1,\"\",\"%s\",\"\",1,1,0,0,1,\"12345\"]]]"; +const char kDummySAMLContinuePath[] = "DummySAMLContinue"; + typedef std::map CookieMap; // Parses cookie name-value map our of |request|. @@ -263,6 +265,10 @@ void FakeGaia::Initialize() { // Handles /SSO GAIA call (not GAIA, made up for SAML tests). REGISTER_PATH_RESPONSE_HANDLER("/SSO", HandleSSO); + REGISTER_RESPONSE_HANDLER( + gaia_urls->gaia_url().Resolve(kDummySAMLContinuePath), + HandleDummySAMLContinue); + // Handles /oauth2/v4/token GAIA call. REGISTER_RESPONSE_HANDLER( gaia_urls->oauth2_token_url(), HandleAuthToken); @@ -580,9 +586,11 @@ void FakeGaia::HandleEmbeddedLookupAccountLookup( GURL url(saml_account_idp_map_[email]); url = net::AppendQueryParameter(url, "SAMLRequest", "fake_request"); - url = net::AppendQueryParameter( - url, "RelayState", - GaiaUrls::GetInstance()->signin_completed_continue_url().spec()); + url = net::AppendQueryParameter(url, "RelayState", + GaiaUrls::GetInstance() + ->gaia_url() + .Resolve(kDummySAMLContinuePath) + .spec()); std::string redirect_url = url.spec(); http_response->AddCustomHeader("Google-Accounts-SAML", "Start"); @@ -628,6 +636,12 @@ void FakeGaia::HandleSSO(const HttpRequest& request, SetOAuthCodeCookie(http_response); } +void FakeGaia::HandleDummySAMLContinue(const HttpRequest& request, + BasicHttpResponse* http_response) { + http_response->set_content(""); + http_response->set_code(net::HTTP_OK); +} + void FakeGaia::HandleAuthToken(const HttpRequest& request, BasicHttpResponse* http_response) { std::string grant_type; diff --git a/google_apis/gaia/fake_gaia.h b/google_apis/gaia/fake_gaia.h index f84e2e7..05c44d5 100644 --- a/google_apis/gaia/fake_gaia.h +++ b/google_apis/gaia/fake_gaia.h @@ -192,6 +192,9 @@ class FakeGaia { net::test_server::BasicHttpResponse* http_response); void HandleSSO(const net::test_server::HttpRequest& request, net::test_server::BasicHttpResponse* http_response); + void HandleDummySAMLContinue( + const net::test_server::HttpRequest& request, + net::test_server::BasicHttpResponse* http_response); void HandleAuthToken(const net::test_server::HttpRequest& request, net::test_server::BasicHttpResponse* http_response); void HandleTokenInfo(const net::test_server::HttpRequest& request, -- cgit v1.1