chromium/chrome/browser/ip_protection/ip_protection_config_provider_browsertest.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 "chrome/browser/ip_protection/ip_protection_config_provider.h"

#include <string>
#include <vector>

#include "base/callback_list.h"
#include "base/test/bind.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/test_future.h"
#include "base/time/time.h"
#include "base/values.h"
#include "chrome/browser/ip_protection/ip_protection_config_provider_factory.h"
#include "chrome/browser/policy/policy_test_utils.h"
#include "chrome/browser/profiles/profile_test_util.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/signin/identity_test_environment_profile_adaptor.h"
#include "chrome/test/base/chrome_test_utils.h"
#include "chrome/test/base/platform_browser_test.h"
#include "components/ip_protection/common/ip_protection_data_types.h"
#include "components/policy/core/common/policy_map.h"
#include "components/policy/core/common/policy_types.h"
#include "components/policy/policy_constants.h"
#include "components/privacy_sandbox/privacy_sandbox_features.h"
#include "components/signin/public/base/consent_level.h"
#include "components/signin/public/identity_manager/identity_test_utils.h"
#include "content/public/browser/network_service_util.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/test/browser_test.h"
#include "mojo/public/cpp/bindings/receiver_set.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "net/base/features.h"
#include "services/network/public/cpp/features.h"
#include "services/network/public/mojom/network_context.mojom-test-utils.h"
#include "services/network/public/mojom/network_context.mojom.h"

#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
#include "components/signin/public/identity_manager/primary_account_change_event.h"
#endif

BlindSignedAuthToken;
GeoHint;

namespace {
class ScopedIpProtectionFeatureList {};

// Helper class to intercept `IpProtectionConfigGetter::TryGetAuthTokens()`
// requests and return a fake token value and a fake expiration value for
// testing.
class IpProtectionConfigGetterInterceptor
    : public network::mojom::IpProtectionConfigGetterInterceptorForTesting {};

constexpr base::Time kDontRetry =;
}  // namespace

class IpProtectionConfigProviderBrowserTest : public PlatformBrowserTest {};

IN_PROC_BROWSER_TEST_F(IpProtectionConfigProviderBrowserTest,
                       NetworkServiceCanRequestTokens) {}

IN_PROC_BROWSER_TEST_F(IpProtectionConfigProviderBrowserTest,
                       ExpectedReceiverSetStateAfterNetworkServiceCrash) {}

#if !BUILDFLAG(IS_ANDROID)
class IpProtectionConfigProviderIdentityBrowserTest
    : public IpProtectionConfigProviderBrowserTest {};

IN_PROC_BROWSER_TEST_F(IpProtectionConfigProviderIdentityBrowserTest,
                       BackoffTimeResetAfterProfileAvailabilityChange) {}
#endif

class IpProtectionConfigProviderUserSettingBrowserTest
    : public IpProtectionConfigProviderBrowserTest {};

IN_PROC_BROWSER_TEST_F(IpProtectionConfigProviderUserSettingBrowserTest,
                       OnIpProtectionEnabledChanged) {}

class IpProtectionConfigProviderPolicyBrowserTest : public policy::PolicyTest {};

IN_PROC_BROWSER_TEST_F(IpProtectionConfigProviderPolicyBrowserTest,
                       IpProtectionEnterprisePolicyDisableAndEnable) {}

// Test transitioning from the policy being set to the policy being unset - the
// pref value should no longer be considered managed and should effectively be
// reset to its initial state.
IN_PROC_BROWSER_TEST_F(IpProtectionConfigProviderPolicyBrowserTest,
                       IpProtectionEnterprisePolicyUnsetAfterSet) {}