| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "base/json/json_reader.h" | |
| 6 #include "base/json/json_writer.h" | |
| 7 #include "base/logging.h" | |
| 8 #include "base/memory/scoped_ptr.h" | |
| 9 #include "base/string_util.h" | |
| 10 #include "base/strings/string_number_conversions.h" | |
| 11 #include "base/values.h" | |
| 12 #include "chrome/browser/autofill/wallet/cart.h" | |
| 13 #include "chrome/browser/autofill/wallet/full_wallet.h" | |
| 14 #include "chrome/browser/autofill/wallet/instrument.h" | |
| 15 #include "chrome/browser/autofill/wallet/wallet_client.h" | |
| 16 #include "chrome/browser/autofill/wallet/wallet_client_observer.h" | |
| 17 #include "chrome/browser/autofill/wallet/wallet_items.h" | |
| 18 #include "chrome/browser/autofill/wallet/wallet_test_util.h" | |
| 19 #include "chrome/test/base/testing_profile.h" | |
| 20 #include "components/autofill/common/autocheckout_status.h" | |
| 21 #include "content/public/test/test_browser_thread.h" | |
| 22 #include "googleurl/src/gurl.h" | |
| 23 #include "net/base/net_errors.h" | |
| 24 #include "net/http/http_status_code.h" | |
| 25 #include "net/url_request/test_url_fetcher_factory.h" | |
| 26 #include "net/url_request/url_fetcher_delegate.h" | |
| 27 #include "net/url_request/url_request_status.h" | |
| 28 #include "testing/gmock/include/gmock/gmock.h" | |
| 29 #include "testing/gtest/include/gtest/gtest.h" | |
| 30 | |
| 31 namespace { | |
| 32 | |
| 33 const char kGoogleTransactionId[] = "google-transaction-id"; | |
| 34 const char kMerchantUrl[] = "https://example.com/path?key=value"; | |
| 35 | |
| 36 const char kGetFullWalletValidResponse[] = | |
| 37 "{" | |
| 38 " \"expiration_month\":12," | |
| 39 " \"expiration_year\":2012," | |
| 40 " \"iin\":\"iin\"," | |
| 41 " \"rest\":\"rest\"," | |
| 42 " \"billing_address\":" | |
| 43 " {" | |
| 44 " \"id\":\"id\"," | |
| 45 " \"phone_number\":\"phone_number\"," | |
| 46 " \"postal_address\":" | |
| 47 " {" | |
| 48 " \"recipient_name\":\"recipient_name\"," | |
| 49 " \"address_line\":" | |
| 50 " [" | |
| 51 " \"address_line_1\"," | |
| 52 " \"address_line_2\"" | |
| 53 " ]," | |
| 54 " \"locality_name\":\"locality_name\"," | |
| 55 " \"administrative_area_name\":\"administrative_area_name\"," | |
| 56 " \"postal_code_number\":\"postal_code_number\"," | |
| 57 " \"country_name_code\":\"country_name_code\"" | |
| 58 " }" | |
| 59 " }," | |
| 60 " \"shipping_address\":" | |
| 61 " {" | |
| 62 " \"id\":\"ship_id\"," | |
| 63 " \"phone_number\":\"ship_phone_number\"," | |
| 64 " \"postal_address\":" | |
| 65 " {" | |
| 66 " \"recipient_name\":\"ship_recipient_name\"," | |
| 67 " \"address_line\":" | |
| 68 " [" | |
| 69 " \"ship_address_line_1\"," | |
| 70 " \"ship_address_line_2\"" | |
| 71 " ]," | |
| 72 " \"locality_name\":\"ship_locality_name\"," | |
| 73 " \"administrative_area_name\":\"ship_administrative_area_name\"," | |
| 74 " \"postal_code_number\":\"ship_postal_code_number\"," | |
| 75 " \"country_name_code\":\"ship_country_name_code\"" | |
| 76 " }" | |
| 77 " }," | |
| 78 " \"required_action\":" | |
| 79 " [" | |
| 80 " ]" | |
| 81 "}"; | |
| 82 | |
| 83 const char kGetFullWalletInvalidResponse[] = | |
| 84 "{" | |
| 85 " \"garbage\":123" | |
| 86 "}"; | |
| 87 | |
| 88 const char kGetWalletItemsValidResponse[] = | |
| 89 "{" | |
| 90 " \"required_action\":" | |
| 91 " [" | |
| 92 " ]," | |
| 93 " \"google_transaction_id\":\"google_transaction_id\"," | |
| 94 " \"instrument\":" | |
| 95 " [" | |
| 96 " {" | |
| 97 " \"descriptive_name\":\"descriptive_name\"," | |
| 98 " \"type\":\"VISA\"," | |
| 99 " \"supported_currency\":\"currency_code\"," | |
| 100 " \"last_four_digits\":\"last_four_digits\"," | |
| 101 " \"expiration_month\":12," | |
| 102 " \"expiration_year\":2012," | |
| 103 " \"brand\":\"monkeys\"," | |
| 104 " \"billing_address\":" | |
| 105 " {" | |
| 106 " \"name\":\"name\"," | |
| 107 " \"address1\":\"address1\"," | |
| 108 " \"address2\":\"address2\"," | |
| 109 " \"city\":\"city\"," | |
| 110 " \"state\":\"state\"," | |
| 111 " \"postal_code\":\"postal_code\"," | |
| 112 " \"phone_number\":\"phone_number\"," | |
| 113 " \"country_code\":\"country_code\"" | |
| 114 " }," | |
| 115 " \"status\":\"VALID\"," | |
| 116 " \"object_id\":\"default_instrument_id\"" | |
| 117 " }" | |
| 118 " ]," | |
| 119 " \"default_instrument_id\":\"default_instrument_id\"," | |
| 120 " \"obfuscated_gaia_id\":\"obfuscated_gaia_id\"," | |
| 121 " \"address\":" | |
| 122 " [" | |
| 123 " ]," | |
| 124 " \"default_address_id\":\"default_address_id\"," | |
| 125 " \"required_legal_document\":" | |
| 126 " [" | |
| 127 " ]" | |
| 128 "}"; | |
| 129 | |
| 130 const char kSaveAddressValidResponse[] = | |
| 131 "{" | |
| 132 " \"shipping_address_id\":\"shipping_address_id\"" | |
| 133 "}"; | |
| 134 | |
| 135 const char kSaveAddressWithRequiredActionsValidResponse[] = | |
| 136 "{" | |
| 137 " \"required_action\":" | |
| 138 " [" | |
| 139 " \" \\treqUIRE_PhOnE_number \\n\\r\"," | |
| 140 " \"INVALID_form_field\"" | |
| 141 " ]" | |
| 142 "}"; | |
| 143 | |
| 144 const char kSaveWithInvalidRequiredActionsResponse[] = | |
| 145 "{" | |
| 146 " \"required_action\":" | |
| 147 " [" | |
| 148 " \" setup_wallet\"," | |
| 149 " \" \\treqUIRE_PhOnE_number \\n\\r\"," | |
| 150 " \"INVALID_form_field\"" | |
| 151 " ]" | |
| 152 "}"; | |
| 153 | |
| 154 const char kSaveInvalidResponse[] = | |
| 155 "{" | |
| 156 " \"garbage\":123" | |
| 157 "}"; | |
| 158 | |
| 159 const char kSaveInstrumentValidResponse[] = | |
| 160 "{" | |
| 161 " \"instrument_id\":\"instrument_id\"" | |
| 162 "}"; | |
| 163 | |
| 164 const char kSaveInstrumentWithRequiredActionsValidResponse[] = | |
| 165 "{" | |
| 166 " \"required_action\":" | |
| 167 " [" | |
| 168 " \" \\treqUIRE_PhOnE_number \\n\\r\"," | |
| 169 " \"INVALID_form_field\"" | |
| 170 " ]" | |
| 171 "}"; | |
| 172 | |
| 173 const char kSaveInstrumentAndAddressValidResponse[] = | |
| 174 "{" | |
| 175 " \"shipping_address_id\":\"shipping_address_id\"," | |
| 176 " \"instrument_id\":\"instrument_id\"" | |
| 177 "}"; | |
| 178 | |
| 179 const char kSaveInstrumentAndAddressWithRequiredActionsValidResponse[] = | |
| 180 "{" | |
| 181 " \"required_action\":" | |
| 182 " [" | |
| 183 " \" \\treqUIRE_PhOnE_number \\n\\r\"," | |
| 184 " \"INVALID_form_field\"" | |
| 185 " ]" | |
| 186 "}"; | |
| 187 | |
| 188 const char kSaveInstrumentAndAddressMissingAddressResponse[] = | |
| 189 "{" | |
| 190 " \"instrument_id\":\"instrument_id\"" | |
| 191 "}"; | |
| 192 | |
| 193 const char kSaveInstrumentAndAddressMissingInstrumentResponse[] = | |
| 194 "{" | |
| 195 " \"shipping_address_id\":\"shipping_address_id\"" | |
| 196 "}"; | |
| 197 | |
| 198 const char kUpdateInstrumentValidResponse[] = | |
| 199 "{" | |
| 200 " \"instrument_id\":\"instrument_id\"" | |
| 201 "}"; | |
| 202 | |
| 203 const char kUpdateInstrumentWithRequiredActionsValidResponse[] = | |
| 204 "{" | |
| 205 " \"required_action\":" | |
| 206 " [" | |
| 207 " \" \\treqUIRE_PhOnE_number \\n\\r\"," | |
| 208 " \"INVALID_form_field\"" | |
| 209 " ]" | |
| 210 "}"; | |
| 211 | |
| 212 const char kUpdateInstrumentMalformedResponse[] = | |
| 213 "{" | |
| 214 " \"cheese\":\"monkeys\"" | |
| 215 "}"; | |
| 216 | |
| 217 const char kAuthenticateInstrumentFailureResponse[] = | |
| 218 "{" | |
| 219 " \"auth_result\":\"anything else\"" | |
| 220 "}"; | |
| 221 | |
| 222 const char kAuthenticateInstrumentSuccessResponse[] = | |
| 223 "{" | |
| 224 " \"auth_result\":\"SUCCESS\"" | |
| 225 "}"; | |
| 226 | |
| 227 // The JSON below is used to test against the request payload being sent to | |
| 228 // Online Wallet. It's indented differently since JSONWriter creates compact | |
| 229 // JSON from DictionaryValues. | |
| 230 | |
| 231 const char kAcceptLegalDocumentsValidRequest[] = | |
| 232 "{" | |
| 233 "\"accepted_legal_document\":" | |
| 234 "[" | |
| 235 "\"doc_1\"," | |
| 236 "\"doc_2\"" | |
| 237 "]," | |
| 238 "\"google_transaction_id\":\"google-transaction-id\"," | |
| 239 "\"merchant_domain\":\"https://example.com/\"" | |
| 240 "}"; | |
| 241 | |
| 242 const char kAuthenticateInstrumentValidRequest[] = | |
| 243 "{" | |
| 244 "\"instrument_escrow_handle\":\"escrow_handle\"," | |
| 245 "\"instrument_id\":\"instrument_id\"," | |
| 246 "\"risk_params\":\"\"" | |
| 247 "}"; | |
| 248 | |
| 249 const char kGetFullWalletValidRequest[] = | |
| 250 "{" | |
| 251 "\"cart\":" | |
| 252 "{" | |
| 253 "\"currency_code\":\"currency_code\"," | |
| 254 "\"total_price\":\"currency_code\"" | |
| 255 "}," | |
| 256 "\"encrypted_otp\":\"encrypted_one_time_pad\"," | |
| 257 "\"google_transaction_id\":\"google_transaction_id\"," | |
| 258 "\"merchant_domain\":\"https://example.com/\"," | |
| 259 "\"risk_params\":\"\"," | |
| 260 "\"selected_address_id\":\"shipping_address_id\"," | |
| 261 "\"selected_instrument_id\":\"instrument_id\"," | |
| 262 "\"session_material\":\"session_material\"" | |
| 263 "}"; | |
| 264 | |
| 265 const char kGetWalletItemsValidRequest[] = | |
| 266 "{" | |
| 267 "\"merchant_domain\":\"https://example.com/\"," | |
| 268 "\"risk_params\":\"\"" | |
| 269 "}"; | |
| 270 | |
| 271 const char kSaveAddressValidRequest[] = | |
| 272 "{" | |
| 273 "\"merchant_domain\":\"https://example.com/\"," | |
| 274 "\"risk_params\":\"\"," | |
| 275 "\"shipping_address\":" | |
| 276 "{" | |
| 277 "\"phone_number\":\"ship_phone_number\"," | |
| 278 "\"postal_address\":" | |
| 279 "{" | |
| 280 "\"address_line\":" | |
| 281 "[" | |
| 282 "\"ship_address_line_1\"," | |
| 283 "\"ship_address_line_2\"" | |
| 284 "]," | |
| 285 "\"administrative_area_name\":\"ship_admin_area_name\"," | |
| 286 "\"country_name_code\":\"ship_country_name_code\"," | |
| 287 "\"locality_name\":\"ship_locality_name\"," | |
| 288 "\"postal_code_number\":\"ship_postal_code_number\"," | |
| 289 "\"recipient_name\":\"ship_recipient_name\"" | |
| 290 "}" | |
| 291 "}" | |
| 292 "}"; | |
| 293 | |
| 294 const char kSaveInstrumentValidRequest[] = | |
| 295 "{" | |
| 296 "\"instrument\":" | |
| 297 "{" | |
| 298 "\"credit_card\":" | |
| 299 "{" | |
| 300 "\"address\":" | |
| 301 "{" | |
| 302 "\"address_line\":" | |
| 303 "[" | |
| 304 "\"address_line_1\"," | |
| 305 "\"address_line_2\"" | |
| 306 "]," | |
| 307 "\"administrative_area_name\":\"admin_area_name\"," | |
| 308 "\"country_name_code\":\"country_name_code\"," | |
| 309 "\"locality_name\":\"locality_name\"," | |
| 310 "\"postal_code_number\":\"postal_code_number\"," | |
| 311 "\"recipient_name\":\"recipient_name\"" | |
| 312 "}," | |
| 313 "\"exp_month\":12," | |
| 314 "\"exp_year\":2012," | |
| 315 "\"fop_type\":\"VISA\"," | |
| 316 "\"last_4_digits\":\"4448\"" | |
| 317 "}," | |
| 318 "\"type\":\"CREDIT_CARD\"" | |
| 319 "}," | |
| 320 "\"instrument_escrow_handle\":\"escrow_handle\"," | |
| 321 "\"instrument_phone_number\":\"phone_number\"," | |
| 322 "\"merchant_domain\":\"https://example.com/\"," | |
| 323 "\"risk_params\":\"\"" | |
| 324 "}"; | |
| 325 | |
| 326 const char kSaveInstrumentAndAddressValidRequest[] = | |
| 327 "{" | |
| 328 "\"instrument\":" | |
| 329 "{" | |
| 330 "\"credit_card\":" | |
| 331 "{" | |
| 332 "\"address\":" | |
| 333 "{" | |
| 334 "\"address_line\":" | |
| 335 "[" | |
| 336 "\"address_line_1\"," | |
| 337 "\"address_line_2\"" | |
| 338 "]," | |
| 339 "\"administrative_area_name\":\"admin_area_name\"," | |
| 340 "\"country_name_code\":\"country_name_code\"," | |
| 341 "\"locality_name\":\"locality_name\"," | |
| 342 "\"postal_code_number\":\"postal_code_number\"," | |
| 343 "\"recipient_name\":\"recipient_name\"" | |
| 344 "}," | |
| 345 "\"exp_month\":12," | |
| 346 "\"exp_year\":2012," | |
| 347 "\"fop_type\":\"VISA\"," | |
| 348 "\"last_4_digits\":\"4448\"" | |
| 349 "}," | |
| 350 "\"type\":\"CREDIT_CARD\"" | |
| 351 "}," | |
| 352 "\"instrument_escrow_handle\":\"escrow_handle\"," | |
| 353 "\"instrument_phone_number\":\"phone_number\"," | |
| 354 "\"merchant_domain\":\"https://example.com/\"," | |
| 355 "\"risk_params\":\"\"," | |
| 356 "\"shipping_address\":" | |
| 357 "{" | |
| 358 "\"phone_number\":\"ship_phone_number\"," | |
| 359 "\"postal_address\":" | |
| 360 "{" | |
| 361 "\"address_line\":" | |
| 362 "[" | |
| 363 "\"ship_address_line_1\"," | |
| 364 "\"ship_address_line_2\"" | |
| 365 "]," | |
| 366 "\"administrative_area_name\":\"ship_admin_area_name\"," | |
| 367 "\"country_name_code\":\"ship_country_name_code\"," | |
| 368 "\"locality_name\":\"ship_locality_name\"," | |
| 369 "\"postal_code_number\":\"ship_postal_code_number\"," | |
| 370 "\"recipient_name\":\"ship_recipient_name\"" | |
| 371 "}" | |
| 372 "}" | |
| 373 "}"; | |
| 374 | |
| 375 const char kSendAutocheckoutStatusOfSuccessValidRequest[] = | |
| 376 "{" | |
| 377 "\"google_transaction_id\":\"google_transaction_id\"," | |
| 378 "\"merchant_domain\":\"https://example.com/\"," | |
| 379 "\"success\":true" | |
| 380 "}"; | |
| 381 | |
| 382 const char kSendAutocheckoutStatusOfFailureValidRequest[] = | |
| 383 "{" | |
| 384 "\"google_transaction_id\":\"google_transaction_id\"," | |
| 385 "\"merchant_domain\":\"https://example.com/\"," | |
| 386 "\"reason\":\"CANNOT_PROCEED\"," | |
| 387 "\"success\":false" | |
| 388 "}"; | |
| 389 | |
| 390 const char kUpdateInstrumentValidRequest[] = | |
| 391 "{" | |
| 392 "\"instrument_phone_number\":\"phone_number\"," | |
| 393 "\"merchant_domain\":\"https://example.com/\"," | |
| 394 "\"risk_params\":\"\"," | |
| 395 "\"upgraded_billing_address\":" | |
| 396 "{" | |
| 397 "\"address_line\":" | |
| 398 "[" | |
| 399 "\"address_line_1\"," | |
| 400 "\"address_line_2\"" | |
| 401 "]," | |
| 402 "\"administrative_area_name\":\"admin_area_name\"," | |
| 403 "\"country_name_code\":\"country_name_code\"," | |
| 404 "\"locality_name\":\"locality_name\"," | |
| 405 "\"postal_code_number\":\"postal_code_number\"," | |
| 406 "\"recipient_name\":\"recipient_name\"" | |
| 407 "}," | |
| 408 "\"upgraded_instrument_id\":\"instrument_id\"" | |
| 409 "}"; | |
| 410 | |
| 411 } // namespace | |
| 412 | |
| 413 namespace autofill { | |
| 414 namespace wallet { | |
| 415 | |
| 416 class WalletClientTest : public testing::Test { | |
| 417 public: | |
| 418 WalletClientTest() : io_thread_(content::BrowserThread::IO) {} | |
| 419 | |
| 420 virtual void SetUp() { | |
| 421 io_thread_.StartIOThread(); | |
| 422 profile_.CreateRequestContext(); | |
| 423 } | |
| 424 | |
| 425 virtual void TearDown() { | |
| 426 profile_.ResetRequestContext(); | |
| 427 io_thread_.Stop(); | |
| 428 } | |
| 429 | |
| 430 std::string GetData(net::TestURLFetcher* fetcher) { | |
| 431 std::string data = fetcher->upload_data(); | |
| 432 scoped_ptr<Value> root(base::JSONReader::Read(data)); | |
| 433 | |
| 434 // If this is not a JSON dictionary, return plain text. | |
| 435 if (root.get() == NULL || !root->IsType(Value::TYPE_DICTIONARY)) | |
| 436 return data; | |
| 437 | |
| 438 // Remove api_key entry (to prevent accidental leak), return JSON as text. | |
| 439 DictionaryValue* dict = static_cast<DictionaryValue*>(root.get()); | |
| 440 dict->Remove("api_key", NULL); | |
| 441 base::JSONWriter::Write(dict, &data); | |
| 442 return data; | |
| 443 } | |
| 444 | |
| 445 void VerifyAndFinishRequest(const net::TestURLFetcherFactory& fetcher_factory, | |
| 446 net::HttpStatusCode response_code, | |
| 447 const std::string& request_body, | |
| 448 const std::string& response_body) { | |
| 449 net::TestURLFetcher* fetcher = fetcher_factory.GetFetcherByID(0); | |
| 450 ASSERT_TRUE(fetcher); | |
| 451 EXPECT_EQ(request_body, GetData(fetcher)); | |
| 452 fetcher->set_response_code(response_code); | |
| 453 fetcher->SetResponseString(response_body); | |
| 454 fetcher->delegate()->OnURLFetchComplete(fetcher); | |
| 455 } | |
| 456 protected: | |
| 457 TestingProfile profile_; | |
| 458 | |
| 459 private: | |
| 460 // The profile's request context must be released on the IO thread. | |
| 461 content::TestBrowserThread io_thread_; | |
| 462 }; | |
| 463 | |
| 464 class MockWalletClientObserver : | |
| 465 public WalletClientObserver, | |
| 466 public base::SupportsWeakPtr<MockWalletClientObserver> { | |
| 467 public: | |
| 468 MockWalletClientObserver() | |
| 469 : full_wallets_received_(0), wallet_items_received_(0) {} | |
| 470 ~MockWalletClientObserver() {} | |
| 471 | |
| 472 MOCK_METHOD0(OnDidAcceptLegalDocuments, void()); | |
| 473 MOCK_METHOD1(OnDidAuthenticateInstrument, void(bool success)); | |
| 474 MOCK_METHOD2(OnDidSaveAddress, | |
| 475 void(const std::string& address_id, | |
| 476 const std::vector<RequiredAction>& required_actions)); | |
| 477 MOCK_METHOD2(OnDidSaveInstrument, | |
| 478 void(const std::string& instrument_id, | |
| 479 const std::vector<RequiredAction>& required_actions)); | |
| 480 MOCK_METHOD3(OnDidSaveInstrumentAndAddress, | |
| 481 void(const std::string& instrument_id, | |
| 482 const std::string& shipping_address_id, | |
| 483 const std::vector<RequiredAction>& required_actions)); | |
| 484 MOCK_METHOD0(OnDidSendAutocheckoutStatus, void()); | |
| 485 MOCK_METHOD2(OnDidUpdateInstrument, | |
| 486 void(const std::string& instrument_id, | |
| 487 const std::vector<RequiredAction>& required_actions)); | |
| 488 MOCK_METHOD0(OnWalletError, void()); | |
| 489 MOCK_METHOD0(OnMalformedResponse, void()); | |
| 490 MOCK_METHOD1(OnNetworkError, void(int response_code)); | |
| 491 | |
| 492 virtual void OnDidGetFullWallet(scoped_ptr<FullWallet> full_wallet) OVERRIDE { | |
| 493 EXPECT_TRUE(full_wallet); | |
| 494 ++full_wallets_received_; | |
| 495 } | |
| 496 virtual void OnDidGetWalletItems(scoped_ptr<WalletItems> wallet_items) | |
| 497 OVERRIDE { | |
| 498 EXPECT_TRUE(wallet_items); | |
| 499 ++wallet_items_received_; | |
| 500 } | |
| 501 size_t full_wallets_received() const { return full_wallets_received_; } | |
| 502 size_t wallet_items_received() const { return wallet_items_received_; } | |
| 503 | |
| 504 private: | |
| 505 size_t full_wallets_received_; | |
| 506 size_t wallet_items_received_; | |
| 507 }; | |
| 508 | |
| 509 // TODO(ahutter): Implement API compatibility tests. See | |
| 510 // http://crbug.com/164465. | |
| 511 | |
| 512 // TODO(ahutter): Improve this when the error body is captured. See | |
| 513 // http://crbug.com/164410. | |
| 514 TEST_F(WalletClientTest, WalletErrorOnExpectedVoidResponse) { | |
| 515 MockWalletClientObserver observer; | |
| 516 EXPECT_CALL(observer, OnWalletError()).Times(1); | |
| 517 | |
| 518 net::TestURLFetcherFactory factory; | |
| 519 | |
| 520 WalletClient wallet_client(profile_.GetRequestContext()); | |
| 521 wallet_client.SendAutocheckoutStatus(autofill::SUCCESS, | |
| 522 GURL(kMerchantUrl), | |
| 523 "", | |
| 524 observer.AsWeakPtr()); | |
| 525 net::TestURLFetcher* fetcher = factory.GetFetcherByID(0); | |
| 526 ASSERT_TRUE(fetcher); | |
| 527 fetcher->set_response_code(net::HTTP_INTERNAL_SERVER_ERROR); | |
| 528 fetcher->delegate()->OnURLFetchComplete(fetcher); | |
| 529 } | |
| 530 | |
| 531 // TODO(ahutter): Improve this when the error body is captured. See | |
| 532 // http://crbug.com/164410. | |
| 533 TEST_F(WalletClientTest, WalletErrorOnExpectedResponse) { | |
| 534 MockWalletClientObserver observer; | |
| 535 EXPECT_CALL(observer, OnWalletError()).Times(1); | |
| 536 | |
| 537 net::TestURLFetcherFactory factory; | |
| 538 | |
| 539 WalletClient wallet_client(profile_.GetRequestContext()); | |
| 540 wallet_client.GetWalletItems(GURL(kMerchantUrl), observer.AsWeakPtr()); | |
| 541 net::TestURLFetcher* fetcher = factory.GetFetcherByID(0); | |
| 542 ASSERT_TRUE(fetcher); | |
| 543 fetcher->set_response_code(net::HTTP_INTERNAL_SERVER_ERROR); | |
| 544 fetcher->delegate()->OnURLFetchComplete(fetcher); | |
| 545 } | |
| 546 | |
| 547 TEST_F(WalletClientTest, NetworkFailureOnExpectedVoidResponse) { | |
| 548 MockWalletClientObserver observer; | |
| 549 EXPECT_CALL(observer, OnNetworkError(net::HTTP_UNAUTHORIZED)).Times(1); | |
| 550 | |
| 551 net::TestURLFetcherFactory factory; | |
| 552 | |
| 553 WalletClient wallet_client(profile_.GetRequestContext()); | |
| 554 wallet_client.SendAutocheckoutStatus(autofill::SUCCESS, | |
| 555 GURL(kMerchantUrl), | |
| 556 "", | |
| 557 observer.AsWeakPtr()); | |
| 558 net::TestURLFetcher* fetcher = factory.GetFetcherByID(0); | |
| 559 ASSERT_TRUE(fetcher); | |
| 560 fetcher->set_response_code(net::HTTP_UNAUTHORIZED); | |
| 561 fetcher->delegate()->OnURLFetchComplete(fetcher); | |
| 562 } | |
| 563 | |
| 564 TEST_F(WalletClientTest, NetworkFailureOnExpectedResponse) { | |
| 565 MockWalletClientObserver observer; | |
| 566 EXPECT_CALL(observer, OnNetworkError(net::HTTP_UNAUTHORIZED)).Times(1); | |
| 567 | |
| 568 net::TestURLFetcherFactory factory; | |
| 569 | |
| 570 WalletClient wallet_client(profile_.GetRequestContext()); | |
| 571 wallet_client.GetWalletItems(GURL(kMerchantUrl), observer.AsWeakPtr()); | |
| 572 net::TestURLFetcher* fetcher = factory.GetFetcherByID(0); | |
| 573 ASSERT_TRUE(fetcher); | |
| 574 fetcher->set_response_code(net::HTTP_UNAUTHORIZED); | |
| 575 fetcher->delegate()->OnURLFetchComplete(fetcher); | |
| 576 } | |
| 577 | |
| 578 TEST_F(WalletClientTest, RequestError) { | |
| 579 MockWalletClientObserver observer; | |
| 580 EXPECT_CALL(observer, OnWalletError()).Times(1); | |
| 581 | |
| 582 net::TestURLFetcherFactory factory; | |
| 583 | |
| 584 WalletClient wallet_client(profile_.GetRequestContext()); | |
| 585 wallet_client.SendAutocheckoutStatus(autofill::SUCCESS, | |
| 586 GURL(kMerchantUrl), | |
| 587 "", | |
| 588 observer.AsWeakPtr()); | |
| 589 net::TestURLFetcher* fetcher = factory.GetFetcherByID(0); | |
| 590 ASSERT_TRUE(fetcher); | |
| 591 fetcher->set_response_code(net::HTTP_BAD_REQUEST); | |
| 592 fetcher->delegate()->OnURLFetchComplete(fetcher); | |
| 593 } | |
| 594 | |
| 595 TEST_F(WalletClientTest, GetFullWalletSuccess) { | |
| 596 MockWalletClientObserver observer; | |
| 597 net::TestURLFetcherFactory factory; | |
| 598 | |
| 599 WalletClient wallet_client(profile_.GetRequestContext()); | |
| 600 Cart cart("currency_code", "currency_code"); | |
| 601 wallet_client.GetFullWallet("instrument_id", | |
| 602 "shipping_address_id", | |
| 603 GURL(kMerchantUrl), | |
| 604 cart, | |
| 605 "google_transaction_id", | |
| 606 observer.AsWeakPtr()); | |
| 607 | |
| 608 net::TestURLFetcher* encryption_fetcher = factory.GetFetcherByID(1); | |
| 609 ASSERT_TRUE(encryption_fetcher); | |
| 610 encryption_fetcher->set_response_code(net::HTTP_OK); | |
| 611 encryption_fetcher->SetResponseString( | |
| 612 "session_material|encrypted_one_time_pad"); | |
| 613 encryption_fetcher->delegate()->OnURLFetchComplete(encryption_fetcher); | |
| 614 | |
| 615 VerifyAndFinishRequest(factory, | |
| 616 net::HTTP_OK, | |
| 617 kGetFullWalletValidRequest, | |
| 618 kGetFullWalletValidResponse); | |
| 619 EXPECT_EQ(1U, observer.full_wallets_received()); | |
| 620 } | |
| 621 | |
| 622 TEST_F(WalletClientTest, GetFullWalletEncryptionDown) { | |
| 623 MockWalletClientObserver observer; | |
| 624 EXPECT_CALL(observer, | |
| 625 OnNetworkError(net::HTTP_INTERNAL_SERVER_ERROR)).Times(1); | |
| 626 | |
| 627 net::TestURLFetcherFactory factory; | |
| 628 | |
| 629 WalletClient wallet_client(profile_.GetRequestContext()); | |
| 630 Cart cart("currency_code", "currency_code"); | |
| 631 wallet_client.GetFullWallet("instrument_id", | |
| 632 "shipping_address_id", | |
| 633 GURL(kMerchantUrl), | |
| 634 cart, | |
| 635 "google_transaction_id", | |
| 636 observer.AsWeakPtr()); | |
| 637 | |
| 638 net::TestURLFetcher* encryption_fetcher = factory.GetFetcherByID(1); | |
| 639 ASSERT_TRUE(encryption_fetcher); | |
| 640 encryption_fetcher->set_response_code(net::HTTP_INTERNAL_SERVER_ERROR); | |
| 641 encryption_fetcher->SetResponseString(std::string()); | |
| 642 encryption_fetcher->delegate()->OnURLFetchComplete(encryption_fetcher); | |
| 643 | |
| 644 EXPECT_EQ(0U, observer.full_wallets_received()); | |
| 645 } | |
| 646 | |
| 647 TEST_F(WalletClientTest, GetFullWalletEncryptionMalformed) { | |
| 648 MockWalletClientObserver observer; | |
| 649 EXPECT_CALL(observer, OnMalformedResponse()).Times(1); | |
| 650 | |
| 651 net::TestURLFetcherFactory factory; | |
| 652 | |
| 653 WalletClient wallet_client(profile_.GetRequestContext()); | |
| 654 Cart cart("currency_code", "currency_code"); | |
| 655 wallet_client.GetFullWallet("instrument_id", | |
| 656 "shipping_address_id", | |
| 657 GURL(kMerchantUrl), | |
| 658 cart, | |
| 659 "google_transaction_id", | |
| 660 observer.AsWeakPtr()); | |
| 661 | |
| 662 net::TestURLFetcher* encryption_fetcher = factory.GetFetcherByID(1); | |
| 663 ASSERT_TRUE(encryption_fetcher); | |
| 664 encryption_fetcher->set_response_code(net::HTTP_OK); | |
| 665 encryption_fetcher->SetResponseString( | |
| 666 "session_material:encrypted_one_time_pad"); | |
| 667 encryption_fetcher->delegate()->OnURLFetchComplete(encryption_fetcher); | |
| 668 | |
| 669 EXPECT_EQ(0U, observer.full_wallets_received()); | |
| 670 } | |
| 671 | |
| 672 TEST_F(WalletClientTest, GetFullWalletMalformedResponse) { | |
| 673 MockWalletClientObserver observer; | |
| 674 EXPECT_CALL(observer, OnMalformedResponse()).Times(1); | |
| 675 | |
| 676 net::TestURLFetcherFactory factory; | |
| 677 | |
| 678 WalletClient wallet_client(profile_.GetRequestContext()); | |
| 679 Cart cart("currency_code", "currency_code"); | |
| 680 wallet_client.GetFullWallet("instrument_id", | |
| 681 "shipping_address_id", | |
| 682 GURL(kMerchantUrl), | |
| 683 cart, | |
| 684 "google_transaction_id", | |
| 685 observer.AsWeakPtr()); | |
| 686 | |
| 687 net::TestURLFetcher* encryption_fetcher = factory.GetFetcherByID(1); | |
| 688 ASSERT_TRUE(encryption_fetcher); | |
| 689 encryption_fetcher->set_response_code(net::HTTP_OK); | |
| 690 encryption_fetcher->SetResponseString( | |
| 691 "session_material|encrypted_one_time_pad"); | |
| 692 encryption_fetcher->delegate()->OnURLFetchComplete(encryption_fetcher); | |
| 693 | |
| 694 VerifyAndFinishRequest(factory, | |
| 695 net::HTTP_OK, | |
| 696 kGetFullWalletValidRequest, | |
| 697 kGetFullWalletInvalidResponse); | |
| 698 EXPECT_EQ(0U, observer.full_wallets_received()); | |
| 699 } | |
| 700 | |
| 701 TEST_F(WalletClientTest, AcceptLegalDocuments) { | |
| 702 MockWalletClientObserver observer; | |
| 703 EXPECT_CALL(observer, OnDidAcceptLegalDocuments()).Times(1); | |
| 704 | |
| 705 net::TestURLFetcherFactory factory; | |
| 706 | |
| 707 WalletClient wallet_client(profile_.GetRequestContext()); | |
| 708 std::vector<std::string> doc_ids; | |
| 709 doc_ids.push_back("doc_1"); | |
| 710 doc_ids.push_back("doc_2"); | |
| 711 wallet_client.AcceptLegalDocuments(doc_ids, | |
| 712 kGoogleTransactionId, | |
| 713 GURL(kMerchantUrl), | |
| 714 observer.AsWeakPtr()); | |
| 715 net::TestURLFetcher* fetcher = factory.GetFetcherByID(0); | |
| 716 ASSERT_TRUE(fetcher); | |
| 717 EXPECT_EQ(kAcceptLegalDocumentsValidRequest, GetData(fetcher)); | |
| 718 fetcher->SetResponseString(")]}'"); // Invalid JSON. Should be ignored. | |
| 719 fetcher->set_response_code(net::HTTP_OK); | |
| 720 fetcher->delegate()->OnURLFetchComplete(fetcher); | |
| 721 } | |
| 722 | |
| 723 TEST_F(WalletClientTest, AuthenticateInstrumentSucceeded) { | |
| 724 MockWalletClientObserver observer; | |
| 725 EXPECT_CALL(observer, OnDidAuthenticateInstrument(true)).Times(1); | |
| 726 | |
| 727 net::TestURLFetcherFactory factory; | |
| 728 | |
| 729 WalletClient wallet_client(profile_.GetRequestContext()); | |
| 730 wallet_client.AuthenticateInstrument("instrument_id", | |
| 731 "cvv", | |
| 732 "obfuscated_gaia_id", | |
| 733 observer.AsWeakPtr()); | |
| 734 | |
| 735 net::TestURLFetcher* encryption_fetcher = factory.GetFetcherByID(1); | |
| 736 ASSERT_TRUE(encryption_fetcher); | |
| 737 encryption_fetcher->set_response_code(net::HTTP_OK); | |
| 738 encryption_fetcher->SetResponseString("escrow_handle"); | |
| 739 encryption_fetcher->delegate()->OnURLFetchComplete(encryption_fetcher); | |
| 740 | |
| 741 VerifyAndFinishRequest(factory, | |
| 742 net::HTTP_OK, | |
| 743 kAuthenticateInstrumentValidRequest, | |
| 744 kAuthenticateInstrumentSuccessResponse); | |
| 745 } | |
| 746 | |
| 747 TEST_F(WalletClientTest, AuthenticateInstrumentFailed) { | |
| 748 MockWalletClientObserver observer; | |
| 749 EXPECT_CALL(observer, OnDidAuthenticateInstrument(false)).Times(1); | |
| 750 | |
| 751 net::TestURLFetcherFactory factory; | |
| 752 | |
| 753 WalletClient wallet_client(profile_.GetRequestContext()); | |
| 754 wallet_client.AuthenticateInstrument("instrument_id", | |
| 755 "cvv", | |
| 756 "obfuscated_gaia_id", | |
| 757 observer.AsWeakPtr()); | |
| 758 | |
| 759 net::TestURLFetcher* encryption_fetcher = factory.GetFetcherByID(1); | |
| 760 ASSERT_TRUE(encryption_fetcher); | |
| 761 encryption_fetcher->set_response_code(net::HTTP_OK); | |
| 762 encryption_fetcher->SetResponseString("escrow_handle"); | |
| 763 encryption_fetcher->delegate()->OnURLFetchComplete(encryption_fetcher); | |
| 764 | |
| 765 VerifyAndFinishRequest(factory, | |
| 766 net::HTTP_OK, | |
| 767 kAuthenticateInstrumentValidRequest, | |
| 768 kAuthenticateInstrumentFailureResponse); | |
| 769 } | |
| 770 | |
| 771 TEST_F(WalletClientTest, AuthenticateInstrumentEscrowDown) { | |
| 772 MockWalletClientObserver observer; | |
| 773 EXPECT_CALL(observer, | |
| 774 OnNetworkError(net::HTTP_INTERNAL_SERVER_ERROR)).Times(1); | |
| 775 | |
| 776 net::TestURLFetcherFactory factory; | |
| 777 | |
| 778 WalletClient wallet_client(profile_.GetRequestContext()); | |
| 779 wallet_client.AuthenticateInstrument("instrument_id", | |
| 780 "cvv", | |
| 781 "obfuscated_gaia_id", | |
| 782 observer.AsWeakPtr()); | |
| 783 | |
| 784 net::TestURLFetcher* encryption_fetcher = factory.GetFetcherByID(1); | |
| 785 ASSERT_TRUE(encryption_fetcher); | |
| 786 encryption_fetcher->set_response_code(net::HTTP_INTERNAL_SERVER_ERROR); | |
| 787 encryption_fetcher->delegate()->OnURLFetchComplete(encryption_fetcher); | |
| 788 } | |
| 789 | |
| 790 TEST_F(WalletClientTest, AuthenticateInstrumentEscrowMalformed) { | |
| 791 MockWalletClientObserver observer; | |
| 792 EXPECT_CALL(observer, OnMalformedResponse()).Times(1); | |
| 793 | |
| 794 net::TestURLFetcherFactory factory; | |
| 795 | |
| 796 WalletClient wallet_client(profile_.GetRequestContext()); | |
| 797 wallet_client.AuthenticateInstrument("instrument_id", | |
| 798 "cvv", | |
| 799 "obfuscated_gaia_id", | |
| 800 observer.AsWeakPtr()); | |
| 801 | |
| 802 net::TestURLFetcher* encryption_fetcher = factory.GetFetcherByID(1); | |
| 803 ASSERT_TRUE(encryption_fetcher); | |
| 804 encryption_fetcher->set_response_code(net::HTTP_OK); | |
| 805 encryption_fetcher->delegate()->OnURLFetchComplete(encryption_fetcher); | |
| 806 } | |
| 807 | |
| 808 TEST_F(WalletClientTest, AuthenticateInstrumentFailedMalformedResponse) { | |
| 809 MockWalletClientObserver observer; | |
| 810 EXPECT_CALL(observer, OnMalformedResponse()).Times(1); | |
| 811 | |
| 812 net::TestURLFetcherFactory factory; | |
| 813 | |
| 814 WalletClient wallet_client(profile_.GetRequestContext()); | |
| 815 wallet_client.AuthenticateInstrument("instrument_id", | |
| 816 "cvv", | |
| 817 "obfuscated_gaia_id", | |
| 818 observer.AsWeakPtr()); | |
| 819 | |
| 820 net::TestURLFetcher* encryption_fetcher = factory.GetFetcherByID(1); | |
| 821 ASSERT_TRUE(encryption_fetcher); | |
| 822 encryption_fetcher->set_response_code(net::HTTP_OK); | |
| 823 encryption_fetcher->SetResponseString("escrow_handle"); | |
| 824 encryption_fetcher->delegate()->OnURLFetchComplete(encryption_fetcher); | |
| 825 | |
| 826 VerifyAndFinishRequest(factory, | |
| 827 net::HTTP_OK, | |
| 828 kAuthenticateInstrumentValidRequest, | |
| 829 kSaveInvalidResponse); | |
| 830 } | |
| 831 | |
| 832 // TODO(ahutter): Add failure tests for GetWalletItems. | |
| 833 | |
| 834 TEST_F(WalletClientTest, GetWalletItems) { | |
| 835 MockWalletClientObserver observer; | |
| 836 net::TestURLFetcherFactory factory; | |
| 837 | |
| 838 WalletClient wallet_client(profile_.GetRequestContext()); | |
| 839 wallet_client.GetWalletItems(GURL(kMerchantUrl), observer.AsWeakPtr()); | |
| 840 net::TestURLFetcher* fetcher = factory.GetFetcherByID(0); | |
| 841 ASSERT_TRUE(fetcher); | |
| 842 EXPECT_EQ(kGetWalletItemsValidRequest, GetData(fetcher)); | |
| 843 fetcher->set_response_code(net::HTTP_OK); | |
| 844 fetcher->SetResponseString(kGetWalletItemsValidResponse); | |
| 845 fetcher->delegate()->OnURLFetchComplete(fetcher); | |
| 846 | |
| 847 EXPECT_EQ(1U, observer.wallet_items_received()); | |
| 848 } | |
| 849 | |
| 850 TEST_F(WalletClientTest, SaveAddressSucceeded) { | |
| 851 MockWalletClientObserver observer; | |
| 852 EXPECT_CALL(observer, | |
| 853 OnDidSaveAddress("shipping_address_id", | |
| 854 std::vector<RequiredAction>())).Times(1); | |
| 855 | |
| 856 net::TestURLFetcherFactory factory; | |
| 857 | |
| 858 scoped_ptr<Address> address = GetTestShippingAddress(); | |
| 859 | |
| 860 WalletClient wallet_client(profile_.GetRequestContext()); | |
| 861 wallet_client.SaveAddress(*address, GURL(kMerchantUrl), observer.AsWeakPtr()); | |
| 862 VerifyAndFinishRequest(factory, | |
| 863 net::HTTP_OK, | |
| 864 kSaveAddressValidRequest, | |
| 865 kSaveAddressValidResponse); | |
| 866 } | |
| 867 | |
| 868 TEST_F(WalletClientTest, SaveAddressWithRequiredActionsSucceeded) { | |
| 869 MockWalletClientObserver observer; | |
| 870 | |
| 871 std::vector<RequiredAction> required_actions; | |
| 872 required_actions.push_back(REQUIRE_PHONE_NUMBER); | |
| 873 required_actions.push_back(INVALID_FORM_FIELD); | |
| 874 | |
| 875 EXPECT_CALL(observer, | |
| 876 OnDidSaveAddress(std::string(), | |
| 877 required_actions)).Times(1); | |
| 878 | |
| 879 net::TestURLFetcherFactory factory; | |
| 880 | |
| 881 scoped_ptr<Address> address = GetTestShippingAddress(); | |
| 882 | |
| 883 WalletClient wallet_client(profile_.GetRequestContext()); | |
| 884 wallet_client.SaveAddress(*address, GURL(kMerchantUrl), observer.AsWeakPtr()); | |
| 885 VerifyAndFinishRequest(factory, | |
| 886 net::HTTP_OK, | |
| 887 kSaveAddressValidRequest, | |
| 888 kSaveAddressWithRequiredActionsValidResponse); | |
| 889 } | |
| 890 | |
| 891 TEST_F(WalletClientTest, SaveAddressFailedInvalidRequiredAction) { | |
| 892 MockWalletClientObserver observer; | |
| 893 EXPECT_CALL(observer, OnMalformedResponse()).Times(1); | |
| 894 | |
| 895 net::TestURLFetcherFactory factory; | |
| 896 | |
| 897 scoped_ptr<Address> address = GetTestShippingAddress(); | |
| 898 | |
| 899 WalletClient wallet_client(profile_.GetRequestContext()); | |
| 900 wallet_client.SaveAddress(*address, GURL(kMerchantUrl), observer.AsWeakPtr()); | |
| 901 VerifyAndFinishRequest(factory, | |
| 902 net::HTTP_OK, | |
| 903 kSaveAddressValidRequest, | |
| 904 kSaveWithInvalidRequiredActionsResponse); | |
| 905 } | |
| 906 | |
| 907 TEST_F(WalletClientTest, SaveAddressFailedMalformedResponse) { | |
| 908 MockWalletClientObserver observer; | |
| 909 EXPECT_CALL(observer, OnMalformedResponse()).Times(1); | |
| 910 | |
| 911 net::TestURLFetcherFactory factory; | |
| 912 | |
| 913 scoped_ptr<Address> address = GetTestShippingAddress(); | |
| 914 | |
| 915 WalletClient wallet_client(profile_.GetRequestContext()); | |
| 916 wallet_client.SaveAddress(*address, GURL(kMerchantUrl), observer.AsWeakPtr()); | |
| 917 VerifyAndFinishRequest(factory, | |
| 918 net::HTTP_OK, | |
| 919 kSaveAddressValidRequest, | |
| 920 kSaveInvalidResponse); | |
| 921 } | |
| 922 | |
| 923 TEST_F(WalletClientTest, SaveInstrumentSucceeded) { | |
| 924 MockWalletClientObserver observer; | |
| 925 EXPECT_CALL(observer, | |
| 926 OnDidSaveInstrument("instrument_id", | |
| 927 std::vector<RequiredAction>())).Times(1); | |
| 928 | |
| 929 net::TestURLFetcherFactory factory; | |
| 930 | |
| 931 scoped_ptr<Instrument> instrument = GetTestInstrument(); | |
| 932 | |
| 933 WalletClient wallet_client(profile_.GetRequestContext()); | |
| 934 wallet_client.SaveInstrument(*instrument, | |
| 935 "obfuscated_gaia_id", | |
| 936 GURL(kMerchantUrl), | |
| 937 observer.AsWeakPtr()); | |
| 938 | |
| 939 net::TestURLFetcher* encryption_fetcher = factory.GetFetcherByID(1); | |
| 940 ASSERT_TRUE(encryption_fetcher); | |
| 941 encryption_fetcher->set_response_code(net::HTTP_OK); | |
| 942 encryption_fetcher->SetResponseString("escrow_handle"); | |
| 943 encryption_fetcher->delegate()->OnURLFetchComplete(encryption_fetcher); | |
| 944 | |
| 945 VerifyAndFinishRequest(factory, | |
| 946 net::HTTP_OK, | |
| 947 kSaveInstrumentValidRequest, | |
| 948 kSaveInstrumentValidResponse); | |
| 949 } | |
| 950 | |
| 951 TEST_F(WalletClientTest, SaveInstrumentWithRequiredActionsSucceeded) { | |
| 952 MockWalletClientObserver observer; | |
| 953 | |
| 954 std::vector<RequiredAction> required_actions; | |
| 955 required_actions.push_back(REQUIRE_PHONE_NUMBER); | |
| 956 required_actions.push_back(INVALID_FORM_FIELD); | |
| 957 | |
| 958 EXPECT_CALL(observer, | |
| 959 OnDidSaveInstrument(std::string(), | |
| 960 required_actions)).Times(1); | |
| 961 | |
| 962 net::TestURLFetcherFactory factory; | |
| 963 | |
| 964 scoped_ptr<Instrument> instrument = GetTestInstrument(); | |
| 965 | |
| 966 WalletClient wallet_client(profile_.GetRequestContext()); | |
| 967 wallet_client.SaveInstrument(*instrument, | |
| 968 "obfuscated_gaia_id", | |
| 969 GURL(kMerchantUrl), | |
| 970 observer.AsWeakPtr()); | |
| 971 | |
| 972 net::TestURLFetcher* encryption_fetcher = factory.GetFetcherByID(1); | |
| 973 ASSERT_TRUE(encryption_fetcher); | |
| 974 encryption_fetcher->set_response_code(net::HTTP_OK); | |
| 975 encryption_fetcher->SetResponseString("escrow_handle"); | |
| 976 encryption_fetcher->delegate()->OnURLFetchComplete(encryption_fetcher); | |
| 977 | |
| 978 VerifyAndFinishRequest(factory, | |
| 979 net::HTTP_OK, | |
| 980 kSaveInstrumentValidRequest, | |
| 981 kSaveInstrumentWithRequiredActionsValidResponse); | |
| 982 } | |
| 983 | |
| 984 TEST_F(WalletClientTest, SaveInstrumentFailedInvalidRequiredActions) { | |
| 985 MockWalletClientObserver observer; | |
| 986 | |
| 987 EXPECT_CALL(observer, OnMalformedResponse()); | |
| 988 | |
| 989 net::TestURLFetcherFactory factory; | |
| 990 | |
| 991 scoped_ptr<Instrument> instrument = GetTestInstrument(); | |
| 992 | |
| 993 WalletClient wallet_client(profile_.GetRequestContext()); | |
| 994 wallet_client.SaveInstrument(*instrument, | |
| 995 "obfuscated_gaia_id", | |
| 996 GURL(kMerchantUrl), | |
| 997 observer.AsWeakPtr()); | |
| 998 | |
| 999 net::TestURLFetcher* encryption_fetcher = factory.GetFetcherByID(1); | |
| 1000 ASSERT_TRUE(encryption_fetcher); | |
| 1001 encryption_fetcher->set_response_code(net::HTTP_OK); | |
| 1002 encryption_fetcher->SetResponseString("escrow_handle"); | |
| 1003 encryption_fetcher->delegate()->OnURLFetchComplete(encryption_fetcher); | |
| 1004 | |
| 1005 VerifyAndFinishRequest(factory, | |
| 1006 net::HTTP_OK, | |
| 1007 kSaveInstrumentValidRequest, | |
| 1008 kSaveWithInvalidRequiredActionsResponse); | |
| 1009 } | |
| 1010 | |
| 1011 TEST_F(WalletClientTest, SaveInstrumentEscrowDown) { | |
| 1012 MockWalletClientObserver observer; | |
| 1013 EXPECT_CALL(observer, | |
| 1014 OnNetworkError(net::HTTP_INTERNAL_SERVER_ERROR)).Times(1); | |
| 1015 | |
| 1016 net::TestURLFetcherFactory factory; | |
| 1017 | |
| 1018 scoped_ptr<Instrument> instrument = GetTestInstrument(); | |
| 1019 | |
| 1020 WalletClient wallet_client(profile_.GetRequestContext()); | |
| 1021 wallet_client.SaveInstrument(*instrument, | |
| 1022 "obfuscated_gaia_id", | |
| 1023 GURL(kMerchantUrl), | |
| 1024 observer.AsWeakPtr()); | |
| 1025 | |
| 1026 net::TestURLFetcher* encryption_fetcher = factory.GetFetcherByID(1); | |
| 1027 ASSERT_TRUE(encryption_fetcher); | |
| 1028 encryption_fetcher->set_response_code(net::HTTP_INTERNAL_SERVER_ERROR); | |
| 1029 encryption_fetcher->SetResponseString(std::string()); | |
| 1030 encryption_fetcher->delegate()->OnURLFetchComplete(encryption_fetcher); | |
| 1031 } | |
| 1032 | |
| 1033 TEST_F(WalletClientTest, SaveInstrumentEscrowMalformed) { | |
| 1034 MockWalletClientObserver observer; | |
| 1035 EXPECT_CALL(observer, OnMalformedResponse()).Times(1); | |
| 1036 | |
| 1037 net::TestURLFetcherFactory factory; | |
| 1038 | |
| 1039 scoped_ptr<Instrument> instrument = GetTestInstrument(); | |
| 1040 | |
| 1041 WalletClient wallet_client(profile_.GetRequestContext()); | |
| 1042 wallet_client.SaveInstrument(*instrument, | |
| 1043 "obfuscated_gaia_id", | |
| 1044 GURL(kMerchantUrl), | |
| 1045 observer.AsWeakPtr()); | |
| 1046 | |
| 1047 net::TestURLFetcher* encryption_fetcher = factory.GetFetcherByID(1); | |
| 1048 ASSERT_TRUE(encryption_fetcher); | |
| 1049 encryption_fetcher->set_response_code(net::HTTP_OK); | |
| 1050 encryption_fetcher->SetResponseString(std::string()); | |
| 1051 encryption_fetcher->delegate()->OnURLFetchComplete(encryption_fetcher); | |
| 1052 } | |
| 1053 | |
| 1054 TEST_F(WalletClientTest, SaveInstrumentFailedMalformedResponse) { | |
| 1055 MockWalletClientObserver observer; | |
| 1056 EXPECT_CALL(observer, OnMalformedResponse()).Times(1); | |
| 1057 | |
| 1058 net::TestURLFetcherFactory factory; | |
| 1059 | |
| 1060 scoped_ptr<Instrument> instrument = GetTestInstrument(); | |
| 1061 | |
| 1062 WalletClient wallet_client(profile_.GetRequestContext()); | |
| 1063 wallet_client.SaveInstrument(*instrument, | |
| 1064 "obfuscated_gaia_id", | |
| 1065 GURL(kMerchantUrl), | |
| 1066 observer.AsWeakPtr()); | |
| 1067 | |
| 1068 net::TestURLFetcher* encryption_fetcher = factory.GetFetcherByID(1); | |
| 1069 ASSERT_TRUE(encryption_fetcher); | |
| 1070 encryption_fetcher->set_response_code(net::HTTP_OK); | |
| 1071 encryption_fetcher->SetResponseString("escrow_handle"); | |
| 1072 encryption_fetcher->delegate()->OnURLFetchComplete(encryption_fetcher); | |
| 1073 | |
| 1074 VerifyAndFinishRequest(factory, | |
| 1075 net::HTTP_OK, | |
| 1076 kSaveInstrumentValidRequest, | |
| 1077 kSaveInvalidResponse); | |
| 1078 } | |
| 1079 | |
| 1080 TEST_F(WalletClientTest, SaveInstrumentAndAddressSucceeded) { | |
| 1081 MockWalletClientObserver observer; | |
| 1082 EXPECT_CALL(observer, | |
| 1083 OnDidSaveInstrumentAndAddress( | |
| 1084 "instrument_id", | |
| 1085 "shipping_address_id", | |
| 1086 std::vector<RequiredAction>())).Times(1); | |
| 1087 | |
| 1088 net::TestURLFetcherFactory factory; | |
| 1089 | |
| 1090 scoped_ptr<Instrument> instrument = GetTestInstrument(); | |
| 1091 | |
| 1092 scoped_ptr<Address> address = GetTestShippingAddress(); | |
| 1093 | |
| 1094 WalletClient wallet_client(profile_.GetRequestContext()); | |
| 1095 wallet_client.SaveInstrumentAndAddress(*instrument, | |
| 1096 *address, | |
| 1097 "obfuscated_gaia_id", | |
| 1098 GURL(kMerchantUrl), | |
| 1099 observer.AsWeakPtr()); | |
| 1100 | |
| 1101 net::TestURLFetcher* encryption_fetcher = factory.GetFetcherByID(1); | |
| 1102 ASSERT_TRUE(encryption_fetcher); | |
| 1103 encryption_fetcher->set_response_code(net::HTTP_OK); | |
| 1104 encryption_fetcher->SetResponseString("escrow_handle"); | |
| 1105 encryption_fetcher->delegate()->OnURLFetchComplete(encryption_fetcher); | |
| 1106 VerifyAndFinishRequest(factory, | |
| 1107 net::HTTP_OK, | |
| 1108 kSaveInstrumentAndAddressValidRequest, | |
| 1109 kSaveInstrumentAndAddressValidResponse); | |
| 1110 } | |
| 1111 | |
| 1112 TEST_F(WalletClientTest, SaveInstrumentAndAddressWithRequiredActionsSucceeded) { | |
| 1113 MockWalletClientObserver observer; | |
| 1114 | |
| 1115 std::vector<RequiredAction> required_actions; | |
| 1116 required_actions.push_back(REQUIRE_PHONE_NUMBER); | |
| 1117 required_actions.push_back(INVALID_FORM_FIELD); | |
| 1118 | |
| 1119 EXPECT_CALL(observer, | |
| 1120 OnDidSaveInstrumentAndAddress( | |
| 1121 std::string(), | |
| 1122 std::string(), | |
| 1123 required_actions)).Times(1); | |
| 1124 | |
| 1125 net::TestURLFetcherFactory factory; | |
| 1126 | |
| 1127 scoped_ptr<Instrument> instrument = GetTestInstrument(); | |
| 1128 | |
| 1129 scoped_ptr<Address> address = GetTestShippingAddress(); | |
| 1130 | |
| 1131 WalletClient wallet_client(profile_.GetRequestContext()); | |
| 1132 wallet_client.SaveInstrumentAndAddress(*instrument, | |
| 1133 *address, | |
| 1134 "obfuscated_gaia_id", | |
| 1135 GURL(kMerchantUrl), | |
| 1136 observer.AsWeakPtr()); | |
| 1137 | |
| 1138 net::TestURLFetcher* encryption_fetcher = factory.GetFetcherByID(1); | |
| 1139 ASSERT_TRUE(encryption_fetcher); | |
| 1140 encryption_fetcher->set_response_code(net::HTTP_OK); | |
| 1141 encryption_fetcher->SetResponseString("escrow_handle"); | |
| 1142 encryption_fetcher->delegate()->OnURLFetchComplete(encryption_fetcher); | |
| 1143 VerifyAndFinishRequest( | |
| 1144 factory, | |
| 1145 net::HTTP_OK, | |
| 1146 kSaveInstrumentAndAddressValidRequest, | |
| 1147 kSaveInstrumentAndAddressWithRequiredActionsValidResponse); | |
| 1148 } | |
| 1149 | |
| 1150 TEST_F(WalletClientTest, SaveInstrumentAndAddressFailedInvalidRequiredAction) { | |
| 1151 MockWalletClientObserver observer; | |
| 1152 EXPECT_CALL(observer, OnMalformedResponse()).Times(1); | |
| 1153 | |
| 1154 net::TestURLFetcherFactory factory; | |
| 1155 | |
| 1156 scoped_ptr<Instrument> instrument = GetTestInstrument(); | |
| 1157 | |
| 1158 scoped_ptr<Address> address = GetTestShippingAddress(); | |
| 1159 | |
| 1160 WalletClient wallet_client(profile_.GetRequestContext()); | |
| 1161 wallet_client.SaveInstrumentAndAddress(*instrument, | |
| 1162 *address, | |
| 1163 "obfuscated_gaia_id", | |
| 1164 GURL(kMerchantUrl), | |
| 1165 observer.AsWeakPtr()); | |
| 1166 | |
| 1167 net::TestURLFetcher* encryption_fetcher = factory.GetFetcherByID(1); | |
| 1168 ASSERT_TRUE(encryption_fetcher); | |
| 1169 encryption_fetcher->set_response_code(net::HTTP_OK); | |
| 1170 encryption_fetcher->SetResponseString("escrow_handle"); | |
| 1171 encryption_fetcher->delegate()->OnURLFetchComplete(encryption_fetcher); | |
| 1172 | |
| 1173 VerifyAndFinishRequest(factory, | |
| 1174 net::HTTP_OK, | |
| 1175 kSaveInstrumentAndAddressValidRequest, | |
| 1176 kSaveWithInvalidRequiredActionsResponse); | |
| 1177 } | |
| 1178 | |
| 1179 TEST_F(WalletClientTest, SaveInstrumentAndAddressEscrowDown) { | |
| 1180 MockWalletClientObserver observer; | |
| 1181 EXPECT_CALL(observer, | |
| 1182 OnNetworkError(net::HTTP_INTERNAL_SERVER_ERROR)).Times(1); | |
| 1183 | |
| 1184 net::TestURLFetcherFactory factory; | |
| 1185 | |
| 1186 scoped_ptr<Instrument> instrument = GetTestInstrument(); | |
| 1187 | |
| 1188 scoped_ptr<Address> address = GetTestShippingAddress(); | |
| 1189 | |
| 1190 WalletClient wallet_client(profile_.GetRequestContext()); | |
| 1191 wallet_client.SaveInstrumentAndAddress(*instrument, | |
| 1192 *address, | |
| 1193 "obfuscated_gaia_id", | |
| 1194 GURL(kMerchantUrl), | |
| 1195 observer.AsWeakPtr()); | |
| 1196 | |
| 1197 net::TestURLFetcher* encryption_fetcher = factory.GetFetcherByID(1); | |
| 1198 ASSERT_TRUE(encryption_fetcher); | |
| 1199 encryption_fetcher->set_response_code(net::HTTP_INTERNAL_SERVER_ERROR); | |
| 1200 encryption_fetcher->SetResponseString(std::string()); | |
| 1201 encryption_fetcher->delegate()->OnURLFetchComplete(encryption_fetcher); | |
| 1202 } | |
| 1203 | |
| 1204 TEST_F(WalletClientTest, SaveInstrumentAndAddressEscrowMalformed) { | |
| 1205 MockWalletClientObserver observer; | |
| 1206 EXPECT_CALL(observer, OnMalformedResponse()).Times(1); | |
| 1207 | |
| 1208 net::TestURLFetcherFactory factory; | |
| 1209 | |
| 1210 scoped_ptr<Instrument> instrument = GetTestInstrument(); | |
| 1211 | |
| 1212 scoped_ptr<Address> address = GetTestShippingAddress(); | |
| 1213 | |
| 1214 WalletClient wallet_client(profile_.GetRequestContext()); | |
| 1215 wallet_client.SaveInstrumentAndAddress(*instrument, | |
| 1216 *address, | |
| 1217 "obfuscated_gaia_id", | |
| 1218 GURL(kMerchantUrl), | |
| 1219 observer.AsWeakPtr()); | |
| 1220 | |
| 1221 net::TestURLFetcher* encryption_fetcher = factory.GetFetcherByID(1); | |
| 1222 ASSERT_TRUE(encryption_fetcher); | |
| 1223 encryption_fetcher->set_response_code(net::HTTP_OK); | |
| 1224 encryption_fetcher->SetResponseString(std::string()); | |
| 1225 encryption_fetcher->delegate()->OnURLFetchComplete(encryption_fetcher); | |
| 1226 } | |
| 1227 | |
| 1228 TEST_F(WalletClientTest, SaveInstrumentAndAddressFailedAddressMissing) { | |
| 1229 MockWalletClientObserver observer; | |
| 1230 EXPECT_CALL(observer, OnMalformedResponse()).Times(1); | |
| 1231 | |
| 1232 net::TestURLFetcherFactory factory; | |
| 1233 | |
| 1234 scoped_ptr<Instrument> instrument = GetTestInstrument(); | |
| 1235 | |
| 1236 scoped_ptr<Address> address = GetTestShippingAddress(); | |
| 1237 | |
| 1238 WalletClient wallet_client(profile_.GetRequestContext()); | |
| 1239 wallet_client.SaveInstrumentAndAddress(*instrument, | |
| 1240 *address, | |
| 1241 "obfuscated_gaia_id", | |
| 1242 GURL(kMerchantUrl), | |
| 1243 observer.AsWeakPtr()); | |
| 1244 | |
| 1245 net::TestURLFetcher* encryption_fetcher = factory.GetFetcherByID(1); | |
| 1246 ASSERT_TRUE(encryption_fetcher); | |
| 1247 encryption_fetcher->set_response_code(net::HTTP_OK); | |
| 1248 encryption_fetcher->SetResponseString("escrow_handle"); | |
| 1249 encryption_fetcher->delegate()->OnURLFetchComplete(encryption_fetcher); | |
| 1250 | |
| 1251 VerifyAndFinishRequest(factory, | |
| 1252 net::HTTP_OK, | |
| 1253 kSaveInstrumentAndAddressValidRequest, | |
| 1254 kSaveInstrumentAndAddressMissingAddressResponse); | |
| 1255 } | |
| 1256 | |
| 1257 TEST_F(WalletClientTest, SaveInstrumentAndAddressFailedInstrumentMissing) { | |
| 1258 MockWalletClientObserver observer; | |
| 1259 EXPECT_CALL(observer, OnMalformedResponse()).Times(1); | |
| 1260 | |
| 1261 net::TestURLFetcherFactory factory; | |
| 1262 | |
| 1263 scoped_ptr<Instrument> instrument = GetTestInstrument(); | |
| 1264 | |
| 1265 scoped_ptr<Address> address = GetTestShippingAddress(); | |
| 1266 | |
| 1267 WalletClient wallet_client(profile_.GetRequestContext()); | |
| 1268 wallet_client.SaveInstrumentAndAddress(*instrument, | |
| 1269 *address, | |
| 1270 "obfuscated_gaia_id", | |
| 1271 GURL(kMerchantUrl), | |
| 1272 observer.AsWeakPtr()); | |
| 1273 | |
| 1274 net::TestURLFetcher* encryption_fetcher = factory.GetFetcherByID(1); | |
| 1275 ASSERT_TRUE(encryption_fetcher); | |
| 1276 encryption_fetcher->set_response_code(net::HTTP_OK); | |
| 1277 encryption_fetcher->SetResponseString("escrow_handle"); | |
| 1278 encryption_fetcher->delegate()->OnURLFetchComplete(encryption_fetcher); | |
| 1279 | |
| 1280 VerifyAndFinishRequest(factory, | |
| 1281 net::HTTP_OK, | |
| 1282 kSaveInstrumentAndAddressValidRequest, | |
| 1283 kSaveInstrumentAndAddressMissingInstrumentResponse); | |
| 1284 } | |
| 1285 | |
| 1286 TEST_F(WalletClientTest, UpdateInstrumentSucceeded) { | |
| 1287 MockWalletClientObserver observer; | |
| 1288 EXPECT_CALL(observer, | |
| 1289 OnDidUpdateInstrument("instrument_id", | |
| 1290 std::vector<RequiredAction>())).Times(1); | |
| 1291 | |
| 1292 net::TestURLFetcherFactory factory; | |
| 1293 | |
| 1294 scoped_ptr<Address> address = GetTestAddress(); | |
| 1295 | |
| 1296 WalletClient wallet_client(profile_.GetRequestContext()); | |
| 1297 wallet_client.UpdateInstrument("instrument_id", | |
| 1298 *address, | |
| 1299 GURL(kMerchantUrl), | |
| 1300 observer.AsWeakPtr()); | |
| 1301 VerifyAndFinishRequest(factory, | |
| 1302 net::HTTP_OK, | |
| 1303 kUpdateInstrumentValidRequest, | |
| 1304 kUpdateInstrumentValidResponse); | |
| 1305 } | |
| 1306 | |
| 1307 TEST_F(WalletClientTest, UpdateInstrumentWithRequiredActionsSucceeded) { | |
| 1308 MockWalletClientObserver observer; | |
| 1309 | |
| 1310 std::vector<RequiredAction> required_actions; | |
| 1311 required_actions.push_back(REQUIRE_PHONE_NUMBER); | |
| 1312 required_actions.push_back(INVALID_FORM_FIELD); | |
| 1313 | |
| 1314 EXPECT_CALL(observer, | |
| 1315 OnDidUpdateInstrument(std::string(), | |
| 1316 required_actions)).Times(1); | |
| 1317 | |
| 1318 net::TestURLFetcherFactory factory; | |
| 1319 | |
| 1320 scoped_ptr<Address> address = GetTestAddress(); | |
| 1321 | |
| 1322 WalletClient wallet_client(profile_.GetRequestContext()); | |
| 1323 wallet_client.UpdateInstrument("instrument_id", | |
| 1324 *address, | |
| 1325 GURL(kMerchantUrl), | |
| 1326 observer.AsWeakPtr()); | |
| 1327 VerifyAndFinishRequest(factory, | |
| 1328 net::HTTP_OK, | |
| 1329 kUpdateInstrumentValidRequest, | |
| 1330 kUpdateInstrumentWithRequiredActionsValidResponse); | |
| 1331 } | |
| 1332 | |
| 1333 TEST_F(WalletClientTest, UpdateInstrumentFailedInvalidRequiredAction) { | |
| 1334 MockWalletClientObserver observer; | |
| 1335 EXPECT_CALL(observer, OnMalformedResponse()).Times(1); | |
| 1336 | |
| 1337 net::TestURLFetcherFactory factory; | |
| 1338 | |
| 1339 scoped_ptr<Address> address = GetTestAddress(); | |
| 1340 | |
| 1341 WalletClient wallet_client(profile_.GetRequestContext()); | |
| 1342 wallet_client.UpdateInstrument("instrument_id", | |
| 1343 *address, | |
| 1344 GURL(kMerchantUrl), | |
| 1345 observer.AsWeakPtr()); | |
| 1346 VerifyAndFinishRequest(factory, | |
| 1347 net::HTTP_OK, | |
| 1348 kUpdateInstrumentValidRequest, | |
| 1349 kSaveWithInvalidRequiredActionsResponse); | |
| 1350 } | |
| 1351 | |
| 1352 TEST_F(WalletClientTest, UpdateInstrumentMalformedResponse) { | |
| 1353 MockWalletClientObserver observer; | |
| 1354 EXPECT_CALL(observer, OnMalformedResponse()).Times(1); | |
| 1355 | |
| 1356 net::TestURLFetcherFactory factory; | |
| 1357 | |
| 1358 scoped_ptr<Address> address = GetTestAddress(); | |
| 1359 | |
| 1360 WalletClient wallet_client(profile_.GetRequestContext()); | |
| 1361 wallet_client.UpdateInstrument("instrument_id", | |
| 1362 *address, | |
| 1363 GURL(kMerchantUrl), | |
| 1364 observer.AsWeakPtr()); | |
| 1365 VerifyAndFinishRequest(factory, | |
| 1366 net::HTTP_OK, | |
| 1367 kUpdateInstrumentValidRequest, | |
| 1368 kUpdateInstrumentMalformedResponse); | |
| 1369 } | |
| 1370 | |
| 1371 TEST_F(WalletClientTest, SendAutocheckoutOfStatusSuccess) { | |
| 1372 MockWalletClientObserver observer; | |
| 1373 EXPECT_CALL(observer, OnDidSendAutocheckoutStatus()).Times(1); | |
| 1374 | |
| 1375 net::TestURLFetcherFactory factory; | |
| 1376 | |
| 1377 WalletClient wallet_client(profile_.GetRequestContext()); | |
| 1378 wallet_client.SendAutocheckoutStatus(autofill::SUCCESS, | |
| 1379 GURL(kMerchantUrl), | |
| 1380 "google_transaction_id", | |
| 1381 observer.AsWeakPtr()); | |
| 1382 net::TestURLFetcher* fetcher = factory.GetFetcherByID(0); | |
| 1383 ASSERT_TRUE(fetcher); | |
| 1384 EXPECT_EQ(kSendAutocheckoutStatusOfSuccessValidRequest, GetData(fetcher)); | |
| 1385 fetcher->SetResponseString(")]}'"); // Invalid JSON. Should be ignored. | |
| 1386 fetcher->set_response_code(net::HTTP_OK); | |
| 1387 fetcher->delegate()->OnURLFetchComplete(fetcher); | |
| 1388 } | |
| 1389 | |
| 1390 TEST_F(WalletClientTest, SendAutocheckoutStatusOfFailure) { | |
| 1391 MockWalletClientObserver observer; | |
| 1392 EXPECT_CALL(observer, OnDidSendAutocheckoutStatus()).Times(1); | |
| 1393 | |
| 1394 net::TestURLFetcherFactory factory; | |
| 1395 | |
| 1396 WalletClient wallet_client(profile_.GetRequestContext()); | |
| 1397 wallet_client.SendAutocheckoutStatus(autofill::CANNOT_PROCEED, | |
| 1398 GURL(kMerchantUrl), | |
| 1399 "google_transaction_id", | |
| 1400 observer.AsWeakPtr()); | |
| 1401 net::TestURLFetcher* fetcher = factory.GetFetcherByID(0); | |
| 1402 ASSERT_TRUE(fetcher); | |
| 1403 EXPECT_EQ(kSendAutocheckoutStatusOfFailureValidRequest, GetData(fetcher)); | |
| 1404 fetcher->set_response_code(net::HTTP_OK); | |
| 1405 fetcher->SetResponseString(")]}'"); // Invalid JSON. Should be ignored. | |
| 1406 fetcher->delegate()->OnURLFetchComplete(fetcher); | |
| 1407 } | |
| 1408 | |
| 1409 TEST_F(WalletClientTest, HasRequestInProgress) { | |
| 1410 MockWalletClientObserver observer; | |
| 1411 net::TestURLFetcherFactory factory; | |
| 1412 | |
| 1413 WalletClient wallet_client(profile_.GetRequestContext()); | |
| 1414 EXPECT_FALSE(wallet_client.HasRequestInProgress()); | |
| 1415 | |
| 1416 wallet_client.GetWalletItems(GURL(kMerchantUrl), observer.AsWeakPtr()); | |
| 1417 EXPECT_TRUE(wallet_client.HasRequestInProgress()); | |
| 1418 | |
| 1419 net::TestURLFetcher* fetcher = factory.GetFetcherByID(0); | |
| 1420 ASSERT_TRUE(fetcher); | |
| 1421 fetcher->set_response_code(net::HTTP_OK); | |
| 1422 fetcher->SetResponseString(kGetWalletItemsValidResponse); | |
| 1423 fetcher->delegate()->OnURLFetchComplete(fetcher); | |
| 1424 EXPECT_FALSE(wallet_client.HasRequestInProgress()); | |
| 1425 } | |
| 1426 | |
| 1427 } // namespace wallet | |
| 1428 } // namespace autofill | |
| OLD | NEW |