chromium/content/browser/network/sandboxed_http_cache_browsertest.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 <memory>
#include <string>
#include <vector>

#include "base/feature_list.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/path_service.h"
#include "base/test/bind.h"
#include "base/test/scoped_feature_list.h"
#include "base/threading/thread_restrictions.h"
#include "build/build_config.h"
#include "content/browser/network/http_cache_backend_file_operations_factory.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/network_service_instance.h"
#include "content/public/browser/network_service_util.h"
#include "content/public/browser/page.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_features.h"
#include "content/public/common/content_paths.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/content_browser_test.h"
#include "content/public/test/content_browser_test_utils.h"
#include "content/public/test/network_service_test_helper.h"
#include "content/shell/browser/shell.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
#include "net/base/features.h"
#include "sandbox/policy/features.h"
#include "services/network/public/cpp/features.h"
#include "services/network/public/mojom/network_service_test.mojom.h"

#if BUILDFLAG(IS_ANDROID)
#include "base/android/build_info.h"
#endif

namespace content {
namespace {

SimpleCache;
SimpleCacheEntry;
SimpleCacheEntryEnumerator;
SimpleCacheOpenEntryResult;
SimpleCacheOpenEntryResultPtr;

FileEnumerationEntry;

// On Mac and Fuchsia, sandboxing is always enabled, so we don't need to test
// the non-sandboxing configuration.
#if !BUILDFLAG(IS_MAC) && !BUILDFLAG(IS_FUCHSIA)

class NonSandboxedNetworkServiceBrowserTest : public ContentBrowserTest {};

IN_PROC_BROWSER_TEST_F(NonSandboxedNetworkServiceBrowserTest,
                       OpeningFileIsAllowed) {}

#endif

class SandboxedHttpCacheBrowserTest : public ContentBrowserTest {};

IN_PROC_BROWSER_TEST_F(SandboxedHttpCacheBrowserTest, OpeningFileIsProhibited) {}

IN_PROC_BROWSER_TEST_F(SandboxedHttpCacheBrowserTest,
                       EnumerateFilesOnNonExistingDirectory) {}

IN_PROC_BROWSER_TEST_F(SandboxedHttpCacheBrowserTest, EnumerateFiles) {}

IN_PROC_BROWSER_TEST_F(SandboxedHttpCacheBrowserTest, CreateSimpleCache) {}

IN_PROC_BROWSER_TEST_F(SandboxedHttpCacheBrowserTest,
                       CreateSimpleCacheOnParentDirectory) {}

// TODO(crbug.com/40919503): Flaky on at least Mac11.
#if BUILDFLAG(IS_MAC)
#define MAYBE_CreateSimpleCacheWithParentDirectoryTraversal
#else
#define MAYBE_CreateSimpleCacheWithParentDirectoryTraversal
#endif
IN_PROC_BROWSER_TEST_F(SandboxedHttpCacheBrowserTest,
                       MAYBE_CreateSimpleCacheWithParentDirectoryTraversal) {}

IN_PROC_BROWSER_TEST_F(SandboxedHttpCacheBrowserTest,
                       CreateSimpleCacheWithReset) {}

IN_PROC_BROWSER_TEST_F(SandboxedHttpCacheBrowserTest, CreateEntry) {}

IN_PROC_BROWSER_TEST_F(SandboxedHttpCacheBrowserTest, OpenNonExistingEntry) {}

IN_PROC_BROWSER_TEST_F(SandboxedHttpCacheBrowserTest, CreateAndOpenEntry) {}

IN_PROC_BROWSER_TEST_F(SandboxedHttpCacheBrowserTest, WriteAndReadData) {}

IN_PROC_BROWSER_TEST_F(SandboxedHttpCacheBrowserTest,
                       WriteTruncateAndReadData) {}

IN_PROC_BROWSER_TEST_F(SandboxedHttpCacheBrowserTest, WriteAndReadSparseData) {}

IN_PROC_BROWSER_TEST_F(SandboxedHttpCacheBrowserTest, DoomEntry) {}

IN_PROC_BROWSER_TEST_F(SandboxedHttpCacheBrowserTest, DoomEntryWithoutOpening) {}

// TODO(crbug.com/40881636): Re-enable this test
IN_PROC_BROWSER_TEST_F(SandboxedHttpCacheBrowserTest,
                       DISABLED_EnumerateEntries) {}

IN_PROC_BROWSER_TEST_F(SandboxedHttpCacheBrowserTest, DoomAllEntries) {}

}  // namespace
}  // namespace content