chromium/net/url_request/url_request_job_unittest.cc

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "net/url_request/url_request_job.h"

#include <memory>
#include <optional>

#include "base/functional/bind.h"
#include "base/run_loop.h"
#include "base/test/bind.h"
#include "base/test/scoped_feature_list.h"
#include "net/base/features.h"
#include "net/base/request_priority.h"
#include "net/http/http_transaction_test_util.h"
#include "net/test/cert_test_util.h"
#include "net/test/gtest_util.h"
#include "net/test/test_data_directory.h"
#include "net/test/test_with_task_environment.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "net/url_request/referrer_policy.h"
#include "net/url_request/url_request.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_builder.h"
#include "net/url_request/url_request_test_util.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/url_util.h"

IsError;
IsOk;

namespace net {

namespace {

// Data encoded in kBrotliHelloData.
const char kHelloData[] =;
// kHelloData encoded with brotli.
const char kBrotliHelloData[] =;

// This is a header that signals the end of the data.
const char kGzipData[] =;
const char kGzipDataWithName[] =;
// kHelloData encoded with gzip.
const char kGzipHelloData[] =;

void GZipServer(const HttpRequestInfo* request,
                std::string* response_status,
                std::string* response_headers,
                std::string* response_data) {}

void GZipHelloServer(const HttpRequestInfo* request,
                     std::string* response_status,
                     std::string* response_headers,
                     std::string* response_data) {}

void BigGZipServer(const HttpRequestInfo* request,
                   std::string* response_status,
                   std::string* response_headers,
                   std::string* response_data) {}

void BrotliHelloServer(const HttpRequestInfo* request,
                       std::string* response_status,
                       std::string* response_headers,
                       std::string* response_data) {}

void MakeMockReferrerPolicyTransaction(const char* referer_header,
                                       const char* response_headers,
                                       MockTransaction* transaction) {}

const MockTransaction kNoFilterTransaction =;

const MockTransaction kNoFilterTransactionWithInvalidLength =;

const MockTransaction kGZipTransaction =;

const MockTransaction kGzipSlowTransaction =;

const MockTransaction kRedirectTransaction =;

const MockTransaction kEmptyBodyGzipTransaction =;

const MockTransaction kInvalidContentGZipTransaction =;

const MockTransaction kBrotliSlowTransaction =;

}  // namespace

URLRequestJobTest;

TEST_F(URLRequestJobTest, TransactionNoFilter) {}

TEST_F(URLRequestJobTest, TransactionNoFilterWithInvalidLength) {}

TEST_F(URLRequestJobTest, TransactionNotifiedWhenDone) {}

TEST_F(URLRequestJobTest, SyncTransactionNotifiedWhenDone) {}

// Tests processing a large gzip header one byte at a time.
TEST_F(URLRequestJobTest, SyncSlowTransaction) {}

TEST_F(URLRequestJobTest, RedirectTransactionNotifiedWhenDone) {}

TEST_F(URLRequestJobTest, RedirectTransactionWithReferrerPolicyHeader) {}

TEST_F(URLRequestJobTest, TransactionNotCachedWhenNetworkDelegateRedirects) {}

// Makes sure that ReadRawDataComplete correctly updates request status before
// calling ReadFilteredData.
// Regression test for crbug.com/553300.
TEST_F(URLRequestJobTest, EmptyBodySkipFilter) {}

// Regression test for crbug.com/575213.
TEST_F(URLRequestJobTest, InvalidContentGZipTransaction) {}

// Regression test for crbug.com/553300.
TEST_F(URLRequestJobTest, SlowFilterRead) {}

TEST_F(URLRequestJobTest, SlowBrotliRead) {}

TEST(URLRequestJobComputeReferrer, SetsSameOriginForMetricsOnSameOrigin) {}

TEST(URLRequestJobComputeReferrer, SetsSameOriginForMetricsOnCrossOrigin) {}

TEST(URLRequestJobComputeReferrer, AcceptsNullptrInput) {}

TEST(URLRequestJobComputeReferrer, FilesystemDestination) {}

TEST(URLRequestJobComputeReferrer, TruncatesLongReferrer) {}

TEST(URLRequestJobComputeReferrer, DoesntTruncateShortReferrer) {}

TEST(URLRequestJobComputeReferrer, DoesntTruncateEvenShorterReferrer) {}

TEST(URLRequestJobComputeReferrer, DoesntTruncateReferrerWithLongRef) {}

TEST(URLRequestJobComputeReferrer, InvalidSchemeReferrer) {}

TEST(URLRequestJobComputeReferrer, CapReferrerOnCrossOrigin) {}

TEST(URLRequestJobComputeReferrer,
     CapReferrerOnCrossOriginRespectsStricterPolicy) {}

TEST(URLRequestJobComputeReferrer,
     CapReferrerOnCrossOriginDoesntCapOnSameOrigin) {}

}  // namespace net