chromium/chrome/browser/k_anonymity_service/k_anonymity_service_client_unittest.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 "chrome/browser/k_anonymity_service/k_anonymity_service_client.h"

#include "base/containers/flat_map.h"
#include "base/functional/callback.h"
#include "base/run_loop.h"
#include "base/strings/string_util.h"
#include "base/test/bind.h"
#include "base/test/metrics/histogram_tester.h"
#include "chrome/browser/k_anonymity_service/k_anonymity_service_metrics.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/signin/identity_test_environment_profile_adaptor.h"
#include "chrome/common/chrome_features.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "chrome/test/base/testing_profile_manager.h"
#include "components/signin/public/identity_manager/account_capabilities_test_mutator.h"
#include "components/signin/public/identity_manager/identity_manager.h"
#include "content/public/browser/k_anonymity_service_delegate.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/test/browser_task_environment.h"
#include "crypto/sha2.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
#include "services/data_decoder/public/cpp/test_support/in_process_data_decoder.h"
#include "services/network/public/cpp/features.h"
#include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h"
#include "services/network/test/test_network_context.h"
#include "services/network/test/test_url_loader_factory.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace {

class KAnonymityServiceClientTest : public testing::Test {};

// JoinSet fails because the user is not logged in and doesn't have the
// capability needed to use the K-AnonymityService.
TEST_F(KAnonymityServiceClientTest, TryJoinSetFails) {}

TEST_F(KAnonymityServiceClientTest, TryJoinSetSuccess) {}

TEST_F(KAnonymityServiceClientTest, TryJoinSetRepeatedly) {}

TEST_F(KAnonymityServiceClientTest, TryJoinSetOneAtATime) {}

TEST_F(KAnonymityServiceClientTest, TryJoinSetFailureDropsAllRequests) {}

TEST_F(KAnonymityServiceClientTest, TryJoinSetOverflowQueue) {}

// Query fails because the user is not logged in and doesn't have the
// capability needed to use the K-AnonymityService.
TEST_F(KAnonymityServiceClientTest, TryQuerySetFailed) {}

TEST_F(KAnonymityServiceClientTest, TryQuerySetAllNotKAnon) {}

class TestTrustTokenQueryAnswerer
    : public network::mojom::TrustTokenQueryAnswerer {};

const char kJoinRelayURL[] =;
const char kQueryRelayURL[] =;

class OhttpTestNetworkContext : public network::TestNetworkContext {};

class KAnonymityServiceClientJoinQueryTest
    : public KAnonymityServiceClientTest {};

TEST_F(KAnonymityServiceClientJoinQueryTest, TryJoinSetGetOHTTPKeyFailed) {}

TEST_F(KAnonymityServiceClientJoinQueryTest, TryJoinSetSignedIn) {}

TEST_F(KAnonymityServiceClientJoinQueryTest, TryJoinSetNetworkDrop) {}

TEST_F(KAnonymityServiceClientJoinQueryTest, TryJoinSetTokenAlreadyUsedOnce) {}

TEST_F(KAnonymityServiceClientJoinQueryTest,
       TryJoinSetOtherNetErrorsNotRetried) {}

TEST_F(KAnonymityServiceClientJoinQueryTest,
       TryJoinSetOtherOuterHttpStatusErrorNotRetried) {}

TEST_F(KAnonymityServiceClientJoinQueryTest,
       TryJoinSetOtherInnerHttpStatusErrorNotRetried) {}

TEST_F(KAnonymityServiceClientJoinQueryTest,
       TryJoinSetTokenAlreadyRetriedTooMany) {}

TEST_F(KAnonymityServiceClientJoinQueryTest, TryQuerySetGetOHTTPKeyFailed) {}

TEST_F(KAnonymityServiceClientJoinQueryTest, TryQuerySetBadResponse) {}

TEST_F(KAnonymityServiceClientJoinQueryTest, TryQuerySet) {}

TEST_F(KAnonymityServiceClientJoinQueryTest, TryQuerySetMultipleSets) {}

TEST_F(KAnonymityServiceClientJoinQueryTest, TryQuerySetCoalescesSplitSets) {}

TEST_F(KAnonymityServiceClientJoinQueryTest,
       TryQuerySetSingleFailureDropsAllRequests) {}

// This test is disabled as the current policy blocks running in OTR mode
// entirely.
// TODO(behamilton): Re-enable this test when we are allowed to run in OTR mode.
TEST_F(KAnonymityServiceClientJoinQueryTest,
       DISABLED_StorageDoesNotPersistWhenOffTheRecord) {}

}  // namespace