1 // Copyright 2018 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "net/network_error_logging/network_error_logging_test_util.h" 6 7 #include "base/containers/contains.h" 8 #include "net/base/ip_address.h" 9 10 namespace net { 11 12 TestNetworkErrorLoggingService::TestNetworkErrorLoggingService() = default; 13 TestNetworkErrorLoggingService::~TestNetworkErrorLoggingService() = default; 14 OnHeader(const NetworkAnonymizationKey & network_anonymization_key,const url::Origin & origin,const IPAddress & received_ip_address,const std::string & value)15void TestNetworkErrorLoggingService::OnHeader( 16 const NetworkAnonymizationKey& network_anonymization_key, 17 const url::Origin& origin, 18 const IPAddress& received_ip_address, 19 const std::string& value) { 20 VLOG(1) << "Received NEL policy for " << origin; 21 Header header; 22 header.network_anonymization_key = network_anonymization_key; 23 header.origin = origin; 24 header.received_ip_address = received_ip_address; 25 header.value = value; 26 headers_.push_back(header); 27 } 28 OnRequest(RequestDetails details)29void TestNetworkErrorLoggingService::OnRequest(RequestDetails details) { 30 VLOG(1) << "Created NEL report (status=" << details.status_code 31 << ", depth=" << details.reporting_upload_depth << ") for " 32 << details.uri; 33 errors_.push_back(std::move(details)); 34 } 35 QueueSignedExchangeReport(SignedExchangeReportDetails details)36void TestNetworkErrorLoggingService::QueueSignedExchangeReport( 37 SignedExchangeReportDetails details) {} 38 RemoveBrowsingData(const base::RepeatingCallback<bool (const url::Origin &)> & origin_filter)39void TestNetworkErrorLoggingService::RemoveBrowsingData( 40 const base::RepeatingCallback<bool(const url::Origin&)>& origin_filter) {} 41 RemoveAllBrowsingData()42void TestNetworkErrorLoggingService::RemoveAllBrowsingData() {} 43 MatchesAddressList(const AddressList & address_list) const44bool TestNetworkErrorLoggingService::Header::MatchesAddressList( 45 const AddressList& address_list) const { 46 return base::Contains(address_list, received_ip_address, 47 &IPEndPoint::address); 48 } 49 50 } // namespace net 51