chromium/content/browser/loader/file_url_loader_factory_unittest.cc

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

#include "content/browser/loader/file_url_loader_factory.h"

#include <memory>
#include <string>

#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/gmock_callback_support.h"
#include "base/test/mock_callback.h"
#include "base/test/task_environment.h"
#include "base/test/test_future.h"
#include "base/threading/thread_restrictions.h"
#include "base/time/time.h"
#include "components/file_access/scoped_file_access.h"
#include "components/file_access/scoped_file_access_delegate.h"
#include "components/file_access/test/mock_scoped_file_access_delegate.h"
#include "content/public/browser/file_url_loader.h"
#include "content/public/browser/shared_cors_origin_access_list.h"
#include "content/public/common/content_paths.h"
#include "content/public/test/simple_url_loader_test_helper.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "net/base/filename_util.h"
#include "net/base/net_errors.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "services/network/public/cpp/cors/origin_access_list.h"
#include "services/network/public/cpp/resource_request.h"
#include "services/network/public/cpp/simple_url_loader.h"
#include "services/network/public/cpp/url_loader_completion_status.h"
#include "services/network/public/mojom/url_loader.mojom.h"
#include "services/network/test/mock_url_loader_client.h"
#include "services/network/test/test_url_loader_client.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
#include "url/origin.h"

namespace content {

_;

namespace {

// Implementation of SharedCorsOriginAccessList that is used by some of the unit
// tests below for verifying that FileURLLoaderFactory correctly grants or
// denies CORS exemptions to specific initiator origins.
//
// The implementation below gives https://www.google.com origin access to all
// file:// URLs.
class SharedCorsOriginAccessListForTesting : public SharedCorsOriginAccessList {};

GURL GetTestURL(const std::string& filename) {}

class FileURLLoaderFactoryTest : public testing::Test {};

TEST_F(FileURLLoaderFactoryTest, LastModified) {}

TEST_F(FileURLLoaderFactoryTest, Status) {}

TEST_F(FileURLLoaderFactoryTest, MissedRequestInitiator) {}

// Verify that FileURLLoaderFactory takes OriginAccessList into account when
// deciding whether to exempt a request from CORS.  See also
// https://crbug.com/1049604.
TEST_F(FileURLLoaderFactoryTest, Allowlist) {}

// Test that response type is set correctly for directory listings. Regression
// test for https://crbug.com/41492103.
TEST_F(FileURLLoaderFactoryTest, ResponseTypeForDirectoryListings) {}

}  // namespace

TEST_F(FileURLLoaderFactoryTest, DlpInitiatorAllow) {}

TEST_F(FileURLLoaderFactoryTest, DlpNoInitiatorAllow) {}

TEST_F(FileURLLoaderFactoryTest, DlpInitiatorDeny) {}

TEST_F(FileURLLoaderFactoryTest, DlpNoInitiatorDeny) {}

TEST_F(FileURLLoaderFactoryTest, DlpRemoteValidFileUrl) {}

TEST_F(FileURLLoaderFactoryTest, DlpRemoteInvalidFileUrl) {}

}  // namespace content