chromium/chrome/common/google_url_loader_throttle_unittest.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/common/google_url_loader_throttle.h"

#include <memory>
#include <string_view>

#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "base/time/time.h"
#include "build/buildflag.h"
#include "chrome/common/renderer_configuration.mojom.h"
#include "components/signin/public/base/signin_switches.h"
#include "services/network/public/cpp/resource_request.h"
#include "services/network/public/cpp/url_loader_completion_status.h"
#include "services/network/public/mojom/fetch_api.mojom.h"
#include "services/network/public/mojom/url_response_head.mojom.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/loader/url_loader_throttle.h"
#include "url/origin.h"

// This file only contains tests relevant to the bound session credentials
// feature.
#if BUILDFLAG(ENABLE_BOUND_SESSION_CREDENTIALS)
#include "chrome/common/bound_session_request_throttled_handler.h"

namespace {

BoundSessionThrottlerParams;
BoundSessionThrottlerParamsPtr;
RequestBoundSessionStatus;

enum class RequestAction {};

class FakeBoundSessionRequestThrottledHandler
    : public BoundSessionRequestThrottledHandler {};

class MockThrottleDelegate : public blink::URLLoaderThrottle::Delegate {};

// std::vector<BoundSessionThrottlerParamsPtr> initializer list constructor
// doesn't work for some reason, so tests use these helpers to reduce
// boilerplate.
std::vector<BoundSessionThrottlerParamsPtr> ToVector(
    BoundSessionThrottlerParamsPtr params) {}
std::vector<BoundSessionThrottlerParamsPtr> ToVector(
    BoundSessionThrottlerParamsPtr params1,
    BoundSessionThrottlerParamsPtr params2) {}

class GoogleURLLoaderThrottleTest
    : public ::testing::Test,
      public ::testing::WithParamInterface<RequestAction> {};

TEST_F(GoogleURLLoaderThrottleTest, GetRequestBoundSessionStatusNullParams) {}

TEST_F(GoogleURLLoaderThrottleTest, GetRequestBoundSessionStatusEmptyParams) {}

TEST_F(GoogleURLLoaderThrottleTest, GetRequestBoundSessionStatusCookieFresh) {}

TEST_F(GoogleURLLoaderThrottleTest,
       GetRequestBoundSessionStatusNotInBoundSession) {}

TEST_F(GoogleURLLoaderThrottleTest, GetRequestBoundSessionStatusCookieExpired) {}

TEST_F(GoogleURLLoaderThrottleTest,
       GetRequestBoundSessionStatusCookieExpiresNow) {}

TEST_F(GoogleURLLoaderThrottleTest,
       GetRequestBoundSessionStatusCookieExpiredDomainWithLeadingDot) {}

TEST_F(GoogleURLLoaderThrottleTest, GetRequestBoundSessionStatusSubdomainUrl) {}

TEST_F(GoogleURLLoaderThrottleTest,
       GetRequestBoundSessionStatusParentDomainUrl) {}

TEST_F(GoogleURLLoaderThrottleTest, GetRequestBoundSessionStatusUrlWithPath) {}

TEST_F(GoogleURLLoaderThrottleTest, GetRequestBoundSessionStatusPathEmpty) {}

TEST_F(GoogleURLLoaderThrottleTest,
       GetRequestBoundSessionStatusUrlNotOnBoundSessionPath) {}

TEST_F(GoogleURLLoaderThrottleTest,
       GetRequestBoundSessionStatusUrlWithPathOnBoundSessionPath) {}

TEST_F(GoogleURLLoaderThrottleTest,
       GetRequestBoundSessionStatusSubdomainUrlWithPathOnBoundSessionPath) {}

TEST_F(GoogleURLLoaderThrottleTest,
       GetRequestBoundSessionStatusNonOverlappingParams) {}

TEST_F(GoogleURLLoaderThrottleTest,
       GetRequestBoundSessionStatusNonOverlappingParamsHit) {}

TEST_F(GoogleURLLoaderThrottleTest,
       GetRequestBoundSessionStatusNonOverlappingParamsHitSwapped) {}

TEST_F(GoogleURLLoaderThrottleTest,
       GetRequestBoundSessionStatusNonOverlappingParamsMiss) {}

TEST_F(GoogleURLLoaderThrottleTest,
       GetRequestBoundSessionStatusOverlappingParamsBothExpired) {}

TEST_F(GoogleURLLoaderThrottleTest,
       GetRequestBoundSessionStatusOverlappingParamsOneExpired) {}

TEST_F(GoogleURLLoaderThrottleTest,
       GetRequestBoundSessionStatusOverlappingParamsOneExpiredSwapped) {}

TEST_P(GoogleURLLoaderThrottleTest, NullBoundSessionThrottlerParams) {}

TEST_P(GoogleURLLoaderThrottleTest, EmptyBoundSessionThrottlerParams) {}

TEST_F(GoogleURLLoaderThrottleTest, NoInterceptRequestWithSendCookiesFalse) {}

TEST_P(GoogleURLLoaderThrottleTest, InterceptBoundSessionCookieExpired) {}

TEST_F(GoogleURLLoaderThrottleTest,
       InterceptNavigationBoundSessionCookieExpired) {}

TEST_P(GoogleURLLoaderThrottleTest, InterceptAndCancelRequest) {}

TEST_P(GoogleURLLoaderThrottleTest,
       RecordDeferredRequestUnblockTriggerSuccess) {}

TEST_P(GoogleURLLoaderThrottleTest,
       RecordDeferredRequestUnblockTriggerFailure) {}

TEST_P(GoogleURLLoaderThrottleTest,
       NoRecordDeferredRequestUnblockTriggerNotDeferred) {}

INSTANTIATE_TEST_SUITE_P();

INSTANTIATE_TEST_SUITE_P();

}  // namespace

#endif  // BUILDFLAG(ENABLE_BOUND_SESSION_CREDENTIALS)