chromium/net/http/http_server_properties_unittest.cc

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

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40284755): Remove this and spanify to fix the errors.
#pragma allow_unsafe_buffers
#endif

#include "net/http/http_server_properties.h"

#include <memory>
#include <string>
#include <vector>

#include "base/check.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/json/json_writer.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/simple_test_clock.h"
#include "base/test/task_environment.h"
#include "base/time/time.h"
#include "base/values.h"
#include "net/base/features.h"
#include "net/base/host_port_pair.h"
#include "net/base/ip_address.h"
#include "net/base/schemeful_site.h"
#include "net/http/http_network_session.h"
#include "net/test/test_with_task_environment.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"

namespace net {

const base::TimeDelta BROKEN_ALT_SVC_EXPIRE_DELAYS[10] =;

class HttpServerPropertiesPeer {};

namespace {

// Creates a ServerInfoMapKey without a NetworkAnonymizationKey.
HttpServerProperties::ServerInfoMapKey CreateSimpleKey(
    const url::SchemeHostPort& server) {}

class HttpServerPropertiesTest : public TestWithTaskEnvironment {};

TEST_F(HttpServerPropertiesTest, SetSupportsSpdy) {}

TEST_F(HttpServerPropertiesTest, SetSupportsSpdyWebSockets) {}

TEST_F(HttpServerPropertiesTest, SetSupportsSpdyWithNetworkIsolationKey) {}

TEST_F(HttpServerPropertiesTest, LoadSupportsSpdy) {}

TEST_F(HttpServerPropertiesTest, SupportsRequestPriority) {}

TEST_F(HttpServerPropertiesTest, ClearSupportsSpdy) {}

TEST_F(HttpServerPropertiesTest, MRUOfServerInfoMap) {}

AlternateProtocolServerPropertiesTest;

TEST_F(AlternateProtocolServerPropertiesTest, Basic) {}

TEST_F(AlternateProtocolServerPropertiesTest, ExcludeOrigin) {}

TEST_F(AlternateProtocolServerPropertiesTest, Set) {}

TEST_F(AlternateProtocolServerPropertiesTest, SetWebSockets) {}

TEST_F(AlternateProtocolServerPropertiesTest, SetWithNetworkIsolationKey) {}

// Regression test for https://crbug.com/504032:
// OnServerInfoLoadedForTesting() should not crash if there is an
// empty hostname is the mapping.
TEST_F(AlternateProtocolServerPropertiesTest, SetWithEmptyHostname) {}

// GetAlternativeServiceInfos() should remove |server_info_map_|
// elements with empty value.
TEST_F(AlternateProtocolServerPropertiesTest, EmptyVector) {}

// Regression test for https://crbug.com/516486 for the canonical host case.
TEST_F(AlternateProtocolServerPropertiesTest, EmptyVectorForCanonical) {}

TEST_F(AlternateProtocolServerPropertiesTest, ClearServerWithCanonical) {}

TEST_F(AlternateProtocolServerPropertiesTest, MRUOfGetAlternativeServiceInfos) {}

TEST_F(AlternateProtocolServerPropertiesTest, SetBroken) {}

TEST_F(AlternateProtocolServerPropertiesTest,
       SetBrokenUntilDefaultNetworkChanges) {}

TEST_F(AlternateProtocolServerPropertiesTest, MaxAge) {}

TEST_F(AlternateProtocolServerPropertiesTest, MaxAgeCanonical) {}

TEST_F(AlternateProtocolServerPropertiesTest, AlternativeServiceWithScheme) {}

TEST_F(AlternateProtocolServerPropertiesTest, ClearAlternativeServices) {}

// A broken alternative service in the mapping carries meaningful information,
// therefore it should not be ignored by SetAlternativeService().  In
// particular, an alternative service mapped to an origin shadows alternative
// services of canonical hosts.
TEST_F(AlternateProtocolServerPropertiesTest, BrokenShadowsCanonical) {}

TEST_F(AlternateProtocolServerPropertiesTest, ClearBroken) {}

TEST_F(AlternateProtocolServerPropertiesTest,
       MarkBrokenWithNetworkIsolationKey) {}

TEST_F(AlternateProtocolServerPropertiesTest, MarkRecentlyBroken) {}

TEST_F(AlternateProtocolServerPropertiesTest,
       MarkRecentlyBrokenWithNetworkIsolationKey) {}

TEST_F(AlternateProtocolServerPropertiesTest,
       MarkBrokenUntilDefaultNetworkChanges) {}

TEST_F(AlternateProtocolServerPropertiesTest,
       MarkBrokenUntilDefaultNetworkChangesWithNetworkIsolationKey) {}

TEST_F(AlternateProtocolServerPropertiesTest, OnDefaultNetworkChanged) {}

TEST_F(AlternateProtocolServerPropertiesTest,
       OnDefaultNetworkChangedWithNetworkIsolationKey) {}

TEST_F(AlternateProtocolServerPropertiesTest, Canonical) {}

TEST_F(AlternateProtocolServerPropertiesTest, ClearCanonical) {}

TEST_F(AlternateProtocolServerPropertiesTest,
       CanonicalWithNetworkIsolationKey) {}

TEST_F(AlternateProtocolServerPropertiesTest, CanonicalBroken) {}

TEST_F(AlternateProtocolServerPropertiesTest,
       CanonicalBrokenUntilDefaultNetworkChanges) {}

// Adding an alternative service for a new host overrides canonical host.
TEST_F(AlternateProtocolServerPropertiesTest, CanonicalOverride) {}

TEST_F(AlternateProtocolServerPropertiesTest, ClearWithCanonical) {}

TEST_F(AlternateProtocolServerPropertiesTest,
       ExpireBrokenAlternateProtocolMappings) {}

TEST_F(AlternateProtocolServerPropertiesTest,
       ExpireBrokenAlternateProtocolMappingsWithNetworkIsolationKey) {}

// Regression test for https://crbug.com/505413.
TEST_F(AlternateProtocolServerPropertiesTest, RemoveExpiredBrokenAltSvc) {}

TEST_F(AlternateProtocolServerPropertiesTest,
       SetBrokenAlternativeServicesDelayParams1) {}

TEST_F(AlternateProtocolServerPropertiesTest,
       SetBrokenAlternativeServicesDelayParams2) {}

// Regression test for https://crbug.com/724302
TEST_F(AlternateProtocolServerPropertiesTest, RemoveExpiredBrokenAltSvc2) {}

// Regression test for https://crbug.com/994537. Having a ServerInfo entry
// without a populated |alternative_services| value would cause
// OnExpireBrokenAlternativeService() to hang..
TEST_F(AlternateProtocolServerPropertiesTest, RemoveExpiredBrokenAltSvc3) {}

TEST_F(AlternateProtocolServerPropertiesTest,
       GetAlternativeServiceInfoAsValue) {}

TEST_F(HttpServerPropertiesTest, LoadLastLocalAddressWhenQuicWorked) {}

TEST_F(HttpServerPropertiesTest, SetLastLocalAddressWhenQuicWorked) {}

TEST_F(HttpServerPropertiesTest, LoadServerNetworkStats) {}

TEST_F(HttpServerPropertiesTest, SetServerNetworkStats) {}

TEST_F(HttpServerPropertiesTest, ClearServerNetworkStats) {}

TEST_F(HttpServerPropertiesTest, OnQuicServerInfoMapLoaded) {}

TEST_F(HttpServerPropertiesTest, SetQuicServerInfo) {}

// Tests that GetQuicServerInfo() returns server info of a host
// with the same canonical suffix when there is no exact host match.
TEST_F(HttpServerPropertiesTest, QuicServerInfoCanonicalSuffixMatch) {}

// Make sure that canonical suffices respect NetworkIsolationKeys when using
// QuicServerInfo methods.
TEST_F(HttpServerPropertiesTest,
       QuicServerInfoCanonicalSuffixMatchWithNetworkIsolationKey) {}

// Verifies that GetQuicServerInfo() returns the MRU entry if multiple records
// match a given canonical host.
TEST_F(HttpServerPropertiesTest,
       QuicServerInfoCanonicalSuffixMatchReturnsMruEntry) {}

// Verifies that |GetQuicServerInfo| doesn't change the MRU order of the server
// info map when a record is matched based on a canonical name.
TEST_F(HttpServerPropertiesTest,
       QuicServerInfoCanonicalSuffixMatchDoesntChangeOrder) {}

// Tests that the canonical host matching works for hosts stored in memory cache
// and the ones loaded from persistent storage, i.e. server info added
// using SetQuicServerInfo() and SetQuicServerInfoMap() is taken into
// cosideration when searching for server info for a host with the same
// canonical suffix.
TEST_F(HttpServerPropertiesTest, QuicServerInfoCanonicalSuffixMatchSetInfoMap) {}

}  // namespace

}  // namespace net