Commit 9222e962 authored by Matt Menke's avatar Matt Menke Committed by Commit Bot

Remove SetUpMockAccountReconcilor().

iOS doesn't seem to be using URLFetcher to fetch account information,
so remove iOS code to mock out URLFetcher responses.

Bug: None
Change-Id: I703d71c11decf168541c1181b7836000ef80d129
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1611868
Commit-Queue: Matt Menke <mmenke@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#660858}
parent a8f9c58b
......@@ -20,51 +20,11 @@
#import "ios/public/provider/chrome/browser/chrome_browser_provider.h"
#import "ios/public/provider/chrome/browser/signin/fake_chrome_identity.h"
#import "ios/public/provider/chrome/browser/signin/fake_chrome_identity_service.h"
#include "net/http/http_status_code.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "net/url_request/test_url_fetcher_factory.h"
#include "net/url_request/url_fetcher_delegate.h"
#include "net/url_request/url_request_status.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace {
net::FakeURLFetcherFactory* gFakeURLFetcherFactory = nullptr;
// Specialization of the FakeURLFetcherFactory that will recognize GET requests
// for MergeSession and answer those requests correctly.
class MergeSessionFakeURLFetcherFactory : public net::FakeURLFetcherFactory {
public:
explicit MergeSessionFakeURLFetcherFactory(URLFetcherFactory* default_factory)
: net::FakeURLFetcherFactory(default_factory) {}
std::unique_ptr<net::URLFetcher> CreateURLFetcher(
int id,
const GURL& url,
net::URLFetcher::RequestType request_type,
net::URLFetcherDelegate* d,
net::NetworkTrafficAnnotationTag traffic_annotation) override {
const GURL kMergeSessionURL =
GURL("https://accounts.google.com/MergeSession");
url::Replacements<char> replacements;
replacements.ClearRef();
replacements.ClearQuery();
if (url.ReplaceComponents(replacements) != kMergeSessionURL) {
// URL is not a MergeSession GET. Use the default method.
return net::FakeURLFetcherFactory::CreateURLFetcher(
id, url, request_type, d, traffic_annotation);
}
// Actual MergeSession request. Answer is ignored by the AccountReconcilor,
// so it can also be empty.
return std::unique_ptr<net::FakeURLFetcher>(new net::FakeURLFetcher(
url, d, "", net::HTTP_OK, net::URLRequestStatus::SUCCESS));
}
};
} // namespace
namespace chrome_test_util {
void SetUpMockAuthentication() {
......@@ -85,53 +45,11 @@ void TearDownMockAuthentication() {
}
void SetUpMockAccountReconcilor() {
gFakeURLFetcherFactory =
new MergeSessionFakeURLFetcherFactory(new net::URLFetcherImplFactory());
GaiaAuthFetcherIOS::SetShouldUseGaiaAuthFetcherIOSForTesting(false);
// Answer is URLs in JSON that will be fetched and used in MergeSession that
// we also intercept, so it can be empty.
const GURL kCheckConnectionInfoURL = GURL(base::StringPrintf(
"https://accounts.google.com/GetCheckConnectionInfo?source=%s",
GaiaConstants::kChromeSource));
gFakeURLFetcherFactory->SetFakeResponse(kCheckConnectionInfoURL, "[]",
net::HTTP_OK,
net::URLRequestStatus::SUCCESS);
// No accounts in the cookie jar, will trigger a MergeSession for all of
// them.
const GURL kListAccountsURL = GURL(base::StringPrintf(
"https://accounts.google.com/ListAccounts?source=%s&json=standard",
GaiaConstants::kChromeSource));
gFakeURLFetcherFactory->SetFakeResponse(kListAccountsURL, "[\"\",[]]",
net::HTTP_OK,
net::URLRequestStatus::SUCCESS);
// Ubertoken, which is sent for the MergeSession that we also intercept, so
// it can be any bogus token.
const GURL kUbertokenURL = GURL(base::StringPrintf(
"https://accounts.google.com/OAuthLogin?source=%s&issueuberauth=1",
GaiaConstants::kChromeSource));
gFakeURLFetcherFactory->SetFakeResponse(
kUbertokenURL, "1234-asdf-fake-ubertoken", net::HTTP_OK,
net::URLRequestStatus::SUCCESS);
// MergeSession request is handled by MergeSessionFakeURLFetcherFactory.
// If a profile was previously signed in without chrome identity, a logout
// action is done and will block all other requests until it has been dealt
// with.
const GURL kLogoutURL =
GURL(base::StringPrintf("https://accounts.google.com/Logout?source=%s",
GaiaConstants::kChromeSource));
gFakeURLFetcherFactory->SetFakeResponse(kLogoutURL, "", net::HTTP_OK,
net::URLRequestStatus::SUCCESS);
}
void TearDownMockAccountReconcilor() {
GaiaAuthFetcherIOS::SetShouldUseGaiaAuthFetcherIOSForTesting(true);
delete gFakeURLFetcherFactory;
gFakeURLFetcherFactory = nullptr;
}
bool SignOutAndClearAccounts() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment