From 911a0bc8f2dea094d6d9be4dbf236e90db720cd5 Mon Sep 17 00:00:00 2001 From: "rsimha@chromium.org" Date: Wed, 6 Nov 2013 18:36:32 +0000 Subject: [sync] Allow FakeURLFetcher to return an arbitrary URLRequestStatus In r232724, FakeURLFetcher went from being able to return only HTTP/200 or HTTP/500, to being able to return any arbitrary HttpResponseCode. However, the URLRequestStatus returned was hard coded to FAILURE for HTTP/5xx and SUCCESS for all other codes. This patch further modifies FakeURLFetcher to be able to return arbitrary URLRequestStatus values in addition to an HttpResponseCode. We no longer hard code the URLRequestStatus based on the HttpResponseCode being returned. It also updates all call sites that currently use FakeURLFetcher. R=achuith@chromium.org, ajwong@chromium.org, akalin@chromium.org, mattm@chromium.org, mmenke@chromium.org, nyquist@chromium.org, sky@chromium.org, tim@chromium.org, vitalybuka@chromium.org TBR=bengr, sergeyu BUG=313905 TEST=All existing tests pass trybots and waterfall Review URL: https://codereview.chromium.org/60923002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@233304 0039d316-1c4b-4281-b951-d872f2087c98 --- .../host/token_validator_factory_impl_unittest.cc | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'remoting') diff --git a/remoting/host/token_validator_factory_impl_unittest.cc b/remoting/host/token_validator_factory_impl_unittest.cc index 1eb14f7..8737917 100644 --- a/remoting/host/token_validator_factory_impl_unittest.cc +++ b/remoting/host/token_validator_factory_impl_unittest.cc @@ -10,6 +10,7 @@ #include "base/values.h" #include "net/http/http_status_code.h" #include "net/url_request/test_url_fetcher_factory.h" +#include "net/url_request/url_request_status.h" #include "net/url_request/url_request_test_util.h" #include "remoting/base/rsa_key_pair.h" #include "remoting/base/test_rsa_key_pair.h" @@ -94,8 +95,10 @@ TEST_F(TokenValidatorFactoryImplTest, Success) { net::FakeURLFetcherFactory factory(NULL); token_validator_ = token_validator_factory_->CreateTokenValidator( kLocalJid, kRemoteJid); - factory.SetFakeResponse(GURL(kTokenValidationUrl), CreateResponse( - token_validator_->token_scope()), net::HTTP_OK); + factory.SetFakeResponse( + GURL(kTokenValidationUrl), + CreateResponse(token_validator_->token_scope()), + net::HTTP_OK, net::URLRequestStatus::SUCCESS); token_validator_->ValidateThirdPartyToken( kToken, base::Bind(&TokenValidatorFactoryImplTest::SuccessCallback, base::Unretained(this))); @@ -106,9 +109,9 @@ TEST_F(TokenValidatorFactoryImplTest, BadToken) { net::FakeURLFetcherFactory factory(NULL); token_validator_ = token_validator_factory_->CreateTokenValidator( kLocalJid, kRemoteJid); - factory.SetFakeResponse(GURL(kTokenValidationUrl), - std::string(), - net::HTTP_INTERNAL_SERVER_ERROR); + factory.SetFakeResponse(GURL(kTokenValidationUrl), std::string(), + net::HTTP_INTERNAL_SERVER_ERROR, + net::URLRequestStatus::FAILED); token_validator_->ValidateThirdPartyToken( kToken, base::Bind(&TokenValidatorFactoryImplTest::FailureCallback, base::Unretained(this))); @@ -120,7 +123,8 @@ TEST_F(TokenValidatorFactoryImplTest, BadScope) { token_validator_ = token_validator_factory_->CreateTokenValidator( kLocalJid, kRemoteJid); factory.SetFakeResponse( - GURL(kTokenValidationUrl), CreateResponse(kBadScope), net::HTTP_OK); + GURL(kTokenValidationUrl), CreateResponse(kBadScope), net::HTTP_OK, + net::URLRequestStatus::SUCCESS); token_validator_->ValidateThirdPartyToken( kToken, base::Bind(&TokenValidatorFactoryImplTest::FailureCallback, base::Unretained(this))); @@ -133,7 +137,8 @@ TEST_F(TokenValidatorFactoryImplTest, DeleteOnFailure) { kLocalJid, kRemoteJid); factory.SetFakeResponse(GURL(kTokenValidationUrl), std::string(), - net::HTTP_INTERNAL_SERVER_ERROR); + net::HTTP_INTERNAL_SERVER_ERROR, + net::URLRequestStatus::FAILED); token_validator_->ValidateThirdPartyToken( kToken, base::Bind( &TokenValidatorFactoryImplTest::DeleteOnFailureCallback, -- cgit v1.1