#include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_response_reader_factory.h"
#include <memory>
#include <optional>
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/task/sequenced_task_runner.h"
#include "base/test/gmock_expected_support.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/repeating_test_future.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "base/test/test_future.h"
#include "base/types/expected.h"
#include "chrome/browser/web_applications/isolated_web_apps/error/uma_logging.h"
#include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_response_reader.h"
#include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_trust_checker.h"
#include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_validator.h"
#include "chrome/browser/web_applications/test/web_app_test.h"
#include "components/web_package/mojom/web_bundle_parser.mojom.h"
#include "components/web_package/signed_web_bundles/ed25519_public_key.h"
#include "components/web_package/signed_web_bundles/signed_web_bundle_id.h"
#include "components/web_package/signed_web_bundles/signed_web_bundle_integrity_block.h"
#include "components/web_package/signed_web_bundles/signed_web_bundle_signature_verifier.h"
#include "components/web_package/test_support/mock_web_bundle_parser_factory.h"
#include "components/web_package/test_support/signed_web_bundles/signature_verifier_test_utils.h"
#include "content/public/common/content_features.h"
#include "services/data_decoder/public/cpp/test_support/in_process_data_decoder.h"
#include "services/network/public/cpp/resource_request.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace web_app {
namespace {
ErrorIs;
HasValue;
ElementsAre;
Eq;
IsFalse;
IsTrue;
Property;
StartsWith;
VerifierError;
constexpr uint8_t kEd25519PublicKey[32] = …;
constexpr uint8_t kEd25519Signature[64] = …;
class FakeIsolatedWebAppValidator : public IsolatedWebAppValidator { … };
class IsolatedWebAppResponseReaderFactoryTest : public WebAppTest { … };
ReaderResult;
class IsolatedWebAppResponseReaderFactoryIntegrityBlockParserErrorTest
: public IsolatedWebAppResponseReaderFactoryTest,
public ::testing::WithParamInterface<
std::pair<web_package::mojom::BundleParseErrorType,
UnusableSwbnFileError::Error>> { … };
TEST_P(IsolatedWebAppResponseReaderFactoryIntegrityBlockParserErrorTest,
TestIntegrityBlockParserError) { … }
INSTANTIATE_TEST_SUITE_P(…);
TEST_F(IsolatedWebAppResponseReaderFactoryTest,
TestInvalidIntegrityBlockContents) { … }
class IsolatedWebAppResponseReaderFactorySignatureVerificationErrorTest
: public IsolatedWebAppResponseReaderFactoryTest,
public ::testing::WithParamInterface<std::tuple<VerifierError, bool>> { … };
TEST_P(IsolatedWebAppResponseReaderFactorySignatureVerificationErrorTest,
SignatureVerificationError) { … }
INSTANTIATE_TEST_SUITE_P(…);
class IsolatedWebAppResponseReaderFactoryMetadataParserErrorTest
: public IsolatedWebAppResponseReaderFactoryTest,
public ::testing::WithParamInterface<
std::pair<web_package::mojom::BundleParseErrorType,
UnusableSwbnFileError::Error>> { … };
TEST_P(IsolatedWebAppResponseReaderFactoryMetadataParserErrorTest,
TestMetadataParserError) { … }
INSTANTIATE_TEST_SUITE_P(…);
TEST_F(IsolatedWebAppResponseReaderFactoryTest, TestInvalidMetadataPrimaryUrl) { … }
TEST_F(IsolatedWebAppResponseReaderFactoryTest,
TestInvalidMetadataInvalidExchange) { … }
}
}