chromium/components/payments/content/secure_payment_confirmation_app_factory_unittest.cc

// Copyright 2022 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/payments/content/secure_payment_confirmation_app_factory.h"

#include <vector>

#include "base/base64.h"
#include "base/test/gmock_callback_support.h"
#include "base/test/scoped_feature_list.h"
#include "components/payments/content/mock_payment_app_factory_delegate.h"
#include "components/payments/content/mock_payment_manifest_web_data_service.h"
#include "components/payments/core/features.h"
#include "components/webauthn/core/browser/mock_internal_authenticator.h"
#include "content/public/test/browser_task_environment.h"
#include "content/public/test/test_browser_context.h"
#include "content/public/test/test_web_contents_factory.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/mojom/payments/payment_request.mojom.h"
#include "url/gurl.h"
#include "url/origin.h"

namespace payments {
namespace {

RunOnceCallback;
_;
ByMove;
Eq;
Return;
ReturnRef;

static constexpr char kChallengeBase64[] =;
static constexpr char kCredentialIdBase64[] =;

class SecurePaymentConfirmationAppFactoryTest : public testing::Test {};

// Test that parsing a valid SecureConfirmationPaymentRequest succeeds.
TEST_F(SecurePaymentConfirmationAppFactoryTest,
       SecureConfirmationPaymentRequest_IsValid) {}

// Test that parsing a SecurePaymentConfirmationRequest with an empty
// credentialIds field fails.
TEST_F(SecurePaymentConfirmationAppFactoryTest,
       SecureConfirmationPaymentRequest_EmptyCredentialIds) {}

// Test that parsing a SecurePaymentConfirmationRequest with an empty ID inside
// the credentialIds field fails.
TEST_F(SecurePaymentConfirmationAppFactoryTest,
       SecureConfirmationPaymentRequest_EmptyId) {}

// Test that parsing a SecurePaymentConfirmationRequest with an empty challenge
// fails.
TEST_F(SecurePaymentConfirmationAppFactoryTest,
       SecureConfirmationPaymentRequest_EmptyChallenge) {}

// Test that parsing a SecurePaymentConfirmationRequest with an empty
// displayName fails.
TEST_F(SecurePaymentConfirmationAppFactoryTest,
       SecureConfirmationPaymentRequest_EmptyDisplayName) {}

// Test that parsing a SecurePaymentConfirmationRequest with an empty
// instrument icon fails.
TEST_F(SecurePaymentConfirmationAppFactoryTest,
       SecureConfirmationPaymentRequest_EmptyInstrumentIcon) {}

// Test that parsing a SecurePaymentConfirmationRequest with an invalid
// instrument icon URL fails.
TEST_F(SecurePaymentConfirmationAppFactoryTest,
       SecureConfirmationPaymentRequest_InvalidInstrumentIcon) {}

// Test that parsing a SecurePaymentConfirmationRequest with an invalid RP
// domain fails.
TEST_F(SecurePaymentConfirmationAppFactoryTest,
       SecureConfirmationPaymentRequest_InvalidRpId) {}

// Test that parsing a SecurePaymentConfirmationRequest with a missing payeeName
// and payeeOrigin fails.
TEST_F(SecurePaymentConfirmationAppFactoryTest,
       SecureConfirmationPaymentRequest_MissingPayeeNameAndPayeeOrigin) {}

// Test that parsing a SecurePaymentConfirmationRequest with a present but empty
// payeeName fails.
TEST_F(SecurePaymentConfirmationAppFactoryTest,
       SecureConfirmationPaymentRequest_EmptyPayeeName) {}

// Test that parsing a SecurePaymentConfirmationRequest with a non-HTTPS
// payeeOrigin fails.
TEST_F(SecurePaymentConfirmationAppFactoryTest,
       SecureConfirmationPaymentRequest_NonHttpsPayeeOrigin) {}

// Test that parsing a SecurePaymentConfirmationRequest with an empty
// network name fails.
TEST_F(SecurePaymentConfirmationAppFactoryTest,
       SecureConfirmationPaymentRequest_EmptyNetworkName) {}

// Test that parsing a SecurePaymentConfirmationRequest with an empty
// network icon fails.
TEST_F(SecurePaymentConfirmationAppFactoryTest,
       SecureConfirmationPaymentRequest_EmptyNetworkIcon) {}

// Test that parsing a SecurePaymentConfirmationRequest with an invalid
// network icon URL fails.
TEST_F(SecurePaymentConfirmationAppFactoryTest,
       SecureConfirmationPaymentRequest_InvalidNetworkIcon) {}

// Test that parsing a SecurePaymentConfirmationRequest with an empty
// issuer name fails.
TEST_F(SecurePaymentConfirmationAppFactoryTest,
       SecureConfirmationPaymentRequest_EmptyIssuerName) {}

// Test that parsing a SecurePaymentConfirmationRequest with an empty
// issuer icon fails.
TEST_F(SecurePaymentConfirmationAppFactoryTest,
       SecureConfirmationPaymentRequest_EmptyIssuerIcon) {}

// Test that parsing a SecurePaymentConfirmationRequest with an invalid
// issuer icon URL fails.
TEST_F(SecurePaymentConfirmationAppFactoryTest,
       SecureConfirmationPaymentRequest_InvalidIssuerIcon) {}

class SecurePaymentConfirmationAppFactoryUsingCredentialStoreAPIsTest
    : public SecurePaymentConfirmationAppFactoryTest {};

TEST_F(
    SecurePaymentConfirmationAppFactoryUsingCredentialStoreAPIsTest,
    CorrectlyCalculatesThirdPartyPaymentRequirement_OriginDifferentFromRpId) {}

TEST_F(SecurePaymentConfirmationAppFactoryUsingCredentialStoreAPIsTest,
       CorrectlyCalculatesThirdPartyPaymentRequirement_OriginSameAsRpId) {}

TEST_F(SecurePaymentConfirmationAppFactoryUsingCredentialStoreAPIsTest,
       CorrectlyCalculatesThirdPartyPaymentRequirement_OriginSameDomainAsRpId) {}

TEST_F(SecurePaymentConfirmationAppFactoryUsingCredentialStoreAPIsTest,
       AppDisabledIfCredentialStoreAPIsUnavailable) {}

}  // namespace
}  // namespace payments