summaryrefslogtreecommitdiffstats
path: root/remoting
diff options
context:
space:
mode:
authorrsimha@chromium.org <rsimha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-06 18:36:32 +0000
committerrsimha@chromium.org <rsimha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-06 18:36:32 +0000
commit911a0bc8f2dea094d6d9be4dbf236e90db720cd5 (patch)
tree4eb4b0eb75019eccf92c6eac1658310fc229dda7 /remoting
parent45ba64ab757f1eb681d9b285330634b4bc437747 (diff)
downloadchromium_src-911a0bc8f2dea094d6d9be4dbf236e90db720cd5.zip
chromium_src-911a0bc8f2dea094d6d9be4dbf236e90db720cd5.tar.gz
chromium_src-911a0bc8f2dea094d6d9be4dbf236e90db720cd5.tar.bz2
[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
Diffstat (limited to 'remoting')
-rw-r--r--remoting/host/token_validator_factory_impl_unittest.cc19
1 files changed, 12 insertions, 7 deletions
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,