chromium/net/reporting/reporting_uploader_unittest.cc

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

#include "net/reporting/reporting_uploader.h"

#include <memory>
#include <string>
#include <utility>

#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/run_loop.h"
#include "base/test/scoped_feature_list.h"
#include "net/base/features.h"
#include "net/base/network_anonymization_key.h"
#include "net/base/schemeful_site.h"
#include "net/cookies/cookie_access_result.h"
#include "net/cookies/cookie_store.h"
#include "net/cookies/cookie_store_test_callbacks.h"
#include "net/http/http_status_code.h"
#include "net/socket/socket_test_util.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "net/test/embedded_test_server/http_request.h"
#include "net/test/embedded_test_server/http_response.h"
#include "net/test/test_with_task_environment.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_builder.h"
#include "net/url_request/url_request_test_util.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
#include "url/origin.h"

namespace net {
namespace {

class ReportingUploaderTest : public TestWithTaskEnvironment {};

const char kUploadBody[] =;

void CheckUpload(const test_server::HttpRequest& request) {}

std::unique_ptr<test_server::HttpResponse> AllowPreflight(
    const test_server::HttpRequest& request) {}

std::unique_ptr<test_server::HttpResponse> ReturnResponse(
    HttpStatusCode code,
    const test_server::HttpRequest& request) {}

std::unique_ptr<test_server::HttpResponse> ReturnInvalidResponse(
    const test_server::HttpRequest& request) {}

class TestUploadCallback {};

TEST_F(ReportingUploaderTest, Upload) {}

TEST_F(ReportingUploaderTest, Success) {}

TEST_F(ReportingUploaderTest, NetworkError1) {}

TEST_F(ReportingUploaderTest, NetworkError2) {}

TEST_F(ReportingUploaderTest, ServerError) {}

std::unique_ptr<test_server::HttpResponse> VerifyPreflight(
    bool* preflight_received_out,
    const test_server::HttpRequest& request) {}

TEST_F(ReportingUploaderTest, VerifyPreflight) {}

TEST_F(ReportingUploaderTest, SkipPreflightForSameOrigin) {}

std::unique_ptr<test_server::HttpResponse> ReturnPreflightError(
    const test_server::HttpRequest& request) {}

TEST_F(ReportingUploaderTest, FailedCorsPreflight) {}

std::unique_ptr<test_server::HttpResponse> ReturnPreflightWithoutOrigin(
    const test_server::HttpRequest& request) {}

TEST_F(ReportingUploaderTest, CorsPreflightWithoutOrigin) {}

std::unique_ptr<test_server::HttpResponse> ReturnPreflightWithoutMethods(
    const test_server::HttpRequest& request) {}

TEST_F(ReportingUploaderTest, CorsPreflightWithoutMethods) {}

std::unique_ptr<test_server::HttpResponse> ReturnPreflightWithWildcardMethods(
    const test_server::HttpRequest& request) {}

TEST_F(ReportingUploaderTest, CorsPreflightWildcardMethods) {}

std::unique_ptr<test_server::HttpResponse> ReturnPreflightWithoutHeaders(
    const test_server::HttpRequest& request) {}

TEST_F(ReportingUploaderTest, CorsPreflightWithoutHeaders) {}

std::unique_ptr<test_server::HttpResponse> ReturnPreflightWithWildcardHeaders(
    const test_server::HttpRequest& request) {}

TEST_F(ReportingUploaderTest, CorsPreflightWildcardHeaders) {}

TEST_F(ReportingUploaderTest, RemoveEndpoint) {}

const char kRedirectPath[] =;

std::unique_ptr<test_server::HttpResponse> ReturnRedirect(
    const std::string& location,
    const test_server::HttpRequest& request) {}

std::unique_ptr<test_server::HttpResponse> CheckRedirect(
    bool* redirect_followed_out,
    const test_server::HttpRequest& request) {}

TEST_F(ReportingUploaderTest, FollowHttpsRedirect) {}

TEST_F(ReportingUploaderTest, DontFollowHttpRedirect) {}

void CheckNoCookie(const test_server::HttpRequest& request) {}

TEST_F(ReportingUploaderTest, DontSendCookies) {}

std::unique_ptr<test_server::HttpResponse> SendCookie(
    const test_server::HttpRequest& request) {}

TEST_F(ReportingUploaderTest, DontSaveCookies) {}

std::unique_ptr<test_server::HttpResponse> ReturnCacheableResponse(
    int* request_count_out,
    const test_server::HttpRequest& request) {}

// TODO(juliatuttle): This passes even if the uploader doesn't set
// LOAD_DISABLE_CACHE. Maybe that's okay -- Chromium might not cache POST
// responses ever -- but this test should either not exist or be sure that it is
// testing actual functionality, not a default.
TEST_F(ReportingUploaderTest, DontCacheResponse) {}

// Create two requests with the same NetworkAnonymizationKey, and one request
// with a different one, and make sure only the requests with the same
// NetworkAnonymizationKey share a socket.
TEST_F(ReportingUploaderTest, RespectsNetworkAnonymizationKey) {}

}  // namespace
}  // namespace net