chromium/components/autofill/core/browser/payments/credit_card_otp_authenticator_unittest.cc

// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/autofill/core/browser/payments/credit_card_otp_authenticator.h"

#include "base/memory/raw_ptr.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/task_environment.h"
#include "components/autofill/core/browser/autofill_test_utils.h"
#include "components/autofill/core/browser/data_model/credit_card.h"
#include "components/autofill/core/browser/metrics/payments/card_unmask_authentication_metrics.h"
#include "components/autofill/core/browser/payments/autofill_error_dialog_context.h"
#include "components/autofill/core/browser/payments/payments_autofill_client.h"
#include "components/autofill/core/browser/payments/test_authentication_requester.h"
#include "components/autofill/core/browser/payments/test_payments_autofill_client.h"
#include "components/autofill/core/browser/payments/test_payments_network_interface.h"
#include "components/autofill/core/browser/test_autofill_client.h"
#include "components/autofill/core/browser/test_autofill_driver.h"
#include "components/autofill/core/browser/test_personal_data_manager.h"
#include "components/prefs/pref_service.h"
#include "components/sync/test/test_sync_service.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace autofill {

namespace {
const char kTestChallengeId[] =;
const char kTestNumber[] =;
const char16_t kTestNumber16[] =;
const char16_t kMaskedPhoneNumber[] =;
const char16_t kMaskedEmailAddress[] =;
const int64_t kTestBillingCustomerNumber =;
}  // namespace

class CreditCardOtpAuthenticatorTestBase : public testing::Test {};

class CreditCardOtpAuthenticatorTest
    : public CreditCardOtpAuthenticatorTestBase,
      public testing::WithParamInterface<CardUnmaskChallengeOptionType> {};

TEST_P(CreditCardOtpAuthenticatorTest, AuthenticateServerCardSuccess) {}

TEST_P(CreditCardOtpAuthenticatorTest, SelectChallengeOptionFailsWithVcnError) {}

TEST_P(CreditCardOtpAuthenticatorTest,
       SelectChallengeOptionFailsWithOtherErrors) {}

TEST_P(CreditCardOtpAuthenticatorTest, OtpAuthServerVcnError) {}

TEST_P(CreditCardOtpAuthenticatorTest, OtpAuthServerNonVcnError) {}

TEST_P(CreditCardOtpAuthenticatorTest, OtpAuthMismatchThenRetry) {}

TEST_P(CreditCardOtpAuthenticatorTest, OtpAuthExpiredThenResendOtp) {}

TEST_P(CreditCardOtpAuthenticatorTest, OtpAuthCancelled) {}

INSTANTIATE_TEST_SUITE_P();

// Params of the CreditCardOtpAuthenticatorCardMetadataTest:
// -- bool card_name_available;
// -- bool card_art_available;
// -- bool metadata_enabled;
class CreditCardOtpAuthenticatorCardMetadataTest
    : public CreditCardOtpAuthenticatorTestBase,
      public testing::WithParamInterface<std::tuple<bool, bool, bool>> {};

INSTANTIATE_TEST_SUITE_P();

TEST_P(CreditCardOtpAuthenticatorCardMetadataTest, MetadataSignal) {}

// Params:
// 1. Function reference to call which creates the appropriate credit card
// benefit for the unittest.
// 2. Whether the flag to render benefits is enabled.
// 3. Issuer ID which is set for the credit card with benefits.
class CreditCardOtpAuthenticatorCardBenefitsTest
    : public CreditCardOtpAuthenticatorTestBase,
      public ::testing::WithParamInterface<
          std::tuple<base::FunctionRef<CreditCardBenefit()>,
                     bool,
                     std::string>> {};

INSTANTIATE_TEST_SUITE_P();

// Checks that ClientBehaviorConstants::kShowingCardBenefits is populated as a
// signal if a card benefit was shown when unmasking a credit card suggestion
// through the OTP authenticator.
TEST_P(CreditCardOtpAuthenticatorCardBenefitsTest,
       Benefits_ClientsBehaviorConstant) {}

}  // namespace autofill