chromium/content/browser/interest_group/auction_url_loader_factory_proxy_unittest.cc

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

#include "content/browser/interest_group/auction_url_loader_factory_proxy.h"

#include <stdint.h>

#include <vector>

#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/ref_counted.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/test/bind.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "content/browser/interest_group/auction_worklet_manager.h"
#include "content/browser/interest_group/subresource_url_builder.h"
#include "content/public/browser/render_frame_host.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "net/base/isolation_info.h"
#include "net/base/load_flags.h"
#include "net/base/network_anonymization_key.h"
#include "net/base/schemeful_site.h"
#include "net/cookies/site_for_cookies.h"
#include "net/http/http_request_headers.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "services/network/public/cpp/resource_request.h"
#include "services/network/public/mojom/client_security_state.mojom.h"
#include "services/network/public/mojom/ip_address_space.mojom.h"
#include "services/network/public/mojom/url_loader_factory.mojom.h"
#include "services/network/test/test_url_loader_factory.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/common/interest_group/auction_config.h"
#include "url/gurl.h"
#include "url/origin.h"

namespace content {

namespace {

WorkletHandle;
BundleSubresourceInfo;

const char kScriptUrl[] =;
const char kWasmUrl[] =;
const char kTrustedSignalsBaseUrl[] =;
// Basic example of a trusted signals URL. Seller signals typically have URLs as
// keys, but AuctionUrlLoaderProxy doesn't currently verify that.
const char kTrustedSignalsUrl[] =;

const char kAdAuctionTrustedSignalsContentType[] =;

// Values for the Accept header.
const char kAcceptJavascript[] =;
const char kAcceptJson[] =;
const char kAcceptAdAuctionTrustedSignals[] =;
const char kAcceptOther[] =;
const char kAcceptWasm[] =;

const char kBundleUrl[] =;

const int kRenderProcessId =;

// The AuctionUrlLoaerFactoryProxy doesn't care which URL is used; its users are
// responsible for setting the correct URLs for the correct proxy.
const char kSubresourceUrl1[] =;
const char kSubresourceUrl2[] =;
const char kSubresourceUrl3[] =;

// We don't need to actually make real WorkletHandles --
// SubresourceUrlAuthorizations only cares about the addresses of
// WorkletHandles, so we can use hard-coded pointers.
const WorkletHandle* const kWorkletHandle1 =;

const WorkletHandle* const kWorkletHandle2 =;

BundleSubresourceInfo MakeBundleSubresourceInfo(
    const std::string& bundle_url,
    const std::string& subresource_url) {}

}  // namespace

class AuctionUrlLoaderFactoryProxyTest : public testing::TestWithParam<bool> {};

TEST_P(AuctionUrlLoaderFactoryProxyTest, Basic) {}

TEST_P(AuctionUrlLoaderFactoryProxyTest, ForceReload) {}

TEST_P(AuctionUrlLoaderFactoryProxyTest, NoWasmUrl) {}

TEST_P(AuctionUrlLoaderFactoryProxyTest, NoTrustedSignalsUrl) {}

// This test focuses on validation of the requested trusted signals URLs.
TEST_P(AuctionUrlLoaderFactoryProxyTest, TrustedSignalsUrl) {}

// Make sure all seller signals requests use the same transient
// NetworkAnonymizationKey.
TEST_P(AuctionUrlLoaderFactoryProxyTest, SellerSignalsNetworkIsolationKey) {}

// Test the case the same URL is used for trusted signals and the script (which
// seems weird, but should still work).
TEST_P(AuctionUrlLoaderFactoryProxyTest, SameUrl) {}

// Make sure that proxies for bidder worklets pass through ClientSecurityState.
// This test relies on the ClientSecurityState equality check in
// TryMakeRequest().
TEST_P(AuctionUrlLoaderFactoryProxyTest, ClientSecurityState) {}

TEST_P(AuctionUrlLoaderFactoryProxyTest, BasicSubresourceBundles1) {}

TEST_P(AuctionUrlLoaderFactoryProxyTest, BasicSubresourceBundles2) {}

TEST_P(AuctionUrlLoaderFactoryProxyTest, AdditionalBidCors) {}

INSTANTIATE_TEST_SUITE_P();
}  // namespace content