diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-08-24 12:15:48 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-08-28 13:30:04 +0000 |
commit | b014812705fc80bff0a5c120dfcef88f349816dc (patch) | |
tree | 25a2e2d9fa285f1add86aa333389a839f81a39ae /chromium/components/signin/core/browser/fake_gaia_cookie_manager_service.cc | |
parent | 9f4560b1027ae06fdb497023cdcaf91b8511fa74 (diff) | |
download | qtwebengine-chromium-b014812705fc80bff0a5c120dfcef88f349816dc.tar.gz |
BASELINE: Update Chromium to 68.0.3440.125
Change-Id: I23f19369e01f688e496f5bf179abb521ad73874f
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/components/signin/core/browser/fake_gaia_cookie_manager_service.cc')
-rw-r--r-- | chromium/components/signin/core/browser/fake_gaia_cookie_manager_service.cc | 99 |
1 files changed, 40 insertions, 59 deletions
diff --git a/chromium/components/signin/core/browser/fake_gaia_cookie_manager_service.cc b/chromium/components/signin/core/browser/fake_gaia_cookie_manager_service.cc index 897b8739b66..ed87b82fb00 100644 --- a/chromium/components/signin/core/browser/fake_gaia_cookie_manager_service.cc +++ b/chromium/components/signin/core/browser/fake_gaia_cookie_manager_service.cc @@ -4,6 +4,7 @@ #include "components/signin/core/browser/fake_gaia_cookie_manager_service.h" +#include "base/strings/string_util.h" #include "base/strings/stringprintf.h" #include "components/signin/core/browser/profile_oauth2_token_service.h" #include "google_apis/gaia/gaia_constants.h" @@ -37,78 +38,58 @@ void FakeGaiaCookieManagerService::SetListAccountsResponseWebLoginRequired() { "Info=WebLoginRequired", net::HTTP_OK, net::URLRequestStatus::SUCCESS); } -void FakeGaiaCookieManagerService::SetListAccountsResponseNoAccounts() { +void FakeGaiaCookieManagerService::SetListAccountsResponseWithParams( + const std::vector<CookieParams>& params) { DCHECK(url_fetcher_factory_); + + std::vector<std::string> response_body; + for (const auto& param : params) { + std::string response_part = base::StringPrintf( + "[\"b\", 0, \"n\", \"%s\", \"p\", 0, 0, 0, 0, %d, \"%s\"", + param.email.c_str(), param.valid ? 1 : 0, param.gaia_id.c_str()); + if (param.signed_out || !param.verified) { + response_part += + base::StringPrintf(", null, null, null, %d, %d", + param.signed_out ? 1 : 0, param.verified ? 1 : 0); + } + response_part += "]"; + response_body.push_back(response_part); + } + url_fetcher_factory_->SetFakeResponse( GaiaUrls::GetInstance()->ListAccountsURLWithSource( GaiaConstants::kChromeSource), - "[\"f\", []]", net::HTTP_OK, net::URLRequestStatus::SUCCESS); + std::string("[\"f\", [") + base::JoinString(response_body, ", ") + "]]", + net::HTTP_OK, net::URLRequestStatus::SUCCESS); +} + +void FakeGaiaCookieManagerService::SetListAccountsResponseNoAccounts() { + SetListAccountsResponseWithParams({}); } void FakeGaiaCookieManagerService::SetListAccountsResponseOneAccount( - const char* email, - const char* gaia_id) { - DCHECK(url_fetcher_factory_); - url_fetcher_factory_->SetFakeResponse( - GaiaUrls::GetInstance()->ListAccountsURLWithSource( - GaiaConstants::kChromeSource), - base::StringPrintf( - "[\"f\", [[\"b\", 0, \"n\", \"%s\", \"p\", 0, 0, 0, 0, 1, \"%s\"]]]", - email, gaia_id), - net::HTTP_OK, net::URLRequestStatus::SUCCESS); + const std::string& email, + const std::string& gaia_id) { + CookieParams params = {email, gaia_id, true /* valid */, + false /* signed_out */, true /* verified */}; + SetListAccountsResponseWithParams({params}); } void FakeGaiaCookieManagerService::SetListAccountsResponseOneAccountWithParams( - const char* email, - const char* gaia_id, - bool is_email_valid, - bool signed_out, - bool verified) { - DCHECK(url_fetcher_factory_); - url_fetcher_factory_->SetFakeResponse( - GaiaUrls::GetInstance()->ListAccountsURLWithSource( - GaiaConstants::kChromeSource), - base::StringPrintf( - "[\"f\", [[\"b\", 0, \"n\", \"%s\", \"p\", 0, 0, 0, 0, %d, \"%s\", " - "null, null, null, %d, %d]]]", - email, is_email_valid ? 1 : 0, gaia_id, signed_out ? 1 : 0, - verified ? 1 : 0), - net::HTTP_OK, net::URLRequestStatus::SUCCESS); + const CookieParams& params) { + SetListAccountsResponseWithParams({params}); } void FakeGaiaCookieManagerService::SetListAccountsResponseTwoAccounts( - const char* email1, - const char* gaia_id1, - const char* email2, - const char* gaia_id2) { - DCHECK(url_fetcher_factory_); - url_fetcher_factory_->SetFakeResponse( - GaiaUrls::GetInstance()->ListAccountsURLWithSource( - GaiaConstants::kChromeSource), - base::StringPrintf( - "[\"f\", [[\"b\", 0, \"n\", \"%s\", \"p\", 0, 0, 0, 0, 1, \"%s\"], " - "[\"b\", 0, \"n\", \"%s\", \"p\", 0, 0, 0, 0, 1, \"%s\"]]]", - email1, gaia_id1, email2, gaia_id2), - net::HTTP_OK, net::URLRequestStatus::SUCCESS); -} - -void FakeGaiaCookieManagerService::SetListAccountsResponseTwoAccountsWithExpiry( - const char* email1, - const char* gaia_id1, - bool account1_expired, - const char* email2, - const char* gaia_id2, - bool account2_expired) { - DCHECK(url_fetcher_factory_); - url_fetcher_factory_->SetFakeResponse( - GaiaUrls::GetInstance()->ListAccountsURLWithSource( - GaiaConstants::kChromeSource), - base::StringPrintf( - "[\"f\", [[\"b\", 0, \"n\", \"%s\", \"p\", 0, 0, 0, 0, %d, \"%s\"], " - "[\"b\", 0, \"n\", \"%s\", \"p\", 0, 0, 0, 0, %d, \"%s\"]]]", - email1, account1_expired ? 0 : 1, gaia_id1, email2, - account2_expired ? 0 : 1, gaia_id2), - net::HTTP_OK, net::URLRequestStatus::SUCCESS); + const std::string& email1, + const std::string& gaia_id1, + const std::string& email2, + const std::string& gaia_id2) { + SetListAccountsResponseWithParams( + {{email1, gaia_id1, true /* valid */, false /* signed_out */, + true /* verified */}, + {email2, gaia_id2, true /* valid */, false /* signed_out */, + true /* verified */}}); } std::string FakeGaiaCookieManagerService::GetSourceForRequest( |