Home | History | Annotate | Download | only in wallet
      1 // Copyright 2013 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/command_line.h"
      6 #include "components/autofill/content/browser/wallet/wallet_service_url.h"
      7 #include "components/autofill/core/common/autofill_switches.h"
      8 #include "testing/gtest/include/gtest/gtest.h"
      9 #include "url/gurl.h"
     10 
     11 namespace autofill {
     12 namespace wallet {
     13 
     14 TEST(WalletServiceUrl, CheckDefaultUrls) {
     15   EXPECT_EQ("https://payments-form-dogfood.sandbox.google.com/online/v2/wallet/"
     16            "autocheckout/v1/getWalletItemsJwtless",
     17             GetGetWalletItemsUrl().spec());
     18   EXPECT_EQ("https://wallet-web.sandbox.google.com/online-secure/v2/"
     19             "autocheckout/v1/getFullWalletJwtless?s7e=otp",
     20             GetGetFullWalletUrl().spec());
     21   EXPECT_EQ("https://wallet-web.sandbox.google.com/manage/paymentMethods",
     22             GetManageInstrumentsUrl().spec());
     23   EXPECT_EQ("https://wallet-web.sandbox.google.com/manage/settings/addresses",
     24             GetManageAddressesUrl().spec());
     25   EXPECT_EQ("https://payments-form-dogfood.sandbox.google.com/online/v2/wallet/"
     26             "autocheckout/v1/acceptLegalDocument",
     27             GetAcceptLegalDocumentsUrl().spec());
     28   EXPECT_EQ("https://wallet-web.sandbox.google.com/online-secure/v2/"
     29             "autocheckout/v1/authenticateInstrument?s7e=cvn",
     30             GetAuthenticateInstrumentUrl().spec());
     31   EXPECT_EQ("https://payments-form-dogfood.sandbox.google.com/online/v2/wallet/"
     32             "autocheckout/v1/reportStatus",
     33             GetSendStatusUrl().spec());
     34   EXPECT_EQ("https://payments-form-dogfood.sandbox.google.com/online/v2/wallet/"
     35             "autocheckout/v1/saveToWallet",
     36             GetSaveToWalletNoEscrowUrl().spec());
     37   EXPECT_EQ("https://wallet-web.sandbox.google.com/online-secure/v2/"
     38             "autocheckout/v1/saveToWallet?s7e=card_number%3Bcvn",
     39             GetSaveToWalletUrl().spec());
     40   EXPECT_EQ("https://payments-form-dogfood.sandbox.google.com/online/v2/"
     41             "passiveauth?isChromePayments=true",
     42             GetPassiveAuthUrl().spec());
     43 }
     44 
     45 TEST(WalletServiceUrl, IsUsingProd) {
     46   // The sandbox servers are the default (for now). Update if this changes.
     47   EXPECT_FALSE(IsUsingProd());
     48 
     49   CommandLine* command_line = CommandLine::ForCurrentProcess();
     50   command_line->AppendSwitch(switches::kWalletServiceUseProd);
     51   EXPECT_TRUE(IsUsingProd());
     52 
     53   const GURL prod_get_items_url = GetGetWalletItemsUrl();
     54   command_line->AppendSwitchASCII(switches::kWalletServiceUrl, "http://goo.gl");
     55   EXPECT_FALSE(IsUsingProd());
     56 
     57   ASSERT_NE(prod_get_items_url, GetGetWalletItemsUrl());
     58 }
     59 
     60 }  // namespace wallet
     61 }  // namespace autofill
     62