#include "components/payments/content/utility/payment_manifest_parser.h"
#include "base/strings/string_util.h"
#include "base/test/values_test_util.h"
#include "components/payments/core/error_logger.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
#include "url/origin.h"
namespace payments {
namespace {
void ExpectUnableToParsePaymentMethodManifest(const std::string& input) { … }
void ExpectParsedPaymentMethodManifest(
const std::string& input,
const std::vector<GURL>& expected_web_app_urls,
const std::vector<url::Origin>& expected_supported_origins) { … }
TEST(PaymentManifestParserTest, StringPaymentMethodManifestIsMalformed) { … }
TEST(PaymentManifestParserTest,
EmptyDictionaryPaymentMethodManifestIsMalformed) { … }
TEST(PaymentManifestParserTest, NullDefaultApplicationIsMalformed) { … }
TEST(PaymentManifestParserTest, NumberDefaultApplicationIsMalformed) { … }
TEST(PaymentManifestParserTest, ListOfNumbersDefaultApplicationIsMalformed) { … }
TEST(PaymentManifestParserTest, EmptyListOfDefaultApplicationsIsMalformed) { … }
TEST(PaymentManifestParserTest, ListOfEmptyDefaultApplicationsIsMalformed) { … }
TEST(PaymentManifestParserTest, DefaultApplicationCanBeRelativeURL) { … }
TEST(PaymentManifestParserTest, DefaultApplicationKeyShouldBeLowercase) { … }
TEST(PaymentManifestParserTest,
DefaultApplicationsCanBeEitherAbsoluteOrRelative) { … }
TEST(PaymentManifestParserTest, DefaultApplicationsShouldBeHttps) { … }
TEST(PaymentManifestParserTest, NullSupportedOriginsIsMalformed) { … }
TEST(PaymentManifestParserTest, NumberSupportedOriginsIsMalformed) { … }
TEST(PaymentManifestParserTest, EmptyListSupportedOriginsIsMalformed) { … }
TEST(PaymentManifestParserTest, ListOfNumbersSupportedOriginsIsMalformed) { … }
TEST(PaymentManifestParserTest, ListOfEmptySupportedOriginsIsMalformed) { … }
TEST(PaymentManifestParserTest, SupportedOriginsShouldBeHttps) { … }
TEST(PaymentManifestParserTest, SupportedOriginsShouldNotHavePath) { … }
TEST(PaymentManifestParserTest, SupportedOriginsShouldNotHaveQuery) { … }
TEST(PaymentManifestParserTest, SupportedOriginsShouldNotHaveRef) { … }
TEST(PaymentManifestParserTest, SupportedOriginsShouldBeList) { … }
TEST(PaymentManifestParserTest, WellFormedPaymentMethodManifestWithApps) { … }
TEST(PaymentManifestParserTest,
WellFormedPaymentMethodManifestWithHttpLocalhostApps) { … }
TEST(PaymentManifestParserTest,
InvalidPaymentMethodManifestWithAppsAndAllSupportedOrigins) { … }
TEST(PaymentManifestParserTest, OriginWildcardNotSupported) { … }
TEST(PaymentManifestParserTest,
InvalidDefaultAppsWillPreventParsingSupportedOrigins) { … }
TEST(PaymentManifestParserTest,
InvalidSupportedOriginsWillPreventParsingDefaultApps) { … }
TEST(PaymentManifestParserTest,
WellFormedPaymentMethodManifestWithAppsAndSomeSupportedOrigins) { … }
TEST(PaymentManifestParserTest,
WellFormedPaymentMethodManifestWithHttpLocalhostSupportedOrigins) { … }
TEST(PaymentManifestParserTest,
WellFormedPaymentMethodManifestWithSomeSupportedOrigins) { … }
TEST(PaymentManifestParserTest,
WellFormedPaymentMethodManifestWithAllSupportedOrigins) { … }
void ExpectUnableToParseWebAppManifest(const std::string& input) { … }
void ExpectParsedWebAppManifest(
const std::string& input,
const std::string& expected_id,
int64_t expected_min_version,
const std::vector<std::vector<uint8_t>>& expected_fingerprints) { … }
TEST(PaymentManifestParserTest, StringContentIsMalformed) { … }
TEST(PaymentManifestParserTest, EmptyDictionaryIsMalformed) { … }
TEST(PaymentManifestParserTest, NullRelatedApplicationsSectionIsMalformed) { … }
TEST(PaymentManifestParserTest, NumberRelatedApplicationsectionIsMalformed) { … }
TEST(PaymentManifestParserTest,
ListOfNumbersRelatedApplicationsSectionIsMalformed) { … }
TEST(PaymentManifestParserTest,
ListOfEmptyDictionariesRelatedApplicationsSectionIsMalformed) { … }
TEST(PaymentManifestParserTest, NoPlayPlatformIsMalformed) { … }
TEST(PaymentManifestParserTest, NoPackageNameIsMalformed) { … }
TEST(PaymentManifestParserTest, NoVersionIsMalformed) { … }
TEST(PaymentManifestParserTest, NoFingerprintIsMalformed) { … }
TEST(PaymentManifestParserTest, EmptyFingerprintsIsMalformed) { … }
TEST(PaymentManifestParserTest, EmptyFingerprintsDictionaryIsMalformed) { … }
TEST(PaymentManifestParserTest, NoFingerprintTypeIsMalformed) { … }
TEST(PaymentManifestParserTest, NoFingerprintValueIsMalformed) { … }
TEST(PaymentManifestParserTest, KeysShouldBeLowerCase) { … }
TEST(PaymentManifestParserTest, FingerprintsShouldBeSha256) { … }
TEST(PaymentManifestParserTest, FingerprintBytesShouldBeColonSeparated) { … }
TEST(PaymentManifestParserTest, FingerprintBytesShouldBeUpperCase) { … }
TEST(PaymentManifestParserTest, FingerprintsShouldContainsThirtyTwoBytes) { … }
TEST(PaymentManifestParserTest, WellFormed) { … }
TEST(PaymentManifestParserTest, DuplicateSignaturesWellFormed) { … }
TEST(PaymentManifestParserTest, TwoDifferentSignaturesWellFormed) { … }
TEST(PaymentManifestParserTest, TwoRelatedApplicationsWellFormed) { … }
void ExpectUnableToParseInstallInfo(const std::string& input) { … }
void ExpectParsedInstallInfo(
const std::string& input,
const WebAppInstallationInfo& expected_installation_info,
const std::vector<PaymentManifestParser::WebAppIcon>& expected_icons) { … }
TEST(PaymentManifestParserTest, StringInstallInfoIsMalformed) { … }
TEST(PaymentManifestParserTest, EmptyDictionaryInstallInfoIsMalformed) { … }
TEST(PaymentManifestParserTest, StringServiceWorkerInInstallInfoIsMalformed) { … }
TEST(PaymentManifestParserTest, IntegerSrcInInstallInfoIsMalformed) { … }
TEST(PaymentManifestParserTest, EmptyServiceWorkerSrcInInstallInfoIsMalformed) { … }
void TestPaymentMemberFormat(const std::string& payment_format) { … }
TEST(PaymentManifestParserTest, EmptyPaymentMemberIsMalformed) { … }
TEST(PaymentManifestParserTest, PaymentMemberMustBeADictionary_List) { … }
TEST(PaymentManifestParserTest, PaymentMemberMustBeADictionary_String) { … }
TEST(PaymentManifestParserTest, PaymentMemberMustBeADictionary_Integer) { … }
TEST(PaymentManifestParserTest, InvalidKeyInPaymentMemberIsMalformed) { … }
TEST(PaymentManifestParserTest, SupportedDelegationsMustBeAList_String) { … }
TEST(PaymentManifestParserTest, SupportedDelegationsMustBeAList_Dictionary) { … }
TEST(PaymentManifestParserTest, SupportedDelegationsMustBeAList_Integer) { … }
TEST(PaymentManifestParserTest, EmptyListSupportedDelegationsIsMalformed) { … }
TEST(PaymentManifestParserTest, InvalidSupportedDelegationsIsMalformed) { … }
TEST(PaymentManifestParserTest,
NonASCIICharsInSupportedDelegationsIsMalformed) { … }
TEST(PaymentManifestParserTest, TooLongSupportedDelegationsListIsMalformed) { … }
TEST(PaymentManifestParserTest, MinimumWellFormedInstallInfo) { … }
TEST(PaymentManifestParserTest, WellFormedInstallInfo) { … }
TEST(PaymentManifestParserTest, IgnoreNonBooleanPreferRelatedApplicationField) { … }
TEST(PaymentManifestParserTest, IgnoreFalsePreferRelatedApplicationField) { … }
TEST(PaymentManifestParserTest, IgnoreEmptyRelatedApplications) { … }
TEST(PaymentManifestParserTest, IgnoreNonListRelatedApplications) { … }
TEST(PaymentManifestParserTest, IgnoreNonDictionaryRelatedApplicationsItems) { … }
TEST(PaymentManifestParserTest, IgnoreRelatedApplicationsItemsWithoutId) { … }
TEST(PaymentManifestParserTest, IgnoreRelatedApplicationsItemsWithoutPlatform) { … }
TEST(PaymentManifestParserTest, IgnoreRelatedApplicationsWithoutPlayPlatform) { … }
TEST(PaymentManifestParserTest, OneHundredRelatedApplicationsIsWellFormed) { … }
TEST(PaymentManifestParserTest, CapRelatedApplicationsAtOneHundred) { … }
TEST(PaymentManifestParserTest, IgnoreEmptyRelatedApplicationId) { … }
TEST(PaymentManifestParserTest, IgnoreNonASCIIRelatedApplicationId) { … }
}
}