#include "content/browser/aggregation_service/aggregation_service_network_fetcher_impl.h"
#include <memory>
#include <string>
#include <string_view>
#include <vector>
#include "base/barrier_closure.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/scoped_refptr.h"
#include "base/strings/string_util.h"
#include "base/test/bind.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/time/clock.h"
#include "base/time/time.h"
#include "content/browser/aggregation_service/aggregation_service_test_utils.h"
#include "content/browser/aggregation_service/public_key.h"
#include "content/public/test/browser_task_environment.h"
#include "net/base/load_flags.h"
#include "net/base/net_errors.h"
#include "net/http/http_status_code.h"
#include "services/data_decoder/public/cpp/test_support/in_process_data_decoder.h"
#include "services/network/public/cpp/resource_request.h"
#include "services/network/public/cpp/url_loader_completion_status.h"
#include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h"
#include "services/network/public/mojom/url_response_head.mojom.h"
#include "services/network/test/test_url_loader_factory.h"
#include "services/network/test/test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
namespace content {
namespace {
const char kExampleUrl[] = …;
const aggregation_service::TestHpkeKey kExampleHpkeKey = …;
const std::string kExampleValidJson = …;
const std::vector<PublicKey> kExamplePublicKeys = …;
constexpr std::string_view kKeyFetcherStatusHistogramName = …;
constexpr std::string_view kKeyFetcherHttpResponseOrNetErrorCodeHistogramName = …;
}
class AggregationServiceNetworkFetcherTest : public testing::Test { … };
TEST_F(AggregationServiceNetworkFetcherTest, RequestAttributes) { … }
TEST_F(AggregationServiceNetworkFetcherTest, FetchPublicKeys_Success) { … }
TEST_F(AggregationServiceNetworkFetcherTest,
FetchPublicKeysInvalidKeyFormat_Failed) { … }
TEST_F(AggregationServiceNetworkFetcherTest,
FetchPublicKeysMalformedJson_Failed) { … }
TEST_F(AggregationServiceNetworkFetcherTest, FetchPublicKeysLargeBody_Failed) { … }
TEST_F(AggregationServiceNetworkFetcherTest,
FetcherDeletedDuringRequest_NoCrash) { … }
TEST_F(AggregationServiceNetworkFetcherTest, FetchRequestHangs_TimesOut) { … }
TEST_F(AggregationServiceNetworkFetcherTest,
FetchRequestFailsDueToNetworkChange_Retries) { … }
TEST_F(AggregationServiceNetworkFetcherTest, HttpError_CallbackRuns) { … }
TEST_F(AggregationServiceNetworkFetcherTest, MultipleRequests_AllCallbacksRun) { … }
TEST_F(AggregationServiceNetworkFetcherTest, VerifyExpiryTime) { … }
TEST_F(AggregationServiceNetworkFetcherTest, VerifyExpiredKeyOnFetch) { … }
}