#include "net/shared_dictionary/shared_dictionary_network_transaction.h"
#include <memory>
#include <optional>
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/scoped_refptr.h"
#include "base/notreached.h"
#include "base/test/scoped_feature_list.h"
#include "crypto/secure_hash.h"
#include "net/base/features.h"
#include "net/base/hash_value.h"
#include "net/base/io_buffer.h"
#include "net/base/test_completion_callback.h"
#include "net/cert/x509_certificate.h"
#include "net/http/http_transaction.h"
#include "net/http/http_transaction_test_util.h"
#include "net/log/net_log_with_source.h"
#include "net/shared_dictionary/shared_dictionary.h"
#include "net/shared_dictionary/shared_dictionary_constants.h"
#include "net/ssl/ssl_private_key.h"
#include "net/test/gtest_util.h"
#include "net/test/test_with_task_environment.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
namespace net {
namespace {
const std::string kTestDictionaryData = …;
const std::string kTestDictionarySha256 = …;
const std::string kTestDictionarySha256Base64 = …;
const std::string kTestData = …;
const uint8_t kBrotliEncodedData[] = …;
const std::string kBrotliEncodedDataString = …;
const uint8_t kZstdEncodedData[] = …;
const std::string kZstdEncodedDataString = …;
const size_t kDefaultBufferSize = …;
class DummySyncDictionary : public SharedDictionary { … };
class DummyAsyncDictionary : public DummySyncDictionary { … };
TransportInfo TestSpdyTransportInfo() { … }
static void BrotliTestTransactionHandler(const HttpRequestInfo* request,
std::string* response_status,
std::string* response_headers,
std::string* response_data) { … }
static void ZstdTestTransactionHandler(const HttpRequestInfo* request,
std::string* response_status,
std::string* response_headers,
std::string* response_data) { … }
static const auto kTestTransactionHandlerWithoutAvailableDictionary = …;
constexpr char kTestUrl[] = …;
const MockTransaction kBrotliDictionaryTestTransaction = …;
const MockTransaction kZstdDictionaryTestTransaction = …;
class SharedDictionaryNetworkTransactionTest : public ::testing::Test { … };
TEST_F(SharedDictionaryNetworkTransactionTest, SyncDictionary) { … }
TEST_F(SharedDictionaryNetworkTransactionTest, NotAllowedToUseDictionary) { … }
TEST_F(SharedDictionaryNetworkTransactionTest, DictionaryId) { … }
TEST_F(SharedDictionaryNetworkTransactionTest,
DictionaryIdWithBackSlashAndDquote) { … }
TEST_F(SharedDictionaryNetworkTransactionTest, EmptyDictionaryId) { … }
TEST_F(SharedDictionaryNetworkTransactionTest,
RequireKnownRootCertCheckFailure) { … }
TEST_F(SharedDictionaryNetworkTransactionTest,
RequireKnownRootCertCheckSuccess) { … }
TEST_F(SharedDictionaryNetworkTransactionTest,
RequireKnownRootCertCheckSuccessForLocalhost) { … }
TEST_F(SharedDictionaryNetworkTransactionTest, NoMatchingDictionary) { … }
TEST_F(SharedDictionaryNetworkTransactionTest, OpaqueFrameOrigin) { … }
TEST_F(SharedDictionaryNetworkTransactionTest, WithoutValidLoadFlag) { … }
TEST_F(SharedDictionaryNetworkTransactionTest, NoSbrContentEncoding) { … }
TEST_F(SharedDictionaryNetworkTransactionTest, WrongContentDictionaryHeader) { … }
TEST_F(SharedDictionaryNetworkTransactionTest, MultipleContentEncodingWithSbr) { … }
TEST_F(SharedDictionaryNetworkTransactionTest,
AsyncDictionarySuccessBeforeStartReading) { … }
TEST_F(SharedDictionaryNetworkTransactionTest,
AsyncDictionarySuccessAfterStartReading) { … }
TEST_F(SharedDictionaryNetworkTransactionTest,
AsyncDictionarySuccessAfterTransactionDestroy) { … }
TEST_F(SharedDictionaryNetworkTransactionTest,
AsyncDictionaryFailureBeforeStartReading) { … }
TEST_F(SharedDictionaryNetworkTransactionTest,
AsyncDictionaryFailureAfterStartReading) { … }
TEST_F(SharedDictionaryNetworkTransactionTest, Restart) { … }
TEST_F(SharedDictionaryNetworkTransactionTest, StopCaching) { … }
TEST_F(SharedDictionaryNetworkTransactionTest, DoneReading) { … }
TEST_F(SharedDictionaryNetworkTransactionTest, GetLoadState) { … }
TEST_F(SharedDictionaryNetworkTransactionTest, SharedZstd) { … }
TEST_F(SharedDictionaryNetworkTransactionTest, NoZstdDContentEncoding) { … }
enum class ProtocolCheckProtocolTestCase { … };
std::string ToString(ProtocolCheckProtocolTestCase protocol) { … }
enum class ProtocolCheckHttp1TestCase { … };
std::string ToString(ProtocolCheckHttp1TestCase feature) { … }
enum class ProtocolCheckHttp2TestCase { … };
std::string ToString(ProtocolCheckHttp2TestCase feature) { … }
enum class ProtocolCheckHostTestCase { … };
std::string ToString(ProtocolCheckHostTestCase host_type) { … }
class SharedDictionaryNetworkTransactionProtocolCheckTest
: public SharedDictionaryNetworkTransactionTest,
public testing::WithParamInterface<
std::tuple<ProtocolCheckHttp1TestCase,
ProtocolCheckHttp2TestCase,
ProtocolCheckProtocolTestCase,
ProtocolCheckHostTestCase>> { … };
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(SharedDictionaryNetworkTransactionProtocolCheckTest, Basic) { … }
}
}