chromium/third_party/blink/renderer/modules/ad_auction/validate_blink_interest_group_test.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 "third_party/blink/renderer/modules/ad_auction/validate_blink_interest_group.h"

#include "base/memory/scoped_refptr.h"
#include "base/strings/stringprintf.h"
#include "base/test/scoped_feature_list.h"
#include "mojo/public/cpp/bindings/map_traits_wtf_hash_map.h"
#include "mojo/public/cpp/bindings/message.h"
#include "mojo/public/cpp/test_support/test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/common/interest_group/interest_group.h"
#include "third_party/blink/public/mojom/interest_group/ad_display_size.mojom-blink.h"
#include "third_party/blink/public/mojom/interest_group/interest_group_types.mojom-blink.h"
#include "third_party/blink/public/mojom/interest_group/interest_group_types.mojom.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/testing/task_environment.h"
#include "third_party/blink/renderer/platform/weborigin/kurl.h"
#include "third_party/blink/renderer/platform/weborigin/security_origin.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
#include "url/gurl.h"
#include "url/origin.h"

namespace blink {

namespace {

constexpr char kOriginString[] =;
constexpr char kNameString[] =;
constexpr char kCoordinatorOriginString[] =;

mojom::blink::InterestGroupAdPtr MakeAdWithUrl(const KURL& url) {}

}  // namespace

// Test fixture for testing both ValidateBlinkInterestGroup() and
// ValidateInterestGroup(), and making sure they behave the same.
class ValidateBlinkInterestGroupTest : public testing::Test {};

// Test behavior with an InterestGroup with as few fields populated as allowed.
TEST_F(ValidateBlinkInterestGroupTest, MinimallyPopulated) {}

// Test behavior with an InterestGroup with all fields populated with valid
// values.
TEST_F(ValidateBlinkInterestGroupTest, FullyPopulated) {}

// Make sure that non-HTTPS origins are rejected, both as the frame origin, and
// as the owner. HTTPS frame origins with non-HTTPS owners are currently
// rejected due to origin mismatch, but once sites can add users to 3P interest
// groups, they should still be rejected for being non-HTTPS.
TEST_F(ValidateBlinkInterestGroupTest, NonHttpsOriginRejected) {}

// Same as NonHttpsOriginRejected, but for `seller_capabilities`.
TEST_F(ValidateBlinkInterestGroupTest,
       NonHttpsOriginRejectedSellerCapabilities) {}

// Check that `bidding_url`, `bidding_wasm_helper_url`, `update_url`, and
// `trusted_bidding_signals_url` must be same-origin and HTTPS.
//
// Ad URLs do not have to be same origin, so they're checked in a different
// test.
TEST_F(ValidateBlinkInterestGroupTest, RejectedUrls) {}

// If the feature enabling cross-origin trusted signals URL to be accepted
// is on, they will be, but other checks still happen.
// TODO(morlovich): Once this is on by default, this should be merged with the
// above test.
TEST_F(ValidateBlinkInterestGroupTest,
       CrossOriginTrustedBiddingSignalsUrlPermitted) {}

// Tests valid and invalid ad render URLs.
TEST_F(ValidateBlinkInterestGroupTest, AdRenderUrlValidation) {}

// Tests valid and invalid ad render URLs.
TEST_F(ValidateBlinkInterestGroupTest, AdComponentRenderUrlValidation) {}

// Mojo rejects malformed URLs when converting mojom::blink::InterestGroup to
// blink::InterestGroup. Since the rejection happens internally in Mojo,
// typemapping code that invokes blink::InterestGroup::IsValid() isn't run, so
// adding a AdRenderUrlValidation testcase to verify malformed URLs wouldn't
// exercise blink::InterestGroup::IsValid(). Since blink::InterestGroup users
// can call IsValid() directly (i.e when not using Mojo), we need a test that
// also calls IsValid() directly.
TEST_F(ValidateBlinkInterestGroupTest, MalformedUrl) {}

TEST_F(ValidateBlinkInterestGroupTest, TooLarge) {}

TEST_F(ValidateBlinkInterestGroupTest, TooLargePriorityVector) {}

TEST_F(ValidateBlinkInterestGroupTest, TooLargePrioritySignalsOverride) {}

TEST_F(ValidateBlinkInterestGroupTest, TooLargeSellerCapabilities) {}

TEST_F(ValidateBlinkInterestGroupTest, TooLargeAdSizes) {}

TEST_F(ValidateBlinkInterestGroupTest, TooLargeSizeGroups) {}

TEST_F(ValidateBlinkInterestGroupTest, TooLargeAds) {}

TEST_F(ValidateBlinkInterestGroupTest, InvalidAdSizes) {}

TEST_F(ValidateBlinkInterestGroupTest, InvalidSizeGroups) {}

TEST_F(ValidateBlinkInterestGroupTest, AdSizeGroupEmptyNameOrNotInSizeGroups) {}

TEST_F(ValidateBlinkInterestGroupTest,
       AdComponentSizeGroupEmptyNameOrNotInSizeGroups) {}

TEST_F(ValidateBlinkInterestGroupTest, AdRenderIdTooLong) {}

TEST_F(ValidateBlinkInterestGroupTest, AdComponentRenderIdTooLong) {}

// The interest group is invalid if its ad object's "allowedReporting" field
// have more than `kMaxAllowedReportingOrigins` elements.
TEST_F(ValidateBlinkInterestGroupTest, AdTooManyAllowedReportingOrigins) {}

TEST_F(ValidateBlinkInterestGroupTest, AdNonHttpsAllowedReportingOrigins) {}

// Test behavior with a negative InterestGroup.
TEST_F(ValidateBlinkInterestGroupTest, JustAdditionalBidKeyIsValid) {}

TEST_F(ValidateBlinkInterestGroupTest, AdditionalBidKeyWrongSize) {}

TEST_F(ValidateBlinkInterestGroupTest,
       AdditionalBidKeyAndAdsNotAllowedTogether) {}

TEST_F(ValidateBlinkInterestGroupTest, AggregationCoordinatorNotHTTPS) {}

TEST_F(ValidateBlinkInterestGroupTest, AggregationCoordinatorInvalid) {}

TEST_F(ValidateBlinkInterestGroupTest,
       AdditionalBidKeyAndUpdateURLNotAllowedTogether) {}

TEST_F(ValidateBlinkInterestGroupTest,
       MaxTrustedBiddingSignalsURLLengthMustNotBeNegative) {}

TEST_F(ValidateBlinkInterestGroupTest,
       InvalidTrustedBiddingSignalsCoordinator) {}

}  // namespace blink