chromium/services/network/cors/cors_url_loader_test_util.cc

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

#include "services/network/cors/cors_url_loader_test_util.h"

#include "base/functional/callback.h"
#include "base/memory/ref_counted.h"
#include "base/notreached.h"
#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
#include "mojo/public/cpp/system/data_pipe.h"
#include "net/base/scheme_host_port_matcher_rule.h"
#include "net/http/http_response_headers.h"
#include "net/log/net_log_entry.h"
#include "net/log/net_log_event_type.h"
#include "net/proxy_resolution/configured_proxy_resolution_service.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_builder.h"
#include "services/network/cors/cors_url_loader_factory.h"
#include "services/network/is_browser_initiated.h"
#include "services/network/network_service.h"
#include "services/network/prefetch_matching_url_loader_factory.h"
#include "services/network/public/cpp/parsed_headers.h"
#include "services/network/public/cpp/url_loader_completion_status.h"
#include "services/network/public/mojom/client_security_state.mojom.h"
#include "services/network/public/mojom/early_hints.mojom.h"
#include "services/network/public/mojom/ip_address_space.mojom.h"
#include "services/network/public/mojom/referrer_policy.mojom.h"
#include "services/network/public/mojom/url_response_head.mojom.h"
#include "services/network/resource_scheduler/resource_scheduler_client.h"
#include "services/network/test/fake_test_cert_verifier_params_factory.h"
#include "services/network/test/mock_devtools_observer.h"
#include "services/network/test/test_url_loader_client.h"
#include "url/gurl.h"
#include "url/origin.h"

namespace network::cors {

// TEST URL LOADER FACTORY
// =======================

TestURLLoaderFactory::TestURLLoaderFactory() = default;

TestURLLoaderFactory::~TestURLLoaderFactory() = default;

base::WeakPtr<TestURLLoaderFactory> TestURLLoaderFactory::GetWeakPtr() {}

void TestURLLoaderFactory::NotifyClientOnReceiveEarlyHints(
    const std::vector<std::pair<std::string, std::string>>& headers) {}

void TestURLLoaderFactory::NotifyClientOnReceiveResponse(
    int status_code,
    const std::vector<std::pair<std::string, std::string>>& extra_headers,
    mojo::ScopedDataPipeConsumerHandle body) {}

void TestURLLoaderFactory::NotifyClientOnComplete(int error_code) {}

void TestURLLoaderFactory::NotifyClientOnComplete(
    const CorsErrorStatus& status) {}

void TestURLLoaderFactory::NotifyClientOnReceiveRedirect(
    const net::RedirectInfo& redirect_info,
    const std::vector<std::pair<std::string, std::string>>& extra_headers) {}

void TestURLLoaderFactory::ResetClientRemote() {}

void TestURLLoaderFactory::CreateLoaderAndStart(
    mojo::PendingReceiver<mojom::URLLoader> receiver,
    int32_t request_id,
    uint32_t options,
    const ResourceRequest& resource_request,
    mojo::PendingRemote<mojom::URLLoaderClient> client,
    const net::MutableNetworkTrafficAnnotationTag& traffic_annotation) {}

void TestURLLoaderFactory::Clone(
    mojo::PendingReceiver<mojom::URLLoaderFactory> receiver) {}

// RESET FACTORY PARAMS
// ====================

CorsURLLoaderTestBase::ResetFactoryParams::ResetFactoryParams() {}

CorsURLLoaderTestBase::ResetFactoryParams::~ResetFactoryParams() = default;

// CORS URL LOADER TEST BASE
// =========================

CorsURLLoaderTestBase::CorsURLLoaderTestBase(bool shared_dictionary_enabled)
    :{}

CorsURLLoaderTestBase::~CorsURLLoaderTestBase() = default;

void CorsURLLoaderTestBase::CreateLoaderAndStart(
    const GURL& origin,
    const GURL& url,
    mojom::RequestMode mode,
    mojom::RedirectMode redirect_mode,
    mojom::CredentialsMode credentials_mode) {}

void CorsURLLoaderTestBase::CreateLoaderAndStart(
    const ResourceRequest& request) {}

void CorsURLLoaderTestBase::ClearHasReceivedRedirect() {}

void CorsURLLoaderTestBase::RunUntilCreateLoaderAndStartCalled() {}

void CorsURLLoaderTestBase::RunUntilComplete() {}

void CorsURLLoaderTestBase::RunUntilRedirectReceived() {}

void CorsURLLoaderTestBase::AddAllowListEntryForOrigin(
    const url::Origin& source_origin,
    const std::string& protocol,
    const std::string& domain,
    const mojom::CorsDomainMatchMode mode) {}

void CorsURLLoaderTestBase::AddBlockListEntryForOrigin(
    const url::Origin& source_origin,
    const std::string& protocol,
    const std::string& domain,
    const mojom::CorsDomainMatchMode mode) {}

void CorsURLLoaderTestBase::ResetFactory(std::optional<url::Origin> initiator,
                                         uint32_t process_id,
                                         const ResetFactoryParams& params) {}

std::vector<net::NetLogEntry> CorsURLLoaderTestBase::GetEntries() const {}

// static.
std::vector<net::NetLogEventType>
CorsURLLoaderTestBase::GetTypesOfNetLogEntries(
    const std::vector<net::NetLogEntry>& entries) {}

// static.
const net::NetLogEntry* CorsURLLoaderTestBase::FindEntryByType(
    const std::vector<net::NetLogEntry>& entries,
    net::NetLogEventType type) {}

net::RedirectInfo CorsURLLoaderTestBase::CreateRedirectInfo(
    int status_code,
    std::string_view method,
    const GURL& url,
    std::string_view referrer,
    net::ReferrerPolicy referrer_policy,
    net::SiteForCookies site_for_cookies) {}

}  // namespace network::cors