summaryrefslogtreecommitdiffstats
path: root/components/autofill/browser/wallet
diff options
context:
space:
mode:
authorahutter@chromium.org <ahutter@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-12 00:41:42 +0000
committerahutter@chromium.org <ahutter@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-12 00:41:42 +0000
commit4d91b01212f22563331a4d196a40e920aad49910 (patch)
treefce937bb29061b5b270a3b36ae0a8e623f6c27ea /components/autofill/browser/wallet
parent8447337c06f81659d793fc2e096ec72cd4eb1f01 (diff)
downloadchromium_src-4d91b01212f22563331a4d196a40e920aad49910.zip
chromium_src-4d91b01212f22563331a4d196a40e920aad49910.tar.gz
chromium_src-4d91b01212f22563331a4d196a40e920aad49910.tar.bz2
Adding risk capabilites to GetFullWallet and GetWalletItems
BUG=181087 Review URL: https://chromiumcodereview.appspot.com/12674002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@187429 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components/autofill/browser/wallet')
-rw-r--r--components/autofill/browser/wallet/wallet_client.cc99
-rw-r--r--components/autofill/browser/wallet/wallet_client.h69
-rw-r--r--components/autofill/browser/wallet/wallet_client_unittest.cc197
3 files changed, 275 insertions, 90 deletions
diff --git a/components/autofill/browser/wallet/wallet_client.cc b/components/autofill/browser/wallet/wallet_client.cc
index fbf17af..1548674 100644
--- a/components/autofill/browser/wallet/wallet_client.cc
+++ b/components/autofill/browser/wallet/wallet_client.cc
@@ -10,7 +10,6 @@
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/string_util.h"
-#include "components/autofill/browser/wallet/cart.h"
#include "components/autofill/browser/wallet/instrument.h"
#include "components/autofill/browser/wallet/wallet_address.h"
#include "components/autofill/browser/wallet/wallet_client_observer.h"
@@ -18,7 +17,6 @@
#include "components/autofill/browser/wallet/wallet_service_url.h"
#include "crypto/random.h"
#include "google_apis/google_api_keys.h"
-#include "googleurl/src/gurl.h"
#include "net/http/http_status_code.h"
#include "net/url_request/url_fetcher.h"
#include "net/url_request/url_request_context_getter.h"
@@ -59,12 +57,24 @@ std::string DialogTypeToFeatureString(autofill::DialogType dialog_type) {
return "NOT_POSSIBLE";
}
+std::string RiskCapabilityToString(
+ WalletClient::RiskCapability risk_capability) {
+ switch (risk_capability) {
+ case WalletClient::RELOGIN:
+ return "RELOGIN";
+ case WalletClient::VERIFY_CVC:
+ return "VERIFY_CVC";
+ }
+ NOTREACHED();
+ return "NOT_POSSIBLE";
+}
+
// Gets and parses required actions from a SaveToWallet response. Returns
// false if any unknown required actions are seen and true otherwise.
void GetRequiredActionsForSaveToWallet(
const base::DictionaryValue& dict,
std::vector<RequiredAction>* required_actions) {
- const ListValue* required_action_list;
+ const base::ListValue* required_action_list;
if (!dict.GetList("required_action", &required_action_list))
return;
@@ -97,6 +107,7 @@ const char kInstrumentEscrowHandleKey[] = "instrument_escrow_handle";
const char kInstrumentPhoneNumberKey[] = "instrument_phone_number";
const char kMerchantDomainKey[] = "merchant_domain";
const char kReasonKey[] = "reason";
+const char kRiskCapabilitiesKey[] = "supported_risk_challenge";
const char kRiskParamsKey[] = "risk_params";
const char kSelectedAddressIdKey[] = "selected_address_id";
const char kSelectedInstrumentIdKey[] = "selected_instrument_id";
@@ -109,6 +120,23 @@ const char kUpgradedInstrumentIdKey[] = "upgraded_instrument_id";
} // namespace
+WalletClient::FullWalletRequest::FullWalletRequest(
+ const std::string& instrument_id,
+ const std::string& address_id,
+ const GURL& source_url,
+ const Cart& cart,
+ const std::string& google_transaction_id,
+ autofill::DialogType dialog_type,
+ const std::vector<RiskCapability> risk_capabilities)
+ : instrument_id(instrument_id),
+ address_id(address_id),
+ source_url(source_url),
+ cart(cart),
+ google_transaction_id(google_transaction_id),
+ dialog_type(dialog_type),
+ risk_capabilities(risk_capabilities) {}
+
+WalletClient::FullWalletRequest::~FullWalletRequest() {}
WalletClient::WalletClient(net::URLRequestContextGetter* context_getter,
WalletClientObserver* observer)
@@ -145,13 +173,13 @@ void WalletClient::AcceptLegalDocuments(
request_dict.SetString(kGoogleTransactionIdKey, google_transaction_id);
request_dict.SetString(kMerchantDomainKey,
source_url.GetWithEmptyPath().spec());
- ListValue* docs_list = new ListValue();
+ scoped_ptr<base::ListValue> docs_list(new base::ListValue());
for (std::vector<std::string>::const_iterator it = document_ids.begin();
it != document_ids.end();
++it) {
docs_list->AppendString(*it);
}
- request_dict.Set(kAcceptedLegalDocumentKey, docs_list);
+ request_dict.Set(kAcceptedLegalDocumentKey, docs_list.release());
std::string post_body;
base::JSONWriter::Write(&request_dict, &post_body);
@@ -184,21 +212,11 @@ void WalletClient::AuthenticateInstrument(
card_verification_number, obfuscated_gaia_id);
}
-void WalletClient::GetFullWallet(const std::string& instrument_id,
- const std::string& address_id,
- const GURL& source_url,
- const Cart& cart,
- const std::string& google_transaction_id,
- autofill::DialogType dialog_type) {
+void WalletClient::GetFullWallet(const FullWalletRequest& full_wallet_request) {
if (HasRequestInProgress()) {
pending_requests_.push(base::Bind(&WalletClient::GetFullWallet,
base::Unretained(this),
- instrument_id,
- address_id,
- source_url,
- cart,
- google_transaction_id,
- dialog_type));
+ full_wallet_request));
return;
}
@@ -208,25 +226,43 @@ void WalletClient::GetFullWallet(const std::string& instrument_id,
pending_request_body_.SetString(kApiKeyKey, google_apis::GetAPIKey());
pending_request_body_.SetString(kRiskParamsKey, GetRiskParams());
- pending_request_body_.SetString(kSelectedInstrumentIdKey, instrument_id);
- pending_request_body_.SetString(kSelectedAddressIdKey, address_id);
- pending_request_body_.SetString(kMerchantDomainKey,
- source_url.GetWithEmptyPath().spec());
+ pending_request_body_.SetString(kSelectedInstrumentIdKey,
+ full_wallet_request.instrument_id);
+ pending_request_body_.SetString(kSelectedAddressIdKey,
+ full_wallet_request.address_id);
+ pending_request_body_.SetString(
+ kMerchantDomainKey,
+ full_wallet_request.source_url.GetWithEmptyPath().spec());
pending_request_body_.SetString(kGoogleTransactionIdKey,
- google_transaction_id);
- pending_request_body_.Set(kCartKey, cart.ToDictionary().release());
- pending_request_body_.SetString(kFeatureKey,
- DialogTypeToFeatureString(dialog_type));
+ full_wallet_request.google_transaction_id);
+ pending_request_body_.Set(kCartKey,
+ full_wallet_request.cart.ToDictionary().release());
+ pending_request_body_.SetString(
+ kFeatureKey,
+ DialogTypeToFeatureString(full_wallet_request.dialog_type));
+
+ scoped_ptr<base::ListValue> risk_capabilities_list(new base::ListValue());
+ for (std::vector<RiskCapability>::const_iterator it =
+ full_wallet_request.risk_capabilities.begin();
+ it != full_wallet_request.risk_capabilities.end();
+ ++it) {
+ risk_capabilities_list->AppendString(RiskCapabilityToString(*it));
+ }
+ pending_request_body_.Set(kRiskCapabilitiesKey,
+ risk_capabilities_list.release());
crypto::RandBytes(&(one_time_pad_[0]), one_time_pad_.size());
encryption_escrow_client_.EncryptOneTimePad(one_time_pad_);
}
-void WalletClient::GetWalletItems(const GURL& source_url) {
+void WalletClient::GetWalletItems(
+ const GURL& source_url,
+ const std::vector<RiskCapability>& risk_capabilities) {
if (HasRequestInProgress()) {
pending_requests_.push(base::Bind(&WalletClient::GetWalletItems,
base::Unretained(this),
- source_url));
+ source_url,
+ risk_capabilities));
return;
}
@@ -239,6 +275,15 @@ void WalletClient::GetWalletItems(const GURL& source_url) {
request_dict.SetString(kMerchantDomainKey,
source_url.GetWithEmptyPath().spec());
+ scoped_ptr<base::ListValue> risk_capabilities_list(new base::ListValue());
+ for (std::vector<RiskCapability>::const_iterator it =
+ risk_capabilities.begin();
+ it != risk_capabilities.end();
+ ++it) {
+ risk_capabilities_list->AppendString(RiskCapabilityToString(*it));
+ }
+ request_dict.Set(kRiskCapabilitiesKey, risk_capabilities_list.release());
+
std::string post_body;
base::JSONWriter::Write(&request_dict, &post_body);
diff --git a/components/autofill/browser/wallet/wallet_client.h b/components/autofill/browser/wallet/wallet_client.h
index 009dc90..c008cb8 100644
--- a/components/autofill/browser/wallet/wallet_client.h
+++ b/components/autofill/browser/wallet/wallet_client.h
@@ -13,15 +13,15 @@
#include "base/memory/ref_counted.h"
#include "base/values.h"
#include "components/autofill/browser/autofill_manager_delegate.h"
+#include "components/autofill/browser/wallet/cart.h"
#include "components/autofill/browser/wallet/encryption_escrow_client.h"
#include "components/autofill/browser/wallet/encryption_escrow_client_observer.h"
#include "components/autofill/browser/wallet/full_wallet.h"
#include "components/autofill/common/autocheckout_status.h"
+#include "googleurl/src/gurl.h"
#include "net/url_request/url_fetcher_delegate.h"
#include "testing/gtest/include/gtest/gtest_prod.h"
-class GURL;
-
namespace net {
class URLFetcher;
class URLRequestContextGetter;
@@ -31,7 +31,6 @@ namespace autofill {
namespace wallet {
class Address;
-class Cart;
class FullWallet;
class Instrument;
class WalletClientObserver;
@@ -68,6 +67,50 @@ class WalletClient
: public net::URLFetcherDelegate,
public EncryptionEscrowClientObserver {
public:
+ // The Risk challenges supported by users of WalletClient.
+ enum RiskCapability {
+ RELOGIN,
+ VERIFY_CVC,
+ };
+
+ struct FullWalletRequest {
+ public:
+ FullWalletRequest(const std::string& instrument_id,
+ const std::string& address_id,
+ const GURL& source_url,
+ const Cart& cart,
+ const std::string& google_transaction_id,
+ autofill::DialogType dialog_type,
+ const std::vector<RiskCapability> risk_capabilities);
+ ~FullWalletRequest();
+
+ // The ID of the backing instrument. Should have been selected by the user
+ // in some UI.
+ std::string instrument_id;
+
+ // The ID of the shipping address. Should have been selected by the user
+ // in some UI.
+ std::string address_id;
+
+ // The URL that Online Wallet usage is being initiated on.
+ GURL source_url;
+
+ // Cart information.
+ Cart cart;
+
+ // The transaction ID from GetWalletItems.
+ std::string google_transaction_id;
+
+ // Which usage of WalletClient this is.
+ autofill::DialogType dialog_type;
+
+ // The Risk challenges supported by the user of WalletClient
+ std::vector<RiskCapability> risk_capabilities;
+
+ private:
+ DISALLOW_ASSIGN(FullWalletRequest);
+ };
+
// |context_getter| is reference counted so it has no lifetime or ownership
// requirements. |observer| must outlive |this|.
WalletClient(net::URLRequestContextGetter* context_getter,
@@ -77,8 +120,10 @@ class WalletClient
// GetWalletItems retrieves the user's online wallet. The WalletItems
// returned may require additional action such as presenting legal documents
- // to the user to be accepted.
- void GetWalletItems(const GURL& source_url);
+ // to the user to be accepted. |risk_capabilities| are the Risk challenges
+ // supported by the users of WalletClient.
+ void GetWalletItems(const GURL& source_url,
+ const std::vector<RiskCapability>& risk_capabilities);
// The GetWalletItems call to the Online Wallet backend may require the user
// to accept various legal documents before a FullWallet can be generated.
@@ -96,18 +141,8 @@ class WalletClient
const std::string& card_verification_number,
const std::string& obfuscated_gaia_id);
- // GetFullWallet retrieves the a FullWallet for the user. |instrument_id| and
- // |adddress_id| should have been selected by the user in some UI,
- // |merchant_domain| should come from the BrowserContext, the |cart|
- // information will have been provided by the browser, |dialog_type| indicates
- // which dialog requests the full wallet, RequestAutocomplete or Autocheckout,
- // and |google_transaction_id| is the same one that GetWalletItems returns.
- void GetFullWallet(const std::string& instrument_id,
- const std::string& address_id,
- const GURL& source_url,
- const Cart& cart,
- const std::string& google_transaction_id,
- autofill::DialogType dialog_type);
+ // GetFullWallet retrieves the a FullWallet for the user.
+ void GetFullWallet(const FullWalletRequest& full_wallet_request);
// SaveAddress saves a new shipping address.
void SaveAddress(const Address& address, const GURL& source_url);
diff --git a/components/autofill/browser/wallet/wallet_client_unittest.cc b/components/autofill/browser/wallet/wallet_client_unittest.cc
index d074bf9..ae507cc 100644
--- a/components/autofill/browser/wallet/wallet_client_unittest.cc
+++ b/components/autofill/browser/wallet/wallet_client_unittest.cc
@@ -251,7 +251,7 @@ const char kGetFullWalletValidRequest[] =
"\"cart\":"
"{"
"\"currency_code\":\"currency_code\","
- "\"total_price\":\"currency_code\""
+ "\"total_price\":\"total_price\""
"},"
"\"encrypted_otp\":\"encrypted_one_time_pad\","
"\"feature\":\"REQUEST_AUTOCOMPLETE\","
@@ -260,13 +260,50 @@ const char kGetFullWalletValidRequest[] =
"\"risk_params\":\"\","
"\"selected_address_id\":\"shipping_address_id\","
"\"selected_instrument_id\":\"instrument_id\","
- "\"session_material\":\"session_material\""
+ "\"session_material\":\"session_material\","
+ "\"supported_risk_challenge\":"
+ "["
+ "]"
+ "}";
+
+const char kGetFullWalletWithRiskCapabilitesValidRequest[] =
+ "{"
+ "\"cart\":"
+ "{"
+ "\"currency_code\":\"currency_code\","
+ "\"total_price\":\"total_price\""
+ "},"
+ "\"encrypted_otp\":\"encrypted_one_time_pad\","
+ "\"feature\":\"REQUEST_AUTOCOMPLETE\","
+ "\"google_transaction_id\":\"google_transaction_id\","
+ "\"merchant_domain\":\"https://example.com/\","
+ "\"risk_params\":\"\","
+ "\"selected_address_id\":\"shipping_address_id\","
+ "\"selected_instrument_id\":\"instrument_id\","
+ "\"session_material\":\"session_material\","
+ "\"supported_risk_challenge\":"
+ "["
+ "\"VERIFY_CVC\""
+ "]"
"}";
const char kGetWalletItemsValidRequest[] =
"{"
"\"merchant_domain\":\"https://example.com/\","
- "\"risk_params\":\"\""
+ "\"risk_params\":\"\","
+ "\"supported_risk_challenge\":"
+ "["
+ "]"
+ "}";
+
+const char kGetWalletItemsWithRiskCapabilitiesValidRequest[] =
+ "{"
+ "\"merchant_domain\":\"https://example.com/\","
+ "\"risk_params\":\"\","
+ "\"supported_risk_challenge\":"
+ "["
+ "\"RELOGIN\""
+ "]"
"}";
const char kSaveAddressValidRequest[] =
@@ -535,7 +572,8 @@ TEST_F(WalletClientTest, WalletErrorOnExpectedResponse) {
net::TestURLFetcherFactory factory;
WalletClient wallet_client(profile_.GetRequestContext(), &observer);
- wallet_client.GetWalletItems(GURL(kMerchantUrl));
+ wallet_client.GetWalletItems(GURL(kMerchantUrl),
+ std::vector<WalletClient::RiskCapability>());
net::TestURLFetcher* fetcher = factory.GetFetcherByID(0);
ASSERT_TRUE(fetcher);
fetcher->set_response_code(net::HTTP_INTERNAL_SERVER_ERROR);
@@ -565,7 +603,8 @@ TEST_F(WalletClientTest, NetworkFailureOnExpectedResponse) {
net::TestURLFetcherFactory factory;
WalletClient wallet_client(profile_.GetRequestContext(), &observer);
- wallet_client.GetWalletItems(GURL(kMerchantUrl));
+ wallet_client.GetWalletItems(GURL(kMerchantUrl),
+ std::vector<WalletClient::RiskCapability>());
net::TestURLFetcher* fetcher = factory.GetFetcherByID(0);
ASSERT_TRUE(fetcher);
fetcher->set_response_code(net::HTTP_UNAUTHORIZED);
@@ -593,13 +632,16 @@ TEST_F(WalletClientTest, GetFullWalletSuccess) {
net::TestURLFetcherFactory factory;
WalletClient wallet_client(profile_.GetRequestContext(), &observer);
- Cart cart("currency_code", "currency_code");
- wallet_client.GetFullWallet("instrument_id",
- "shipping_address_id",
- GURL(kMerchantUrl),
- cart,
- "google_transaction_id",
- DIALOG_TYPE_REQUEST_AUTOCOMPLETE);
+ Cart cart("total_price", "currency_code");
+ WalletClient::FullWalletRequest full_wallet_request(
+ "instrument_id",
+ "shipping_address_id",
+ GURL(kMerchantUrl),
+ cart,
+ "google_transaction_id",
+ DIALOG_TYPE_REQUEST_AUTOCOMPLETE,
+ std::vector<WalletClient::RiskCapability>());
+ wallet_client.GetFullWallet(full_wallet_request);
net::TestURLFetcher* encryption_fetcher = factory.GetFetcherByID(1);
ASSERT_TRUE(encryption_fetcher);
@@ -615,6 +657,38 @@ TEST_F(WalletClientTest, GetFullWalletSuccess) {
EXPECT_EQ(1U, observer.full_wallets_received());
}
+TEST_F(WalletClientTest, GetFullWalletWithRiskCapabilitesSuccess) {
+ MockWalletClientObserver observer;
+ net::TestURLFetcherFactory factory;
+
+ WalletClient wallet_client(profile_.GetRequestContext(), &observer);
+ std::vector<WalletClient::RiskCapability> risk_capabilities;
+ risk_capabilities.push_back(WalletClient::VERIFY_CVC);
+ Cart cart("total_price", "currency_code");
+ WalletClient::FullWalletRequest full_wallet_request(
+ "instrument_id",
+ "shipping_address_id",
+ GURL(kMerchantUrl),
+ cart,
+ "google_transaction_id",
+ DIALOG_TYPE_REQUEST_AUTOCOMPLETE,
+ risk_capabilities);
+ wallet_client.GetFullWallet(full_wallet_request);
+
+ net::TestURLFetcher* encryption_fetcher = factory.GetFetcherByID(1);
+ ASSERT_TRUE(encryption_fetcher);
+ encryption_fetcher->set_response_code(net::HTTP_OK);
+ encryption_fetcher->SetResponseString(
+ "session_material|encrypted_one_time_pad");
+ encryption_fetcher->delegate()->OnURLFetchComplete(encryption_fetcher);
+
+ VerifyAndFinishRequest(factory,
+ net::HTTP_OK,
+ kGetFullWalletWithRiskCapabilitesValidRequest,
+ kGetFullWalletValidResponse);
+ EXPECT_EQ(1U, observer.full_wallets_received());
+}
+
TEST_F(WalletClientTest, GetFullWalletEncryptionDown) {
MockWalletClientObserver observer;
EXPECT_CALL(observer,
@@ -623,13 +697,16 @@ TEST_F(WalletClientTest, GetFullWalletEncryptionDown) {
net::TestURLFetcherFactory factory;
WalletClient wallet_client(profile_.GetRequestContext(), &observer);
- Cart cart("currency_code", "currency_code");
- wallet_client.GetFullWallet("instrument_id",
- "shipping_address_id",
- GURL(kMerchantUrl),
- cart,
- "google_transaction_id",
- DIALOG_TYPE_REQUEST_AUTOCOMPLETE);
+ Cart cart("total_price", "currency_code");
+ WalletClient::FullWalletRequest full_wallet_request(
+ "instrument_id",
+ "shipping_address_id",
+ GURL(kMerchantUrl),
+ cart,
+ "google_transaction_id",
+ DIALOG_TYPE_REQUEST_AUTOCOMPLETE,
+ std::vector<WalletClient::RiskCapability>());
+ wallet_client.GetFullWallet(full_wallet_request);
net::TestURLFetcher* encryption_fetcher = factory.GetFetcherByID(1);
ASSERT_TRUE(encryption_fetcher);
@@ -647,13 +724,16 @@ TEST_F(WalletClientTest, GetFullWalletEncryptionMalformed) {
net::TestURLFetcherFactory factory;
WalletClient wallet_client(profile_.GetRequestContext(), &observer);
- Cart cart("currency_code", "currency_code");
- wallet_client.GetFullWallet("instrument_id",
- "shipping_address_id",
- GURL(kMerchantUrl),
- cart,
- "google_transaction_id",
- DIALOG_TYPE_REQUEST_AUTOCOMPLETE);
+ Cart cart("total_price", "currency_code");
+ WalletClient::FullWalletRequest full_wallet_request(
+ "instrument_id",
+ "shipping_address_id",
+ GURL(kMerchantUrl),
+ cart,
+ "google_transaction_id",
+ DIALOG_TYPE_REQUEST_AUTOCOMPLETE,
+ std::vector<WalletClient::RiskCapability>());
+ wallet_client.GetFullWallet(full_wallet_request);
net::TestURLFetcher* encryption_fetcher = factory.GetFetcherByID(1);
ASSERT_TRUE(encryption_fetcher);
@@ -672,13 +752,16 @@ TEST_F(WalletClientTest, GetFullWalletMalformedResponse) {
net::TestURLFetcherFactory factory;
WalletClient wallet_client(profile_.GetRequestContext(), &observer);
- Cart cart("currency_code", "currency_code");
- wallet_client.GetFullWallet("instrument_id",
- "shipping_address_id",
- GURL(kMerchantUrl),
- cart,
- "google_transaction_id",
- DIALOG_TYPE_REQUEST_AUTOCOMPLETE);
+ Cart cart("total_price", "currency_code");
+ WalletClient::FullWalletRequest full_wallet_request(
+ "instrument_id",
+ "shipping_address_id",
+ GURL(kMerchantUrl),
+ cart,
+ "google_transaction_id",
+ DIALOG_TYPE_REQUEST_AUTOCOMPLETE,
+ std::vector<WalletClient::RiskCapability>());
+ wallet_client.GetFullWallet(full_wallet_request);
net::TestURLFetcher* encryption_fetcher = factory.GetFetcherByID(1);
ASSERT_TRUE(encryption_fetcher);
@@ -826,14 +909,31 @@ TEST_F(WalletClientTest, GetWalletItems) {
net::TestURLFetcherFactory factory;
WalletClient wallet_client(profile_.GetRequestContext(), &observer);
- wallet_client.GetWalletItems(GURL(kMerchantUrl));
- net::TestURLFetcher* fetcher = factory.GetFetcherByID(0);
- ASSERT_TRUE(fetcher);
- EXPECT_EQ(kGetWalletItemsValidRequest, GetData(fetcher));
- fetcher->set_response_code(net::HTTP_OK);
- fetcher->SetResponseString(kGetWalletItemsValidResponse);
- fetcher->delegate()->OnURLFetchComplete(fetcher);
+ wallet_client.GetWalletItems(GURL(kMerchantUrl),
+ std::vector<WalletClient::RiskCapability>());
+
+ VerifyAndFinishRequest(factory,
+ net::HTTP_OK,
+ kGetWalletItemsValidRequest,
+ kGetWalletItemsValidResponse);
+ EXPECT_EQ(1U, observer.wallet_items_received());
+}
+
+TEST_F(WalletClientTest, GetWalletItemsWithRiskCapabilites) {
+ MockWalletClientObserver observer;
+ net::TestURLFetcherFactory factory;
+ std::vector<WalletClient::RiskCapability> risk_capabilities;
+ risk_capabilities.push_back(WalletClient::RELOGIN);
+
+ WalletClient wallet_client(profile_.GetRequestContext(), &observer);
+ wallet_client.GetWalletItems(GURL(kMerchantUrl),
+ risk_capabilities);
+
+ VerifyAndFinishRequest(factory,
+ net::HTTP_OK,
+ kGetWalletItemsWithRiskCapabilitiesValidRequest,
+ kGetWalletItemsValidResponse);
EXPECT_EQ(1U, observer.wallet_items_received());
}
@@ -1384,7 +1484,8 @@ TEST_F(WalletClientTest, HasRequestInProgress) {
WalletClient wallet_client(profile_.GetRequestContext(), &observer);
EXPECT_FALSE(wallet_client.HasRequestInProgress());
- wallet_client.GetWalletItems(GURL(kMerchantUrl));
+ wallet_client.GetWalletItems(GURL(kMerchantUrl),
+ std::vector<WalletClient::RiskCapability>());
EXPECT_TRUE(wallet_client.HasRequestInProgress());
VerifyAndFinishRequest(factory,
@@ -1401,11 +1502,13 @@ TEST_F(WalletClientTest, PendingRequest) {
WalletClient wallet_client(profile_.GetRequestContext(), &observer);
ASSERT_EQ(0U, wallet_client.pending_requests_.size());
+ std::vector<WalletClient::RiskCapability> risk_capabilities;
+
// Shouldn't queue the first request.
- wallet_client.GetWalletItems(GURL(kMerchantUrl));
+ wallet_client.GetWalletItems(GURL(kMerchantUrl), risk_capabilities);
EXPECT_EQ(0U, wallet_client.pending_requests_.size());
- wallet_client.GetWalletItems(GURL(kMerchantUrl));
+ wallet_client.GetWalletItems(GURL(kMerchantUrl), risk_capabilities);
EXPECT_EQ(1U, wallet_client.pending_requests_.size());
VerifyAndFinishRequest(factory,
@@ -1428,9 +1531,11 @@ TEST_F(WalletClientTest, CancelPendingRequests) {
WalletClient wallet_client(profile_.GetRequestContext(), &observer);
ASSERT_EQ(0U, wallet_client.pending_requests_.size());
- wallet_client.GetWalletItems(GURL(kMerchantUrl));
- wallet_client.GetWalletItems(GURL(kMerchantUrl));
- wallet_client.GetWalletItems(GURL(kMerchantUrl));
+ std::vector<WalletClient::RiskCapability> risk_capabilities;
+
+ wallet_client.GetWalletItems(GURL(kMerchantUrl), risk_capabilities);
+ wallet_client.GetWalletItems(GURL(kMerchantUrl), risk_capabilities);
+ wallet_client.GetWalletItems(GURL(kMerchantUrl), risk_capabilities);
EXPECT_EQ(2U, wallet_client.pending_requests_.size());
wallet_client.CancelPendingRequests();