#include "services/network/sct_auditing/sct_auditing_handler.h"
#include <memory>
#include <string_view>
#include "base/base64.h"
#include "base/feature_list.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/test/bind.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/task_environment.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "net/base/hash_value.h"
#include "net/cert/ct_serialization.h"
#include "net/cert/merkle_tree_leaf.h"
#include "net/cert/sct_status_flags.h"
#include "net/test/cert_test_util.h"
#include "net/test/test_data_directory.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "services/network/network_context.h"
#include "services/network/network_service.h"
#include "services/network/public/cpp/resource_request.h"
#include "services/network/public/proto/sct_audit_report.pb.h"
#include "services/network/sct_auditing/sct_auditing_cache.h"
#include "services/network/sct_auditing/sct_auditing_reporter.h"
#include "services/network/test/fake_test_cert_verifier_params_factory.h"
#include "services/network/test/test_network_context_client.h"
#include "services/network/test/test_url_loader_factory.h"
#include "services/network/test/test_utils.h"
#include "services/network/url_loader_factory.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/abseil-cpp/absl/utility/utility.h"
namespace network {
namespace {
constexpr uint8_t kTestLogId[] = …;
const std::string kTestLogIdAsString(reinterpret_cast<const char*>(kTestLogId),
sizeof(kTestLogId));
constexpr base::TimeDelta kTestLogMMD = …;
constexpr base::TimeDelta kTestHWMPeriod = …;
class SCTAuditingHandlerTest : public testing::Test { … };
void MakeTestSCTAndStatus(
net::ct::SignedCertificateTimestamp::Origin origin,
const std::string& extensions,
const std::string& signature_data,
const base::Time& timestamp,
net::ct::SCTVerifyStatus status,
net::SignedCertificateTimestampAndStatusList* sct_list) { … }
TEST_F(SCTAuditingHandlerTest, DisableReporting) { … }
TEST_F(SCTAuditingHandlerTest, ReportsSentWithServerOK) { … }
TEST_F(SCTAuditingHandlerTest, ReportSentWithServerError) { … }
TEST_F(SCTAuditingHandlerTest, ReportsOnlyIncludesValidSCTs) { … }
TEST_F(SCTAuditingHandlerTest, PopulateSCTMetadataOnHashdanceMode) { … }
TEST_F(SCTAuditingHandlerTest, DoNotReportPopularSCT) { … }
TEST_F(SCTAuditingHandlerTest, ReportSucceedsOnSecondTry) { … }
TEST_F(SCTAuditingHandlerTest, ExhaustAllRetriesShouldDeleteReporter) { … }
TEST_F(SCTAuditingHandlerTest, RetriesEnabledSucceedFirstTryMetrics) { … }
TEST_F(SCTAuditingHandlerTest, ReportHighWaterMarkMetrics) { … }
TEST_F(SCTAuditingHandlerTest, ReportNotGeneratedIfNoValidSCTs) { … }
TEST_F(SCTAuditingHandlerTest, HandlerWithoutPersistencePath) { … }
TEST_F(SCTAuditingHandlerTest, HandlerWithPersistencePath) { … }
TEST_F(SCTAuditingHandlerTest, DataRoundTrip) { … }
TEST_F(SCTAuditingHandlerTest, DeserializeBadData) { … }
TEST_F(SCTAuditingHandlerTest, HandlerWithExistingPersistedData) { … }
TEST_F(SCTAuditingHandlerTest, RetryUpdatesPersistedBackoffEntry) { … }
TEST_F(SCTAuditingHandlerTest, RestoringMaxRetries) { … }
TEST_F(SCTAuditingHandlerTest, LogNotFound) { … }
TEST_F(SCTAuditingHandlerTest, ClearPendingReports) { … }
TEST_F(SCTAuditingHandlerTest, PersistedDataWithReportAlreadyCounted) { … }
TEST_F(SCTAuditingHandlerTest, PersistedDataWithoutReportAlreadyCounted) { … }
}
}