#include "services/network/shared_storage/shared_storage_request_helper.h"
#include <memory>
#include <optional>
#include <string>
#include <utility>
#include <vector>
#include "base/memory/weak_ptr.h"
#include "base/run_loop.h"
#include "base/strings/strcat.h"
#include "base/test/test_future.h"
#include "net/cert/mock_cert_verifier.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "net/test/embedded_test_server/simple_connection_listener.h"
#include "net/test/test_with_task_environment.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "net/url_request/url_request.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 "services/network/public/mojom/url_loader_network_service_observer.mojom.h"
#include "services/network/shared_storage/shared_storage_header_utils.h"
#include "services/network/shared_storage/shared_storage_test_url_loader_network_observer.h"
#include "services/network/shared_storage/shared_storage_test_utils.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
#include "url/origin.h"
namespace network {
namespace {
ElementsAre;
const char kHostname[] = …;
const char kTestRequestOrigin[] = …;
[[nodiscard]] GURL GetHttpsRequestURL() { … }
class PausableTestDelegate : public net::TestDelegate { … };
class SharedStorageRequestHelperTest : public net::TestWithTaskEnvironment { … };
}
TEST_F(SharedStorageRequestHelperTest,
SharedStorageWritableHeaderRemoved_EligibityRemoved) { … }
TEST_F(SharedStorageRequestHelperTest,
SharedStorageWritableHeaderNotRemoved_EligibityNotRemoved) { … }
TEST_F(SharedStorageRequestHelperTest,
SharedStorageWritableHeaderAdded_EligibityRestored) { … }
TEST_F(SharedStorageRequestHelperTest,
SharedStorageWritableHeaderNotAdded_EligibityNotRestored) { … }
TEST_F(SharedStorageRequestHelperTest,
IncorrectSharedStorageWritableHeaderAdded_EligibityNotRestored) { … }
TEST_F(SharedStorageRequestHelperTest,
ProcessOutgoingRequest_Eligible_RequestHeaderAdded) { … }
TEST_F(SharedStorageRequestHelperTest,
ProcessOutgoingRequest_NotEligible_RequestHeaderNotAdded) { … }
TEST_F(SharedStorageRequestHelperTest,
ProcessIncomingResponse_NoHeader_NotEligible_NoResponseProcessed) { … }
TEST_F(SharedStorageRequestHelperTest,
ProcessIncomingResponse_NoHeader_Eligible_NoResponseProcessed) { … }
TEST_F(SharedStorageRequestHelperTest,
ProcessIncomingResponse_WithHeader_NotEligible_NoResponseProcessed) { … }
namespace {
class SharedStorageRequestHelperProcessHeaderTest
: public SharedStorageRequestHelperTest { … };
}
TEST_F(SharedStorageRequestHelperProcessHeaderTest,
ClearSetAppendDelete_TokensStringsBytes_HeaderReceived) { … }
TEST_F(SharedStorageRequestHelperProcessHeaderTest,
UnrecognizedAndExtraParams_HeaderReceived) { … }
namespace {
class SharedStorageRequestHelperProcessHeaderMultiConnectionTest
: public SharedStorageRequestHelperProcessHeaderTest { … };
}
TEST_F(SharedStorageRequestHelperProcessHeaderMultiConnectionTest,
InvalidHeader_NoHeaderReceived) { … }
TEST_F(SharedStorageRequestHelperProcessHeaderMultiConnectionTest,
SkipInvalidMiddleItem_HeaderReceived) { … }
}