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

// Copyright 2023 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_risk_based_authenticator.h"

#include <memory>

#include "base/strings/utf_string_conversions.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/payments_autofill_client.h"
#include "components/autofill/core/browser/payments/test_authentication_requester.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_personal_data_manager.h"
#include "components/sync/test/test_sync_service.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace autofill {

namespace {
constexpr std::string_view kTestNumber =;
// Base64 encoding of "This is a test challenge".
constexpr std::string_view kTestChallenge =;
// Base64 encoding of "This is a test Credential ID".
constexpr std::string_view kCredentialId =;
constexpr std::string_view kGooglePaymentsRpid =;
}  // namespace

class CreditCardRiskBasedAuthenticatorTest : public testing::Test {};

// Ensure the UnmaskRequestDetails is populated with the correct contents when
// we initiate a risk based authentication flow.
TEST_F(CreditCardRiskBasedAuthenticatorTest, UnmaskRequestSetCorrectly) {}

// Ensures that ServerCard authentication attempts are logged correctly.
TEST_F(CreditCardRiskBasedAuthenticatorTest,
       AuthServerCardAttemptLoggedCorrectly) {}

// Ensures the ServerCard authentication latency is logged correctly.
TEST_F(CreditCardRiskBasedAuthenticatorTest,
       AuthServerCardLatencyLoggedCorrectly) {}

// Test that risk-based authentication returns the full PAN upon success.
TEST_F(CreditCardRiskBasedAuthenticatorTest, AuthenticateServerCardSuccess) {}

// Test that risk-based authentication doesn't return the full PAN when the
// server call fails.
TEST_F(CreditCardRiskBasedAuthenticatorTest, AuthenticateServerCardFailure) {}

// Test that the requester receives `kAuthenticationCancelled` response when the
// risk-based authentication was cancelled.
TEST_F(CreditCardRiskBasedAuthenticatorTest, AuthenticateServerCardCancelled) {}

// Test that risk-based authentication determines authentication is required
// when the server call succeeds and the PAN is not returned.
TEST_F(CreditCardRiskBasedAuthenticatorTest,
       AuthenticateServerCardSuccess_PanNotReturned) {}

// Test that risk-based authentication determines authentication is required
// when the server call succeeds and the `fido_request_options` is returned.
TEST_F(CreditCardRiskBasedAuthenticatorTest,
       AuthenticateServerCardSuccess_FidoReturned) {}

// Ensures that VirtualCard authentication attempts are logged correctly.
TEST_F(CreditCardRiskBasedAuthenticatorTest,
       AuthVirtualCardAttemptLoggedCorrectly) {}

// Test a success risk based virtual card unmask request.
TEST_F(CreditCardRiskBasedAuthenticatorTest, VirtualCardUnmaskSuccess) {}

// Test a failed risk based virtual card unmask request.
TEST_F(CreditCardRiskBasedAuthenticatorTest, VirtualCardUnmaskFailure) {}

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

INSTANTIATE_TEST_SUITE_P();

TEST_P(CreditCardRiskBasedAuthenticatorCardMetadataTest, 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 CreditCardRiskBasedAuthenticatorCardBenefitsTest
    : public CreditCardRiskBasedAuthenticatorTest,
      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 risk based authenticator.
TEST_P(CreditCardRiskBasedAuthenticatorCardBenefitsTest,
       Benefits_ClientBehaviorConstants) {}

}  // namespace autofill