chromium/components/policy/core/browser/url_blocklist_policy_handler_unittest.cc

// Copyright 2014 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/policy/core/browser/url_blocklist_policy_handler.h"

#include <memory>
#include <utility>

#include "base/strings/string_number_conversions.h"
#include "base/values.h"
#include "build/build_config.h"
#include "components/policy/core/browser/policy_error_map.h"
#include "components/policy/core/common/policy_map.h"
#include "components/policy/core/common/policy_pref_names.h"
#include "components/policy/core/common/policy_types.h"
#include "components/policy/policy_constants.h"
#include "components/prefs/pref_value_map.h"
#include "components/strings/grit/components_strings.h"
#include "components/url_matcher/url_util.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/l10n/l10n_util.h"

// Note: this file should move to components/policy/core/browser, but the
// components_unittests runner does not load the ResourceBundle as
// ChromeTestSuite::Initialize does, which leads to failures using
// PolicyErrorMap.

namespace policy {

namespace {

#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS)
const char kTestDisabledScheme[] =;
#endif
const char kTestBlocklistValue[] =;

}  // namespace

class URLBlocklistPolicyHandlerTest : public testing::Test {};

TEST_F(URLBlocklistPolicyHandlerTest,
       CheckPolicySettings_DisabledSchemesUnspecified) {}

#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS)
TEST_F(URLBlocklistPolicyHandlerTest,
       CheckPolicySettings_URLBlocklistUnspecified) {}

TEST_F(URLBlocklistPolicyHandlerTest,
       CheckPolicySettings_DisabledSchemesWrongType) {}
#endif

TEST_F(URLBlocklistPolicyHandlerTest,
       CheckPolicySettings_URLBlocklistWrongType) {}

TEST_F(URLBlocklistPolicyHandlerTest, ApplyPolicySettings_NothingSpecified) {}

#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS)
TEST_F(URLBlocklistPolicyHandlerTest,
       ApplyPolicySettings_DisabledSchemesWrongType) {}

TEST_F(URLBlocklistPolicyHandlerTest,
       ApplyPolicySettings_DisabledSchemesEmpty) {}

TEST_F(URLBlocklistPolicyHandlerTest,
       ApplyPolicySettings_DisabledSchemesWrongElementType) {}

TEST_F(URLBlocklistPolicyHandlerTest,
       ApplyPolicySettings_DisabledSchemesSuccessful) {}

TEST_F(URLBlocklistPolicyHandlerTest, ApplyPolicySettings_MergeSuccessful) {}

// Test that the warning message, mapped to
// |IDS_POLICY_URL_ALLOW_BLOCK_LIST_MAX_FILTERS_LIMIT_WARNING|, is added to
// |errors_| when URLBlocklist + DisabledScheme entries exceed the max filters
// per policy limit.
TEST_F(URLBlocklistPolicyHandlerTest,
       ApplyPolicySettings_CheckPolicySettingsMaxFiltersLimitExceeded_2) {}
#endif

TEST_F(URLBlocklistPolicyHandlerTest,
       ApplyPolicySettings_URLBlocklistWrongType) {}

TEST_F(URLBlocklistPolicyHandlerTest, ApplyPolicySettings_URLBlocklistEmpty) {}

TEST_F(URLBlocklistPolicyHandlerTest,
       ApplyPolicySettings_URLBlocklistWrongElementType) {}

TEST_F(URLBlocklistPolicyHandlerTest,
       ApplyPolicySettings_URLBlocklistSuccessful) {}

TEST_F(URLBlocklistPolicyHandlerTest,
       ApplyPolicySettings_CheckPolicySettingsMaxFiltersLimitOK) {}

// Test that the warning message, mapped to
// |IDS_POLICY_URL_ALLOW_BLOCK_LIST_MAX_FILTERS_LIMIT_WARNING|, is added to
// |errors_| when URLBlocklist entries exceed the max filters per policy limit.
TEST_F(URLBlocklistPolicyHandlerTest,
       ApplyPolicySettings_CheckPolicySettingsMaxFiltersLimitExceeded_1) {}

TEST_F(URLBlocklistPolicyHandlerTest, ValidatePolicy) {}

// When the invalid sequence with '*' in the host is added to the blocklist, the
// policy can still be applied, but an error is added to the error map to
// indicate an invalid URL.
TEST_F(URLBlocklistPolicyHandlerTest, CheckPolicyURLHostWithAsterik) {}

}  // namespace policy