chromium/components/privacy_sandbox/privacy_sandbox_attestations/privacy_sandbox_attestations_parser_unittest.cc

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

#include "components/privacy_sandbox/privacy_sandbox_attestations/privacy_sandbox_attestations_parser.h"

#include <string>

#include "base/containers/enum_set.h"
#include "base/containers/flat_map.h"
#include "base/test/with_feature_override.h"
#include "components/privacy_sandbox/privacy_sandbox_attestations/proto/privacy_sandbox_attestations.pb.h"
#include "net/base/schemeful_site.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/features.h"
#include "url/gurl.h"

namespace privacy_sandbox {

class PrivacySandboxAttestationsParserTest : public testing::Test {};

// A completely empty proto gets parsed as an empty map.
TEST_F(PrivacySandboxAttestationsParserTest, EmptyProto) {}

// A malformed proto returns std::nullopt to represent an error.
TEST_F(PrivacySandboxAttestationsParserTest, InvalidProto) {}

// A map with one API for each site should correctly map the APIs between proto
// and C++.
TEST_F(PrivacySandboxAttestationsParserTest, OneSitePerAPIProto) {}

// Multiple attested APIs per site should work. Unknown APIs should be ignored.
TEST_F(PrivacySandboxAttestationsParserTest, MultipleAPIsPerSiteProto) {}

// Test basic functionality of `all_apis` and `sites_attested_for_all_apis`.
// Let "all APIs" be Topics, Protected Audience, and Private Aggregation.
// Have two sites attested for "all APIs", and one site attested for Private
// Aggregation and Shared Storage only.
TEST_F(PrivacySandboxAttestationsParserTest, AllAPIsProto) {}

// Test that nothing goes terribly wrong when the proto has multiple mappings
// for a single site (which should never happen in real use).
TEST_F(PrivacySandboxAttestationsParserTest, RepeatedSiteProto) {}

// Test that invalid API enums in `all_apis` are ignored.
TEST_F(PrivacySandboxAttestationsParserTest, InvalidAllAPIsProto) {}

// When 'FencedFramesLocalUnpartitionedDataAccess' feature is enabled, there
// will be a new attestation API `LOCAL_UNPARTITIONED_DATA_ACCESS`.
class FencedFramesLocalUnpartitionedDataAccessAttestationTest
    : public base::test::WithFeatureOverride,
      public PrivacySandboxAttestationsParserTest {};

TEST_P(FencedFramesLocalUnpartitionedDataAccessAttestationTest,
       LocalUnpartitionedDataAccessAttestationEnum) {}

TEST_P(FencedFramesLocalUnpartitionedDataAccessAttestationTest, AllAPIs) {}

TEST_P(FencedFramesLocalUnpartitionedDataAccessAttestationTest,
       AllAPIsWithLocalUnpartitionedDataAccess) {}

INSTANTIATE_FEATURE_OVERRIDE_TEST_SUITE();

}  // namespace privacy_sandbox