chromium/net/http/http_server_properties_manager_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 "net/http/http_server_properties_manager.h"

#include <utility>

#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/json/json_writer.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/bind.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/values_test_util.h"
#include "base/time/default_tick_clock.h"
#include "base/time/time.h"
#include "base/values.h"
#include "net/base/features.h"
#include "net/base/ip_address.h"
#include "net/base/schemeful_site.h"
#include "net/http/http_network_session.h"
#include "net/http/http_server_properties.h"
#include "net/quic/quic_context.h"
#include "net/test/test_with_task_environment.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"

namespace net {

namespace {

StringPrintf;
_;
AtLeast;
Invoke;
Mock;
StrictMock;

enum class NetworkAnonymizationKeyMode {};

const NetworkAnonymizationKeyMode kNetworkAnonymizationKeyModes[] =;

std::unique_ptr<base::test::ScopedFeatureList> SetNetworkAnonymizationKeyMode(
    NetworkAnonymizationKeyMode mode) {}

class MockPrefDelegate : public HttpServerProperties::PrefDelegate {};

// Converts |server_info_map| to a base::Value::Dict by running it through an
// HttpServerPropertiesManager. Other fields are left empty.
base::Value::Dict ServerInfoMapToDict(
    const HttpServerProperties::ServerInfoMap& server_info_map) {}

// Does the inverse of ServerInfoMapToDict(). Ignores fields other than the
// ServerInfoMap.
std::unique_ptr<HttpServerProperties::ServerInfoMap> DictToServerInfoMap(
    base::Value::Dict dict) {}

}  // namespace

class HttpServerPropertiesManagerTest : public testing::Test,
                                        public WithTaskEnvironment {};

TEST_F(HttpServerPropertiesManagerTest, BadCachedHostPortPair) {}

TEST_F(HttpServerPropertiesManagerTest, BadCachedAltProtocolPort) {}

TEST_F(HttpServerPropertiesManagerTest, SupportsSpdy) {}

// Regression test for crbug.com/670519. Test that there is only one pref update
// scheduled if multiple updates happen in a given time period. Subsequent pref
// update could also be scheduled once the previous scheduled update is
// completed.
TEST_F(HttpServerPropertiesManagerTest,
       SinglePrefUpdateForTwoSpdyServerCacheChanges) {}

TEST_F(HttpServerPropertiesManagerTest, GetAlternativeServiceInfos) {}

TEST_F(HttpServerPropertiesManagerTest, SetAlternativeServices) {}

TEST_F(HttpServerPropertiesManagerTest, SetAlternativeServicesEmpty) {}

TEST_F(HttpServerPropertiesManagerTest, ConfirmAlternativeService) {}

// Check the case that prefs are loaded only after setting alternative service
// info. Prefs should not be written until after the load happens.
TEST_F(HttpServerPropertiesManagerTest, LateLoadAlternativeServiceInfo) {}

// Check the case that prefs are cleared before they're loaded.
TEST_F(HttpServerPropertiesManagerTest,
       ClearPrefsBeforeLoadAlternativeServiceInfo) {}

TEST_F(HttpServerPropertiesManagerTest,
       ConfirmBrokenUntilDefaultNetworkChanges) {}

TEST_F(HttpServerPropertiesManagerTest,
       OnDefaultNetworkChangedWithBrokenUntilDefaultNetworkChanges) {}

TEST_F(HttpServerPropertiesManagerTest, OnDefaultNetworkChangedWithBrokenOnly) {}

TEST_F(HttpServerPropertiesManagerTest, LastLocalAddressWhenQuicWorked) {}

TEST_F(HttpServerPropertiesManagerTest, ServerNetworkStats) {}

TEST_F(HttpServerPropertiesManagerTest, QuicServerInfo) {}

TEST_F(HttpServerPropertiesManagerTest, Clear) {}

// https://crbug.com/444956: Add 200 alternative_service servers followed by
// supports_quic and verify we have read supports_quic from prefs.
TEST_F(HttpServerPropertiesManagerTest, BadLastLocalAddressWhenQuicWorked) {}

TEST_F(HttpServerPropertiesManagerTest, UpdatePrefsWithCache) {}

TEST_F(HttpServerPropertiesManagerTest, ParseAlternativeServiceInfo) {}

// Regression test for https://crbug.com/615497.
TEST_F(HttpServerPropertiesManagerTest, DoNotLoadAltSvcForInsecureOrigins) {}

// Do not persist expired alternative service entries to disk.
TEST_F(HttpServerPropertiesManagerTest, DoNotPersistExpiredAlternativeService) {}

// Test that expired alternative service entries on disk are ignored.
TEST_F(HttpServerPropertiesManagerTest, DoNotLoadExpiredAlternativeService) {}

// Make sure prefs are updated on destruction.
TEST_F(HttpServerPropertiesManagerTest, UpdatePrefsOnShutdown) {}

TEST_F(HttpServerPropertiesManagerTest, PersistAdvertisedVersionsToPref) {}

TEST_F(HttpServerPropertiesManagerTest, ReadAdvertisedVersionsFromPref) {}

TEST_F(HttpServerPropertiesManagerTest,
       UpdatePrefWhenAdvertisedVersionsChange) {}

TEST_F(HttpServerPropertiesManagerTest, UpdateCacheWithPrefs) {}

// Check the interaction of ForceHTTP11 with saving/restoring settings.
// In particular, ForceHTTP11 is not saved, and it should not overwrite or be
// overitten by loaded data.
TEST_F(HttpServerPropertiesManagerTest, ForceHTTP11) {}

TEST_F(HttpServerPropertiesManagerTest, NetworkAnonymizationKeyServerInfo) {}

// Tests a full round trip with a NetworkAnonymizationKey, using the
// HttpServerProperties interface.
TEST_F(HttpServerPropertiesManagerTest, NetworkAnonymizationKeyIntegration) {}

// Tests a full round trip to prefs and back in the canonical suffix case.
// Enable NetworkAnonymizationKeys, as they have some interactions with the
// canonical suffix logic.
TEST_F(HttpServerPropertiesManagerTest,
       CanonicalSuffixRoundTripWithNetworkAnonymizationKey) {}

// Tests a full round trip with a NetworkAnonymizationKey, using the
// HttpServerProperties interface and setting alternative services as broken.
TEST_F(HttpServerPropertiesManagerTest,
       NetworkAnonymizationKeyBrokenAltServiceRoundTrip) {}

// Make sure broken alt services with opaque origins aren't saved.
TEST_F(HttpServerPropertiesManagerTest,
       NetworkAnonymizationKeyBrokenAltServiceOpaqueOrigin) {}

// Tests a full round trip with a NetworkAnonymizationKey, using the
// HttpServerProperties interface and setting QuicServerInfo.
TEST_F(HttpServerPropertiesManagerTest,
       NetworkAnonymizationKeyQuicServerInfoRoundTrip) {}

// Tests a full round trip to prefs and back in the canonical suffix for
// QuicServerInfo case. Enable NetworkAnonymizationKeys, as they have some
// interactions with the canonical suffix logic.
TEST_F(HttpServerPropertiesManagerTest,
       NetworkAnonymizationKeyQuicServerInfoCanonicalSuffixRoundTrip) {}

// Make sure QuicServerInfo associated with NetworkAnonymizationKeys with opaque
// origins aren't saved.
TEST_F(HttpServerPropertiesManagerTest,
       NetworkAnonymizationKeyQuicServerInfoOpaqueOrigin) {}

TEST_F(HttpServerPropertiesManagerTest, AdvertisedVersionsRoundTrip) {}

TEST_F(HttpServerPropertiesManagerTest, SameOrderAfterReload) {}

}  // namespace net