#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "net/url_request/url_request.h"
#include <stdint.h>
#include <algorithm>
#include <iterator>
#include <limits>
#include <memory>
#include <optional>
#include <string_view>
#include <utility>
#include "base/base64.h"
#include "base/base64url.h"
#include "base/compiler_specific.h"
#include "base/containers/heap_array.h"
#include "base/containers/span.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/format_macros.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/location.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/path_service.h"
#include "base/ranges/algorithm.h"
#include "base/run_loop.h"
#include "base/strings/escape.h"
#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/bind.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/test_future.h"
#include "base/test/values_test_util.h"
#include "base/time/time.h"
#include "base/values.h"
#include "build/build_config.h"
#include "build/buildflag.h"
#include "crypto/sha2.h"
#include "net/base/chunked_upload_data_stream.h"
#include "net/base/directory_listing.h"
#include "net/base/elements_upload_data_stream.h"
#include "net/base/features.h"
#include "net/base/hash_value.h"
#include "net/base/ip_address.h"
#include "net/base/ip_endpoint.h"
#include "net/base/isolation_info.h"
#include "net/base/load_flags.h"
#include "net/base/load_timing_info.h"
#include "net/base/load_timing_info_test_util.h"
#include "net/base/net_errors.h"
#include "net/base/net_module.h"
#include "net/base/proxy_chain.h"
#include "net/base/proxy_server.h"
#include "net/base/proxy_string_util.h"
#include "net/base/request_priority.h"
#include "net/base/test_completion_callback.h"
#include "net/base/transport_info.h"
#include "net/base/upload_bytes_element_reader.h"
#include "net/base/upload_data_stream.h"
#include "net/base/upload_file_element_reader.h"
#include "net/base/url_util.h"
#include "net/cert/asn1_util.h"
#include "net/cert/caching_cert_verifier.h"
#include "net/cert/cert_net_fetcher.h"
#include "net/cert/cert_verifier.h"
#include "net/cert/coalescing_cert_verifier.h"
#include "net/cert/crl_set.h"
#include "net/cert/do_nothing_ct_verifier.h"
#include "net/cert/ev_root_ca_metadata.h"
#include "net/cert/mock_cert_verifier.h"
#include "net/cert/multi_log_ct_verifier.h"
#include "net/cert/signed_certificate_timestamp_and_status.h"
#include "net/cert/test_root_certs.h"
#include "net/cert/x509_util.h"
#include "net/cert_net/cert_net_fetcher_url_request.h"
#include "net/cookies/canonical_cookie_test_helpers.h"
#include "net/cookies/cookie_inclusion_status.h"
#include "net/cookies/cookie_monster.h"
#include "net/cookies/cookie_setting_override.h"
#include "net/cookies/cookie_store_test_helpers.h"
#include "net/cookies/cookie_util.h"
#include "net/cookies/test_cookie_access_delegate.h"
#include "net/disk_cache/disk_cache.h"
#include "net/dns/mock_host_resolver.h"
#include "net/dns/public/host_resolver_results.h"
#include "net/dns/public/secure_dns_policy.h"
#include "net/http/http_byte_range.h"
#include "net/http/http_cache.h"
#include "net/http/http_connection_info.h"
#include "net/http/http_network_layer.h"
#include "net/http/http_network_session.h"
#include "net/http/http_request_headers.h"
#include "net/http/http_response_headers.h"
#include "net/http/http_server_properties.h"
#include "net/http/http_status_code.h"
#include "net/http/http_transaction_test_util.h"
#include "net/http/http_util.h"
#include "net/http/transport_security_state.h"
#include "net/http/transport_security_state_source.h"
#include "net/log/file_net_log_observer.h"
#include "net/log/net_log.h"
#include "net/log/net_log_event_type.h"
#include "net/log/net_log_source.h"
#include "net/log/test_net_log.h"
#include "net/log/test_net_log_util.h"
#include "net/net_buildflags.h"
#include "net/proxy_resolution/configured_proxy_resolution_service.h"
#include "net/quic/mock_crypto_client_stream_factory.h"
#include "net/quic/quic_server_info.h"
#include "net/socket/read_buffering_stream_socket.h"
#include "net/socket/socket_test_util.h"
#include "net/socket/ssl_client_socket.h"
#include "net/ssl/client_cert_identity_test_util.h"
#include "net/ssl/ssl_connection_status_flags.h"
#include "net/ssl/ssl_private_key.h"
#include "net/ssl/ssl_server_config.h"
#include "net/ssl/test_ssl_config_service.h"
#include "net/storage_access_api/status.h"
#include "net/test/cert_test_util.h"
#include "net/test/embedded_test_server/http_request.h"
#include "net/test/embedded_test_server/http_response.h"
#include "net/test/gtest_util.h"
#include "net/test/spawned_test_server/spawned_test_server.h"
#include "net/test/test_data_directory.h"
#include "net/test/test_with_task_environment.h"
#include "net/test/url_request/url_request_failed_job.h"
#include "net/test/url_request/url_request_mock_http_job.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "net/url_request/redirect_util.h"
#include "net/url_request/referrer_policy.h"
#include "net/url_request/static_http_user_agent_settings.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_builder.h"
#include "net/url_request/url_request_filter.h"
#include "net/url_request/url_request_http_job.h"
#include "net/url_request/url_request_interceptor.h"
#include "net/url_request/url_request_redirect_job.h"
#include "net/url_request/url_request_test_job.h"
#include "net/url_request/url_request_test_util.h"
#include "net/url_request/websocket_handshake_userdata_key.h"
#include "testing/gmock/include/gmock/gmock-matchers.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
#include "third_party/boringssl/src/include/openssl/ssl.h"
#include "url/url_constants.h"
#include "url/url_util.h"
#if BUILDFLAG(IS_WIN)
#include <objbase.h>
#include <windows.h>
#include <shlobj.h>
#include <wrl/client.h>
#include "base/win/scoped_com_initializer.h"
#endif
#if BUILDFLAG(IS_APPLE)
#include "base/mac/mac_util.h"
#endif
#if BUILDFLAG(ENABLE_REPORTING)
#include "net/network_error_logging/network_error_logging_service.h"
#include "net/network_error_logging/network_error_logging_test_util.h"
#endif
#if BUILDFLAG(ENABLE_WEBSOCKETS)
#include "net/websockets/websocket_test_util.h"
#endif
IsError;
IsOk;
RegisterDefaultHandlers;
_;
AnyOf;
ElementsAre;
IsEmpty;
Optional;
UnorderedElementsAre;
ASCIIToUTF16;
Time;
string;
namespace net {
namespace {
namespace test_default {
#include "net/http/transport_security_state_static_unittest_default.h"
}
const std::u16string kSecret(u"secret");
const std::u16string kUser(u"user");
const base::FilePath::CharType kTestFilePath[] = …);
void TestLoadTimingNotReused(const LoadTimingInfo& load_timing_info,
int connect_timing_flags) { … }
void TestLoadTimingNotReusedWithProxy(const LoadTimingInfo& load_timing_info,
int connect_timing_flags) { … }
void TestLoadTimingReusedWithProxy(const LoadTimingInfo& load_timing_info) { … }
CookieList GetAllCookies(URLRequestContext* request_context) { … }
void TestLoadTimingCacheHitNoNetwork(const LoadTimingInfo& load_timing_info) { … }
class PriorityMonitoringURLRequestJob : public URLRequestTestJob { … };
bool ContainsString(const std::string& haystack, const char* needle) { … }
std::unique_ptr<UploadDataStream> CreateSimpleUploadData(
base::span<const uint8_t> data) { … }
void CheckSSLInfo(const SSLInfo& ssl_info) { … }
class BlockingNetworkDelegate : public TestNetworkDelegate { … };
BlockingNetworkDelegate::BlockingNetworkDelegate(BlockMode block_mode)
: … { … }
void BlockingNetworkDelegate::RunUntilBlocked() { … }
void BlockingNetworkDelegate::DoCallback(int response) { … }
void BlockingNetworkDelegate::OnBlocked() { … }
void BlockingNetworkDelegate::RunCallback(int response,
CompletionOnceCallback callback) { … }
int BlockingNetworkDelegate::OnBeforeURLRequest(URLRequest* request,
CompletionOnceCallback callback,
GURL* new_url) { … }
int BlockingNetworkDelegate::OnBeforeStartTransaction(
URLRequest* request,
const HttpRequestHeaders& headers,
OnBeforeStartTransactionCallback callback) { … }
int BlockingNetworkDelegate::OnHeadersReceived(
URLRequest* request,
CompletionOnceCallback callback,
const HttpResponseHeaders* original_response_headers,
scoped_refptr<HttpResponseHeaders>* override_response_headers,
const IPEndPoint& endpoint,
std::optional<GURL>* preserve_fragment_on_redirect_url) { … }
void BlockingNetworkDelegate::Reset() { … }
int BlockingNetworkDelegate::MaybeBlockStage(
BlockingNetworkDelegate::Stage stage,
CompletionOnceCallback callback) { … }
class OCSPErrorTestDelegate : public TestDelegate { … };
#if !BUILDFLAG(IS_IOS)
bool GetTestRootCertSPKIHash(SHA256HashValue* root_hash) { … }
#endif
}
class URLRequestTest : public PlatformTest, public WithTaskEnvironment { … };
TEST_F(URLRequestTest, AboutBlankTest) { … }
TEST_F(URLRequestTest, InvalidUrlTest) { … }
TEST_F(URLRequestTest, WsUrlTest) { … }
TEST_F(URLRequestTest, WssUrlTest) { … }
TEST_F(URLRequestTest, InvalidReferrerTest) { … }
TEST_F(URLRequestTest, RecordsSameOriginReferrerHistogram) { … }
TEST_F(URLRequestTest, RecordsCrossOriginReferrerHistogram) { … }
TEST_F(URLRequestTest, RecordsReferrerHistogramAgainOnRedirect) { … }
TEST_F(URLRequestTest, RecordsReferrrerWithInformativePath) { … }
TEST_F(URLRequestTest, RecordsReferrerWithInformativeQuery) { … }
TEST_F(URLRequestTest, RecordsReferrerWithoutInformativePathOrQuery) { … }
class URLRequestInterceptorWithLoadTimingInfo : public URLRequestInterceptor { … };
class URLRequestLoadTimingTest : public URLRequestTest { … };
LoadTimingInfo NormalLoadTimingInfo(base::TimeTicks now,
int connect_time_flags,
bool used_proxy) { … }
LoadTimingInfo NormalLoadTimingInfoReused(base::TimeTicks now,
bool used_proxy) { … }
LoadTimingInfo RunURLRequestInterceptorLoadTimingTest(
const LoadTimingInfo& job_load_timing,
const URLRequestContext& context,
URLRequestInterceptorWithLoadTimingInfo* interceptor) { … }
TEST_F(URLRequestLoadTimingTest, InterceptLoadTiming) { … }
TEST_F(URLRequestLoadTimingTest, InterceptLoadTimingProxy) { … }
TEST_F(URLRequestLoadTimingTest, InterceptLoadTimingEarlyProxyResolution) { … }
TEST_F(URLRequestLoadTimingTest,
InterceptLoadTimingEarlyProxyResolutionReused) { … }
TEST_F(URLRequestLoadTimingTest, InterceptLoadTimingEarlyConnect) { … }
TEST_F(URLRequestLoadTimingTest, InterceptLoadTimingEarlyConnectWithProxy) { … }
TEST_F(URLRequestTest, NetworkDelegateProxyError) { … }
TEST_F(URLRequestTest, DnsNameHttpsOnlyErrorCausesSchemeUpgrade) { … }
TEST_F(URLRequestTest, DnsNameHttpsOnlyErrorCausesSchemeUpgradeDeferred) { … }
#if BUILDFLAG(ENABLE_WEBSOCKETS)
TEST_F(URLRequestTest, DnsHttpsRecordPresentCausesWsSchemeUpgrade) { … }
TEST_F(URLRequestTest, WssRequestsAreEligibleForStorageAccess) { … }
#endif
TEST_F(URLRequestTest, DnsHttpsRecordAbsentNoSchemeUpgrade) { … }
TEST_F(URLRequestTest, SkipSecureDnsDisabledByDefault) { … }
TEST_F(URLRequestTest, SkipSecureDnsEnabled) { … }
TEST_F(URLRequestTest, RequestCompletionForEmptyResponse) { … }
TEST_F(URLRequestTest, SetPriorityBasic) { … }
TEST_F(URLRequestTest, SetJobPriorityBeforeJobStart) { … }
TEST_F(URLRequestTest, SetJobPriority) { … }
TEST_F(URLRequestTest, PriorityIgnoreLimits) { … }
TEST_F(URLRequestTest, NotifyDelegateConnectedSkippedOnEarlyFailure) { … }
TEST_F(URLRequestTest, OnConnected) { … }
TEST_F(URLRequestTest, OnConnectedRedirect) { … }
TEST_F(URLRequestTest, OnConnectedError) { … }
TEST_F(URLRequestTest, OnConnectedAsync) { … }
TEST_F(URLRequestTest, OnConnectedAsyncError) { … }
TEST_F(URLRequestTest, DelayedCookieCallback) { … }
TEST_F(URLRequestTest, DelayedCookieCallbackAsync) { … }
TEST_F(URLRequestTest, DoNotSendCookies) { … }
TEST_F(URLRequestTest, DoNotSaveCookies) { … }
TEST_F(URLRequestTest, DoNotSendCookies_ViaPolicy) { … }
#if BUILDFLAG(IS_IOS)
#define MAYBE_DoNotSaveCookies_ViaPolicy …
#else
#define MAYBE_DoNotSaveCookies_ViaPolicy …
#endif
TEST_F(URLRequestTest, MAYBE_DoNotSaveCookies_ViaPolicy) { … }
TEST_F(URLRequestTest, DoNotSaveEmptyCookies) { … }
TEST_F(URLRequestTest, DoNotSendCookies_ViaPolicy_Async) { … }
TEST_F(URLRequestTest, DoNotSaveCookies_ViaPolicy_Async) { … }
class URLRequestSameSiteCookiesTest
: public URLRequestTest,
public ::testing::WithParamInterface<bool> { … };
TEST_P(URLRequestSameSiteCookiesTest, SameSiteCookies) { … }
TEST_P(URLRequestSameSiteCookiesTest, SameSiteCookies_Redirect) { … }
TEST_P(URLRequestSameSiteCookiesTest, SettingSameSiteCookies) { … }
TEST_P(URLRequestSameSiteCookiesTest, SameSiteCookiesSpecialScheme) { … }
TEST_P(URLRequestSameSiteCookiesTest, SettingSameSiteCookies_Redirect) { … }
INSTANTIATE_TEST_SUITE_P(…);
TEST_F(URLRequestTest, PartitionedCookiesRedirect) { … }
TEST_F(URLRequestTest, SecureCookiePrefixOnNonsecureOrigin) { … }
TEST_F(URLRequestTest, SecureCookiePrefixNonsecure) { … }
TEST_F(URLRequestTest, SecureCookiePrefixSecure) { … }
TEST_F(URLRequestTest, StrictSecureCookiesOnNonsecureOrigin) { … }
class FixedDateNetworkDelegate : public TestNetworkDelegate { … };
int FixedDateNetworkDelegate::OnHeadersReceived(
URLRequest* request,
CompletionOnceCallback callback,
const HttpResponseHeaders* original_response_headers,
scoped_refptr<HttpResponseHeaders>* override_response_headers,
const IPEndPoint& endpoint,
std::optional<GURL>* preserve_fragment_on_redirect_url) { … }
TEST_F(URLRequestTest, AcceptClockSkewCookieWithWrongDateTimezone) { … }
TEST_F(URLRequestTest, DoNotOverrideReferrer) { … }
class URLRequestTestHTTP : public URLRequestTest { … };
namespace {
std::unique_ptr<test_server::HttpResponse> HandleRedirectConnect(
const test_server::HttpRequest& request) { … }
}
TEST_F(URLRequestTestHTTP, ProxyTunnelRedirectTest) { … }
TEST_F(URLRequestTestHTTP, NetworkDelegateTunnelConnectionFailed) { … }
TEST_F(URLRequestTestHTTP, NetworkDelegateBlockAsynchronously) { … }
TEST_F(URLRequestTestHTTP, NetworkDelegateCancelRequest) { … }
void NetworkDelegateCancelRequest(BlockingNetworkDelegate::BlockMode block_mode,
BlockingNetworkDelegate::Stage stage,
const GURL& url) { … }
TEST_F(URLRequestTestHTTP, NetworkDelegateCancelRequestSynchronously1) { … }
TEST_F(URLRequestTestHTTP, NetworkDelegateCancelRequestSynchronously2) { … }
TEST_F(URLRequestTestHTTP, NetworkDelegateCancelRequestSynchronously3) { … }
TEST_F(URLRequestTestHTTP, NetworkDelegateCancelRequestAsynchronously1) { … }
TEST_F(URLRequestTestHTTP, NetworkDelegateCancelRequestAsynchronously2) { … }
TEST_F(URLRequestTestHTTP, NetworkDelegateCancelRequestAsynchronously3) { … }
TEST_F(URLRequestTestHTTP, NetworkDelegateRedirectRequest) { … }
TEST_F(URLRequestTestHTTP, NetworkDelegateRedirectRequestSynchronously) { … }
TEST_F(URLRequestTestHTTP, NetworkDelegateRedirectRequestPost) { … }
TEST_F(URLRequestTestHTTP, NetworkDelegateRedirectRequestOnHeadersReceived) { … }
TEST_F(URLRequestTestHTTP, NetworkDelegateOnAuthRequiredSyncNoAction) { … }
TEST_F(URLRequestTestHTTP, NetworkDelegateOverrideHeadersWithAuth) { … }
TEST_F(URLRequestTestHTTP, NetworkDelegateCancelWhileWaiting1) { … }
TEST_F(URLRequestTestHTTP, NetworkDelegateCancelWhileWaiting2) { … }
TEST_F(URLRequestTestHTTP, NetworkDelegateCancelWhileWaiting3) { … }
namespace {
std::unique_ptr<test_server::HttpResponse> HandleServerAuthConnect(
const test_server::HttpRequest& request) { … }
}
TEST_F(URLRequestTestHTTP, UnexpectedServerAuthTest) { … }
TEST_F(URLRequestTestHTTP, GetTest_NoCache) { … }
TEST_F(URLRequestTestHTTP, GetTest) { … }
TEST_F(URLRequestTestHTTP, GetTestLoadTiming) { … }
namespace {
const char kZippedContentLengthCompressed[] = …;
const char kZippedContentLengthUncompressed[] = …;
const char kZippedContentLengthShort[] = …;
const char kZippedContentLengthMedium[] = …;
const char kZippedContentLengthLong[] = …;
std::unique_ptr<test_server::HttpResponse> HandleZippedRequest(
const std::string& compressed_content,
size_t uncompressed_length,
const test_server::HttpRequest& request) { … }
}
TEST_F(URLRequestTestHTTP, GetZippedTest) { … }
TEST_F(URLRequestTestHTTP, RedirectLoadTiming) { … }
TEST_F(URLRequestTestHTTP, MultipleRedirectTest) { … }
TEST_F(URLRequestTestHTTP, RedirectEscaping) { … }
const char kFirstDelegateInfo[] = …;
const char16_t kFirstDelegateInfo16[] = …;
const char kSecondDelegateInfo[] = …;
const char16_t kSecondDelegateInfo16[] = …;
class AsyncDelegateLogger : public base::RefCounted<AsyncDelegateLogger> { … };
class AsyncLoggingNetworkDelegate : public TestNetworkDelegate { … };
class AsyncLoggingUrlRequestDelegate : public TestDelegate { … };
TEST_F(URLRequestTestHTTP, DelegateInfoBeforeStart) { … }
TEST_F(URLRequestTestHTTP, NetworkDelegateInfo) { … }
TEST_F(URLRequestTestHTTP, NetworkDelegateInfoRedirect) { … }
TEST_F(URLRequestTestHTTP, URLRequestDelegateInfo) { … }
TEST_F(URLRequestTestHTTP, URLRequestDelegateInfoOnRedirect) { … }
TEST_F(URLRequestTestHTTP, URLRequestDelegateOnRedirectCancelled) { … }
namespace {
const char kExtraHeader[] = …;
const char kExtraValue[] = …;
class RedirectWithAdditionalHeadersDelegate : public TestDelegate { … };
}
TEST_F(URLRequestTestHTTP, RedirectWithAdditionalHeadersTest) { … }
namespace {
const char kExtraHeaderToRemove[] = …;
class RedirectWithHeaderRemovalDelegate : public TestDelegate { … };
}
TEST_F(URLRequestTestHTTP, RedirectWithHeaderRemovalTest) { … }
TEST_F(URLRequestTestHTTP, CancelAfterStart) { … }
TEST_F(URLRequestTestHTTP, CancelInResponseStarted) { … }
TEST_F(URLRequestTestHTTP, CancelOnDataReceived) { … }
TEST_F(URLRequestTestHTTP, CancelDuringEofRead) { … }
TEST_F(URLRequestTestHTTP, CancelByDestroyingAfterStart) { … }
TEST_F(URLRequestTestHTTP, CancelWhileReadingFromCache) { … }
TEST_F(URLRequestTestHTTP, PostTest) { … }
TEST_F(URLRequestTestHTTP, PutTest) { … }
TEST_F(URLRequestTestHTTP, PostEmptyTest) { … }
TEST_F(URLRequestTestHTTP, PostFileTest) { … }
TEST_F(URLRequestTestHTTP, PostUnreadableFileTest) { … }
namespace {
void AddDataToUpload(ChunkedUploadDataStream::Writer* writer) { … }
void VerifyReceivedDataMatchesChunks(URLRequest* r, TestDelegate* d) { … }
}
TEST_F(URLRequestTestHTTP, TestPostChunkedDataBeforeStart) { … }
TEST_F(URLRequestTestHTTP, TestPostChunkedDataJustAfterStart) { … }
TEST_F(URLRequestTestHTTP, TestPostChunkedDataAfterStart) { … }
TEST_F(URLRequestTestHTTP, ResponseHeadersTest) { … }
#if !BUILDFLAG(IS_IOS)
TEST_F(URLRequestTestHTTP, ProcessSTS) { … }
TEST_F(URLRequestTestHTTP, STSNotProcessedOnIP) { … }
TEST_F(URLRequestTestHTTP, PKPBypassRecorded) { … }
TEST_F(URLRequestTestHTTP, ProcessSTSOnce) { … }
#endif
#if BUILDFLAG(ENABLE_REPORTING)
TEST_F(URLRequestTestHTTP, NetworkErrorLogging_DontReportIfNetworkNotAccessed) { … }
TEST_F(URLRequestTestHTTP, NetworkErrorLogging_BasicSuccess) { … }
TEST_F(URLRequestTestHTTP, NetworkErrorLogging_BasicError) { … }
TEST_F(URLRequestTestHTTP, NetworkErrorLogging_Redirect) { … }
TEST_F(URLRequestTestHTTP, NetworkErrorLogging_RedirectWithoutLocationHeader) { … }
TEST_F(URLRequestTestHTTP, NetworkErrorLogging_Auth) { … }
TEST_F(URLRequestTestHTTP, NetworkErrorLogging_304Response) { … }
TEST_F(URLRequestTestHTTP, NetworkErrorLogging_CancelInResponseStarted) { … }
TEST_F(URLRequestTestHTTP, NetworkErrorLogging_CancelOnDataReceived) { … }
TEST_F(URLRequestTestHTTP, NetworkErrorLogging_CancelRedirect) { … }
#endif
TEST_F(URLRequestTestHTTP, ContentTypeNormalizationTest) { … }
TEST_F(URLRequestTestHTTP, FileRedirect) { … }
TEST_F(URLRequestTestHTTP, DataRedirect) { … }
TEST_F(URLRequestTestHTTP, RestrictUnsafeRedirect) { … }
TEST_F(URLRequestTestHTTP, RedirectToInvalidURL) { … }
TEST_F(URLRequestTestHTTP, CacheRedirect) { … }
TEST_F(URLRequestTestHTTP, NoCacheOnNetworkDelegateRedirect) { … }
TEST_F(URLRequestTestHTTP, PreserveFragmentOnRedirectUrl) { … }
TEST_F(URLRequestTestHTTP, PreserveFragmentOnRedirectUrlMismatch) { … }
TEST_F(URLRequestTestHTTP, RedirectJobWithReferenceFragment) { … }
TEST_F(URLRequestTestHTTP, UnsupportedReferrerScheme) { … }
TEST_F(URLRequestTestHTTP, NoUserPassInReferrer) { … }
TEST_F(URLRequestTestHTTP, NoFragmentInReferrer) { … }
TEST_F(URLRequestTestHTTP, EmptyReferrerAfterValidReferrer) { … }
TEST_F(URLRequestTestHTTP, CapRefererHeaderLength) { … }
TEST_F(URLRequestTestHTTP, CancelRedirect) { … }
TEST_F(URLRequestTestHTTP, DeferredRedirect) { … }
TEST_F(URLRequestTestHTTP, DeferredRedirect_ModifiedHeaders) { … }
TEST_F(URLRequestTestHTTP, DeferredRedirect_RemovedHeaders) { … }
TEST_F(URLRequestTestHTTP, CancelDeferredRedirect) { … }
TEST_F(URLRequestTestHTTP, VaryHeader) { … }
TEST_F(URLRequestTestHTTP, BasicAuth) { … }
TEST_F(URLRequestTestHTTP, BasicAuthWithCookies) { … }
TEST_F(URLRequestTestHTTP, BasicAuthWithCredentialsWithCookies) { … }
TEST_F(URLRequestTestHTTP, BasicAuthWithCookiesCancelAuth) { … }
TEST_F(URLRequestTestHTTP, IsolationInfoUpdatedOnRedirect) { … }
TEST_F(URLRequestTestHTTP, AuthWithNetworkAnonymizationKey) { … }
TEST_F(URLRequestTest, ReportCookieActivity) { … }
TEST_F(URLRequestTest, NoCookieInclusionStatusWarningIfWouldBeExcludedAnyway) { … }
TEST_F(URLRequestTestHTTP, AuthChallengeCancelCookieCollect) { … }
TEST_F(URLRequestTestHTTP, AuthChallengeWithFilteredCookies) { … }
TEST_F(URLRequestTestHTTP, BasicAuthLoadTiming) { … }
TEST_F(URLRequestTestHTTP, Post302RedirectGet) { … }
TEST_F(URLRequestTestHTTP, Redirect301Tests) { … }
TEST_F(URLRequestTestHTTP, Redirect302Tests) { … }
TEST_F(URLRequestTestHTTP, Redirect303Tests) { … }
TEST_F(URLRequestTestHTTP, Redirect307Tests) { … }
TEST_F(URLRequestTestHTTP, Redirect308Tests) { … }
TEST_F(URLRequestTestHTTP, NoRedirectOn308WithoutLocationHeader) { … }
TEST_F(URLRequestTestHTTP, Redirect302PreserveReferenceFragment) { … }
TEST_F(URLRequestTestHTTP, RedirectWithFilteredCookies) { … }
TEST_F(URLRequestTestHTTP, RedirectPreserveFirstPartyURL) { … }
TEST_F(URLRequestTestHTTP, RedirectUpdateFirstPartyURL) { … }
TEST_F(URLRequestTestHTTP, InterceptPost302RedirectGet) { … }
TEST_F(URLRequestTestHTTP, InterceptPost307RedirectPost) { … }
TEST_F(URLRequestTestHTTP, DefaultAcceptLanguage) { … }
TEST_F(URLRequestTestHTTP, EmptyAcceptLanguage) { … }
TEST_F(URLRequestTestHTTP, OverrideAcceptLanguage) { … }
TEST_F(URLRequestTestHTTP, DefaultAcceptEncoding) { … }
TEST_F(URLRequestTestHTTP, DefaultAcceptEncodingOverriden) { … }
TEST_F(URLRequestTestHTTP, OverrideAcceptEncoding) { … }
TEST_F(URLRequestTestHTTP, SetAcceptCharset) { … }
TEST_F(URLRequestTestHTTP, DefaultUserAgent) { … }
#if BUILDFLAG(IS_IOS)
#define MAYBE_OverrideUserAgent …
#else
#define MAYBE_OverrideUserAgent …
#endif
TEST_F(URLRequestTestHTTP, MAYBE_OverrideUserAgent) { … }
TEST_F(URLRequestTestHTTP, EmptyHttpUserAgentSettings) { … }
TEST_F(URLRequestTestHTTP, SetSubsequentJobPriority) { … }
TEST_F(URLRequestTestHTTP, NetworkSuspendTest) { … }
namespace {
class FailingHttpTransactionFactory : public HttpTransactionFactory { … };
}
TEST_F(URLRequestTestHTTP, NetworkCancelAfterCreateTransactionFailsTest) { … }
TEST_F(URLRequestTestHTTP, NetworkAccessedSetOnNetworkRequest) { … }
TEST_F(URLRequestTestHTTP, NetworkAccessedClearOnCachedResponse) { … }
TEST_F(URLRequestTestHTTP, NetworkAccessedClearOnLoadOnlyFromCache) { … }
TEST_F(URLRequestTestHTTP, ThrottledPriority) { … }
TEST_F(URLRequestTestHTTP, RawBodyBytesNoContentEncoding) { … }
TEST_F(URLRequestTestHTTP, RawBodyBytesGzipEncoding) { … }
TEST_F(URLRequestTestHTTP, TesBeforeStartTransactionFails) { … }
class URLRequestTestReferrerPolicy : public URLRequestTest { … };
TEST_F(URLRequestTestReferrerPolicy, HTTPToSameOriginHTTP) { … }
TEST_F(URLRequestTestReferrerPolicy, HTTPToCrossOriginHTTP) { … }
TEST_F(URLRequestTestReferrerPolicy, HTTPSToSameOriginHTTPS) { … }
TEST_F(URLRequestTestReferrerPolicy, HTTPSToCrossOriginHTTPS) { … }
TEST_F(URLRequestTestReferrerPolicy, HTTPToHTTPS) { … }
TEST_F(URLRequestTestReferrerPolicy, HTTPSToHTTP) { … }
class HTTPSRequestTest : public TestWithTaskEnvironment { … };
TEST_F(HTTPSRequestTest, HTTPSGetTest) { … }
TEST_F(HTTPSRequestTest, HTTPSMismatchedTest) { … }
TEST_F(HTTPSRequestTest, HTTPSExpiredTest) { … }
class SSLNetErrorTestDelegate : public TestDelegate { … };
TEST_F(HTTPSRequestTest, SSLNetErrorReportedToDelegate) { … }
#if !BUILDFLAG(IS_IOS)
TEST_F(HTTPSRequestTest, HTTPSPreloadedHSTSTest) { … }
TEST_F(HTTPSRequestTest, HTTPSErrorsNoClobberTSSTest) { … }
TEST_F(HTTPSRequestTest, HSTSPreservesPosts) { … }
TEST_F(HTTPSRequestTest, HSTSCrossOriginAddHeaders) { … }
namespace {
class SSLClientAuthTestDelegate : public TestDelegate { … };
class TestSSLPrivateKey : public SSLPrivateKey { … };
}
TEST_F(HTTPSRequestTest, ClientAuthNoCertificate) { … }
TEST_F(HTTPSRequestTest, ClientAuth) { … }
TEST_F(HTTPSRequestTest, ClientAuthFailSigning) { … }
TEST_F(HTTPSRequestTest, ClientAuthFailSigningRetry) { … }
TEST_F(HTTPSRequestTest, ResumeTest) { … }
TEST_F(HTTPSRequestTest, SSLSessionCacheShardTest) { … }
TEST_F(HTTPSRequestTest, NoSessionResumptionBetweenPrivacyModes) { … }
class HTTPSFallbackTest : public TestWithTaskEnvironment { … };
TEST_F(HTTPSFallbackTest, TLSv1NoFallback) { … }
TEST_F(HTTPSFallbackTest, TLSv1_1NoFallback) { … }
TEST_F(HTTPSFallbackTest, TLSv1_2NoFallback) { … }
class HTTPSSessionTest : public TestWithTaskEnvironment { … };
TEST_F(HTTPSSessionTest, DontResumeSessionsForInvalidCertificates) { … }
class SecureDnsInterceptor : public net::URLRequestInterceptor { … };
class HTTPSCertNetFetchingTest : public HTTPSRequestTest { … };
static const char kEVTestCertPolicy[] = …;
class HTTPSEVTest : public HTTPSCertNetFetchingTest { … };
class HTTPSOCSPTest : public HTTPSCertNetFetchingTest { … };
static bool UsingBuiltinCertVerifier() { … }
static bool SystemSupportsHardFailRevocationChecking() { … }
static bool SystemUsesChromiumEVMetadata() { … }
static bool SystemSupportsOCSP() { … }
static bool SystemSupportsOCSPStapling() { … }
static bool SystemSupportsCRLSets() { … }
TEST_F(HTTPSEVTest, EVCheckNoOCSP) { … }
TEST_F(HTTPSOCSPTest, Valid) { … }
TEST_F(HTTPSOCSPTest, Revoked) { … }
TEST_F(HTTPSOCSPTest, Invalid) { … }
TEST_F(HTTPSOCSPTest, IntermediateValid) { … }
TEST_F(HTTPSOCSPTest, IntermediateResponseOldButStillValid) { … }
TEST_F(HTTPSOCSPTest, IntermediateResponseTooOldKnownRoot) { … }
TEST_F(HTTPSOCSPTest, IntermediateResponseTooOld) { … }
TEST_F(HTTPSOCSPTest, IntermediateRevoked) { … }
TEST_F(HTTPSOCSPTest, ValidStapled) { … }
TEST_F(HTTPSOCSPTest, RevokedStapled) { … }
TEST_F(HTTPSOCSPTest, OldStapledAndInvalidAIA) { … }
TEST_F(HTTPSOCSPTest, OldStapledButValidAIA) { … }
static const struct OCSPVerifyTestData { … } kOCSPVerifyData[] = …;
class HTTPSOCSPVerifyTest
: public HTTPSOCSPTest,
public testing::WithParamInterface<OCSPVerifyTestData> { … };
TEST_P(HTTPSOCSPVerifyTest, VerifyResult) { … }
INSTANTIATE_TEST_SUITE_P(…);
class HTTPSAIATest : public HTTPSCertNetFetchingTest { … };
TEST_F(HTTPSAIATest, AIAFetching) { … }
class HTTPSHardFailTest : public HTTPSOCSPTest { … };
TEST_F(HTTPSHardFailTest, Valid) { … }
TEST_F(HTTPSHardFailTest, Revoked) { … }
TEST_F(HTTPSHardFailTest, FailsOnOCSPInvalid) { … }
TEST_F(HTTPSHardFailTest, IntermediateResponseOldButStillValid) { … }
TEST_F(HTTPSHardFailTest, IntermediateResponseTooOld) { … }
TEST_F(HTTPSHardFailTest, ValidStapled) { … }
TEST_F(HTTPSHardFailTest, RevokedStapled) { … }
TEST_F(HTTPSHardFailTest, OldStapledAndInvalidAIA) { … }
TEST_F(HTTPSHardFailTest, OldStapledButValidAIA) { … }
class HTTPSCRLSetTest : public HTTPSCertNetFetchingTest { … };
TEST_F(HTTPSCRLSetTest, ExpiredCRLSet) { … }
TEST_F(HTTPSCRLSetTest, ExpiredCRLSetAndRevoked) { … }
TEST_F(HTTPSCRLSetTest, CRLSetRevoked) { … }
TEST_F(HTTPSCRLSetTest, CRLSetRevokedBySubject) { … }
HTTPSLocalCRLSetTest;
TEST_F(HTTPSLocalCRLSetTest, KnownInterceptionBlocked) { … }
TEST_F(HTTPSLocalCRLSetTest, InterceptionBlockedAllowOverrideOnHSTS) { … }
#endif
TEST_F(URLRequestTest, NetworkAccessedSetOnHostResolutionFailure) { … }
TEST_F(URLRequestTest, URLRequestRedirectJobCancelRequest) { … }
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_CHROMEOS)
#define MAYBE_HeadersCallbacks …
#else
#define MAYBE_HeadersCallbacks …
#endif
TEST_F(URLRequestTestHTTP, MAYBE_HeadersCallbacks) { … }
TEST_F(URLRequestTestHTTP, HeadersCallbacksWithRedirect) { … }
TEST_F(URLRequestTest, HeadersCallbacksConnectFailed) { … }
TEST_F(URLRequestTestHTTP, HeadersCallbacksAuthRetry) { … }
TEST_F(URLRequestTest, UpgradeIfInsecureFlagSet) { … }
TEST_F(URLRequestTest, UpgradeIfInsecureFlagSetExplicitPort80) { … }
TEST_F(URLRequestTest, UpgradeIfInsecureFlagSetNonStandardPort) { … }
TEST_F(URLRequestTest, UpgradeIfInsecureFlagNotSet) { … }
#if BUILDFLAG(IS_ANDROID)
TEST_F(URLRequestTestHTTP, TestTagging) {
if (!CanGetTaggedBytes()) {
DVLOG(0) << "Skipping test - GetTaggedBytes unsupported.";
return;
}
ASSERT_TRUE(http_test_server()->Start());
static const int32_t UNTAGGED_TAG = 0;
uint64_t old_traffic = GetTaggedBytes(UNTAGGED_TAG);
TestDelegate delegate;
std::unique_ptr<URLRequest> req(default_context().CreateRequest(
http_test_server()->GetURL("/"), DEFAULT_PRIORITY, &delegate,
TRAFFIC_ANNOTATION_FOR_TESTS));
EXPECT_EQ(SocketTag(), req->socket_tag());
req->Start();
delegate.RunUntilComplete();
EXPECT_GT(GetTaggedBytes(UNTAGGED_TAG), old_traffic);
int32_t tag_val1 = 0x12345678;
SocketTag tag1(SocketTag::UNSET_UID, tag_val1);
old_traffic = GetTaggedBytes(tag_val1);
req = default_context().CreateRequest(http_test_server()->GetURL("/"),
DEFAULT_PRIORITY, &delegate,
TRAFFIC_ANNOTATION_FOR_TESTS);
req->set_socket_tag(tag1);
EXPECT_EQ(tag1, req->socket_tag());
req->Start();
delegate.RunUntilComplete();
EXPECT_GT(GetTaggedBytes(tag_val1), old_traffic);
}
#endif
namespace {
class ReadBufferingListener
: public test_server::EmbeddedTestServerConnectionListener { … };
class ZeroRTTResponse : public test_server::BasicHttpResponse { … };
std::unique_ptr<test_server::HttpResponse> HandleZeroRTTRequest(
const test_server::HttpRequest& request) { … }
}
class HTTPSEarlyDataTest : public TestWithTaskEnvironment { … };
TEST_F(HTTPSEarlyDataTest, TLSEarlyDataTest) { … }
TEST_F(HTTPSEarlyDataTest, TLSEarlyDataPOSTTest) { … }
TEST_F(HTTPSEarlyDataTest, TLSEarlyDataIdempotentPOSTTest) { … }
TEST_F(HTTPSEarlyDataTest, TLSEarlyDataNonIdempotentRequestTest) { … }
std::unique_ptr<test_server::HttpResponse> HandleTooEarly(
bool* sent_425,
const test_server::HttpRequest& request) { … }
TEST_F(HTTPSEarlyDataTest, TLSEarlyDataTooEarlyTest) { … }
TEST_F(HTTPSEarlyDataTest, TLSEarlyDataRejectTest) { … }
TEST_F(HTTPSEarlyDataTest, TLSEarlyDataTLS12RejectTest) { … }
TEST_F(URLRequestTestHTTP, AuthChallengeInfo) { … }
TEST_F(URLRequestTestHTTP, ConnectNoSupported) { … }
class URLRequestDnsAliasTest : public TestWithTaskEnvironment { … };
TEST_F(URLRequestDnsAliasTest, WithDnsAliases) { … }
TEST_F(URLRequestDnsAliasTest, NoAdditionalDnsAliases) { … }
TEST_F(URLRequestTest, SetURLChain) { … }
TEST_F(URLRequestTest, SetIsolationInfoFromNak) { … }
TEST_F(URLRequestTest, CookiePartitionKey) { … }
class URLRequestMaybeAsyncFirstPartySetsTest
: public URLRequestTest,
public testing::WithParamInterface<bool> { … };
TEST_P(URLRequestMaybeAsyncFirstPartySetsTest, SimpleRequest) { … }
TEST_P(URLRequestMaybeAsyncFirstPartySetsTest, SingleRedirect) { … }
INSTANTIATE_TEST_SUITE_P(…);
class PartitionConnectionsByNetworkAnonymizationKey : public URLRequestTest { … };
TEST_F(PartitionConnectionsByNetworkAnonymizationKey,
DifferentTopFrameSitesNeverShareConnections) { … }
TEST_F(PartitionConnectionsByNetworkAnonymizationKey,
FirstPartyIsSeparatedFromCrossSiteFrames) { … }
TEST_F(
PartitionConnectionsByNetworkAnonymizationKey,
DifferentCrossSiteFramesAreSeparatedOnlyWhenNetworkAnonymizationKeyIsTripleKeyed) { … }
TEST_F(PartitionConnectionsByNetworkAnonymizationKey,
DifferentNoncesAreAlwaysSeparated) { … }
class PatternedExpectBypassCacheNetworkDelegate : public TestNetworkDelegate { … };
class StorageAccessHeaderURLRequestTest : public URLRequestTestHTTP { … };
TEST_F(StorageAccessHeaderURLRequestTest, StorageAccessHeaderRetry) { … }
TEST_F(StorageAccessHeaderURLRequestTest,
StorageAccessHeaderRetry_RedirectPrioritizesRetryHeader) { … }
TEST_F(StorageAccessHeaderURLRequestTest,
StorageAccessHeaderRetry_AuthChallengeIgnoresRetryHeader) { … }
TEST_F(StorageAccessHeaderURLRequestTest,
StorageAccessHeaderRetry_AuthWithoutChallengeHonorsRetryHeader) { … }
TEST_F(StorageAccessHeaderURLRequestTest,
StorageAccessHeaderRetry_SurvivesPostAuthRetries) { … }
}