Commit bca64428 authored by Douglas Creager's avatar Douglas Creager Committed by Commit Bot

Reporting: Switch to underscores in headers and payloads

This updates the Reporting implementation to include the naming
changes in https://github.com/WICG/reporting/issues/72.

Cq-Include-Trybots: luci.chromium.try:linux_mojo
Change-Id: I2446a8baaf512760949ac5bcaae56088def7d600
Reviewed-on: https://chromium-review.googlesource.com/1073060
Commit-Queue: Douglas Creager <dcreager@chromium.org>
Reviewed-by: default avatarMatt Menke <mmenke@chromium.org>
Reviewed-by: default avatarMartin Šrámek <msramek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#567990}
parent 6949b0fe
...@@ -1492,7 +1492,7 @@ TEST_F(BrowsingDataRemoverImplTest, RemoveNetworkErrorLogging) { ...@@ -1492,7 +1492,7 @@ TEST_F(BrowsingDataRemoverImplTest, RemoveNetworkErrorLogging) {
GURL domain("https://google.com"); GURL domain("https://google.com");
logging_service->OnHeader(url::Origin::Create(domain), logging_service->OnHeader(url::Origin::Create(domain),
"{\"report-to\":\"group\",\"max-age\":86400}"); "{\"report_to\":\"group\",\"max_age\":86400}");
ASSERT_EQ(1u, logging_service->GetPolicyOriginsForTesting().size()); ASSERT_EQ(1u, logging_service->GetPolicyOriginsForTesting().size());
...@@ -1513,16 +1513,16 @@ TEST_F(BrowsingDataRemoverImplTest, RemoveNetworkErrorLogging_SpecificOrigins) { ...@@ -1513,16 +1513,16 @@ TEST_F(BrowsingDataRemoverImplTest, RemoveNetworkErrorLogging_SpecificOrigins) {
GURL domain1("https://google.com"); GURL domain1("https://google.com");
logging_service->OnHeader(url::Origin::Create(domain1), logging_service->OnHeader(url::Origin::Create(domain1),
"{\"report-to\":\"group\",\"max-age\":86400}"); "{\"report_to\":\"group\",\"max_age\":86400}");
GURL domain2("https://host2.com"); GURL domain2("https://host2.com");
logging_service->OnHeader(url::Origin::Create(domain2), logging_service->OnHeader(url::Origin::Create(domain2),
"{\"report-to\":\"group\",\"max-age\":86400}"); "{\"report_to\":\"group\",\"max_age\":86400}");
GURL domain3("https://host3.com"); GURL domain3("https://host3.com");
logging_service->OnHeader(url::Origin::Create(domain3), logging_service->OnHeader(url::Origin::Create(domain3),
"{\"report-to\":\"group\",\"max-age\":86400}"); "{\"report_to\":\"group\",\"max_age\":86400}");
GURL domain4("https://host4.com"); GURL domain4("https://host4.com");
logging_service->OnHeader(url::Origin::Create(domain4), logging_service->OnHeader(url::Origin::Create(domain4),
"{\"report-to\":\"group\",\"max-age\":86400}"); "{\"report_to\":\"group\",\"max_age\":86400}");
ASSERT_EQ(4u, logging_service->GetPolicyOriginsForTesting().size()); ASSERT_EQ(4u, logging_service->GetPolicyOriginsForTesting().size());
......
...@@ -108,10 +108,10 @@ class NetworkErrorLoggingEndToEndTest : public TestWithScopedTaskEnvironment { ...@@ -108,10 +108,10 @@ class NetworkErrorLoggingEndToEndTest : public TestWithScopedTaskEnvironment {
response->AddCustomHeader( response->AddCustomHeader(
"Report-To", "Report-To",
base::StringPrintf("{\"endpoints\":[{\"url\":\"%s\"}],\"group\":\"%s\"," base::StringPrintf("{\"endpoints\":[{\"url\":\"%s\"}],\"group\":\"%s\","
"\"max-age\":%d}", "\"max_age\":%d}",
endpoint_url.spec().c_str(), kGroup, kMaxAgeSec)); endpoint_url.spec().c_str(), kGroup, kMaxAgeSec));
response->AddCustomHeader( response->AddCustomHeader(
"NEL", base::StringPrintf("{\"report-to\":\"%s\",\"max-age\":%d}", "NEL", base::StringPrintf("{\"report_to\":\"%s\",\"max_age\":%d}",
kGroup, kMaxAgeSec)); kGroup, kMaxAgeSec));
response->set_content_type("text/plain"); response->set_content_type("text/plain");
response->set_content(""); response->set_content("");
......
...@@ -32,11 +32,11 @@ namespace { ...@@ -32,11 +32,11 @@ namespace {
const int kMaxJsonSize = 16 * 1024; const int kMaxJsonSize = 16 * 1024;
const int kMaxJsonDepth = 4; const int kMaxJsonDepth = 4;
const char kReportToKey[] = "report-to"; const char kReportToKey[] = "report_to";
const char kMaxAgeKey[] = "max-age"; const char kMaxAgeKey[] = "max_age";
const char kIncludeSubdomainsKey[] = "include-subdomains"; const char kIncludeSubdomainsKey[] = "include_subdomains";
const char kSuccessFractionKey[] = "success-fraction"; const char kSuccessFractionKey[] = "success_fraction";
const char kFailureFractionKey[] = "failure-fraction"; const char kFailureFractionKey[] = "failure_fraction";
// Returns the superdomain of a given domain, or the empty string if the given // Returns the superdomain of a given domain, or the empty string if the given
// domain is just a single label. Note that this does not take into account // domain is just a single label. Note that this does not take into account
...@@ -345,7 +345,7 @@ class NetworkErrorLoggingServiceImpl : public NetworkErrorLoggingService { ...@@ -345,7 +345,7 @@ class NetworkErrorLoggingServiceImpl : public NetworkErrorLoggingService {
// Would be unordered_map, but url::Origin has no hash. // Would be unordered_map, but url::Origin has no hash.
using PolicyMap = std::map<url::Origin, OriginPolicy>; using PolicyMap = std::map<url::Origin, OriginPolicy>;
// Wildcard policies are policies for which the include-subdomains flag is // Wildcard policies are policies for which the include_subdomains flag is
// set. // set.
// //
// Wildcard policies are accessed by domain name, not full origin, so there // Wildcard policies are accessed by domain name, not full origin, so there
...@@ -398,17 +398,17 @@ class NetworkErrorLoggingServiceImpl : public NetworkErrorLoggingService { ...@@ -398,17 +398,17 @@ class NetworkErrorLoggingServiceImpl : public NetworkErrorLoggingService {
} }
bool include_subdomains = false; bool include_subdomains = false;
// include-subdomains is optional and defaults to false, so it's okay if // include_subdomains is optional and defaults to false, so it's okay if
// GetBoolean fails. // GetBoolean fails.
dict->GetBoolean(kIncludeSubdomainsKey, &include_subdomains); dict->GetBoolean(kIncludeSubdomainsKey, &include_subdomains);
double success_fraction = 0.0; double success_fraction = 0.0;
// success-fraction is optional and defaults to 0.0, so it's okay if // success_fraction is optional and defaults to 0.0, so it's okay if
// GetDouble fails. // GetDouble fails.
dict->GetDouble(kSuccessFractionKey, &success_fraction); dict->GetDouble(kSuccessFractionKey, &success_fraction);
double failure_fraction = 1.0; double failure_fraction = 1.0;
// failure-fraction is optional and defaults to 1.0, so it's okay if // failure_fraction is optional and defaults to 1.0, so it's okay if
// GetDouble fails. // GetDouble fails.
dict->GetDouble(kFailureFractionKey, &failure_fraction); dict->GetDouble(kFailureFractionKey, &failure_fraction);
...@@ -455,7 +455,7 @@ class NetworkErrorLoggingServiceImpl : public NetworkErrorLoggingService { ...@@ -455,7 +455,7 @@ class NetworkErrorLoggingServiceImpl : public NetworkErrorLoggingService {
// TODO(juliatuttle): Come up with a deterministic way to resolve these. // TODO(juliatuttle): Come up with a deterministic way to resolve these.
if (it->second.size() > 1) { if (it->second.size() > 1) {
LOG(WARNING) << "Domain " << domain LOG(WARNING) << "Domain " << domain
<< " matches multiple origins with include-subdomains; " << " matches multiple origins with include_subdomains; "
<< "choosing one arbitrarily."; << "choosing one arbitrarily.";
} }
......
...@@ -161,15 +161,15 @@ class NetworkErrorLoggingServiceTest : public ::testing::Test { ...@@ -161,15 +161,15 @@ class NetworkErrorLoggingServiceTest : public ::testing::Test {
const url::Origin kOriginDifferentHost_ = const url::Origin kOriginDifferentHost_ =
url::Origin::Create(kUrlDifferentHost_); url::Origin::Create(kUrlDifferentHost_);
const std::string kHeader_ = "{\"report-to\":\"group\",\"max-age\":86400}"; const std::string kHeader_ = "{\"report_to\":\"group\",\"max_age\":86400}";
const std::string kHeaderIncludeSubdomains_ = const std::string kHeaderIncludeSubdomains_ =
"{\"report-to\":\"group\",\"max-age\":86400,\"include-subdomains\":true}"; "{\"report_to\":\"group\",\"max_age\":86400,\"include_subdomains\":true}";
const std::string kHeaderMaxAge0_ = "{\"max-age\":0}"; const std::string kHeaderMaxAge0_ = "{\"max_age\":0}";
const std::string kHeaderTooLong_ = const std::string kHeaderTooLong_ =
"{\"report-to\":\"group\",\"max-age\":86400,\"junk\":\"" + "{\"report_to\":\"group\",\"max_age\":86400,\"junk\":\"" +
std::string(32 * 1024, 'a') + "\"}"; std::string(32 * 1024, 'a') + "\"}";
const std::string kHeaderTooDeep_ = const std::string kHeaderTooDeep_ =
"{\"report-to\":\"group\",\"max-age\":86400,\"junk\":[[[[[[[[[[]]]]]]]]]]" "{\"report_to\":\"group\",\"max_age\":86400,\"junk\":[[[[[[[[[[]]]]]]]]]]"
"}"; "}";
const std::string kGroup_ = "group"; const std::string kGroup_ = "group";
...@@ -240,7 +240,7 @@ TEST_F(NetworkErrorLoggingServiceTest, JsonTooDeep) { ...@@ -240,7 +240,7 @@ TEST_F(NetworkErrorLoggingServiceTest, JsonTooDeep) {
TEST_F(NetworkErrorLoggingServiceTest, SuccessReportQueued) { TEST_F(NetworkErrorLoggingServiceTest, SuccessReportQueued) {
static const std::string kHeaderSuccessFraction1 = static const std::string kHeaderSuccessFraction1 =
"{\"report-to\":\"group\",\"max-age\":86400,\"success-fraction\":1.0}"; "{\"report_to\":\"group\",\"max_age\":86400,\"success_fraction\":1.0}";
service()->OnHeader(kOrigin_, kHeaderSuccessFraction1); service()->OnHeader(kOrigin_, kHeaderSuccessFraction1);
service()->OnRequest(MakeRequestDetails(kUrl_, OK)); service()->OnRequest(MakeRequestDetails(kUrl_, OK));
...@@ -274,7 +274,7 @@ TEST_F(NetworkErrorLoggingServiceTest, SuccessReportQueued) { ...@@ -274,7 +274,7 @@ TEST_F(NetworkErrorLoggingServiceTest, SuccessReportQueued) {
TEST_F(NetworkErrorLoggingServiceTest, FailureReportQueued) { TEST_F(NetworkErrorLoggingServiceTest, FailureReportQueued) {
static const std::string kHeaderFailureFraction1 = static const std::string kHeaderFailureFraction1 =
"{\"report-to\":\"group\",\"max-age\":86400,\"failure-fraction\":1.0}"; "{\"report_to\":\"group\",\"max_age\":86400,\"failure_fraction\":1.0}";
service()->OnHeader(kOrigin_, kHeaderFailureFraction1); service()->OnHeader(kOrigin_, kHeaderFailureFraction1);
service()->OnRequest(MakeRequestDetails(kUrl_, ERR_CONNECTION_REFUSED)); service()->OnRequest(MakeRequestDetails(kUrl_, ERR_CONNECTION_REFUSED));
...@@ -308,7 +308,7 @@ TEST_F(NetworkErrorLoggingServiceTest, FailureReportQueued) { ...@@ -308,7 +308,7 @@ TEST_F(NetworkErrorLoggingServiceTest, FailureReportQueued) {
TEST_F(NetworkErrorLoggingServiceTest, HttpErrorReportQueued) { TEST_F(NetworkErrorLoggingServiceTest, HttpErrorReportQueued) {
static const std::string kHeaderFailureFraction1 = static const std::string kHeaderFailureFraction1 =
"{\"report-to\":\"group\",\"max-age\":86400,\"failure-fraction\":1.0}"; "{\"report_to\":\"group\",\"max_age\":86400,\"failure_fraction\":1.0}";
service()->OnHeader(kOrigin_, kHeaderFailureFraction1); service()->OnHeader(kOrigin_, kHeaderFailureFraction1);
service()->OnRequest(MakeRequestDetails(kUrl_, OK, 504)); service()->OnRequest(MakeRequestDetails(kUrl_, OK, 504));
...@@ -352,7 +352,7 @@ TEST_F(NetworkErrorLoggingServiceTest, MaxAge0) { ...@@ -352,7 +352,7 @@ TEST_F(NetworkErrorLoggingServiceTest, MaxAge0) {
TEST_F(NetworkErrorLoggingServiceTest, SuccessFraction0) { TEST_F(NetworkErrorLoggingServiceTest, SuccessFraction0) {
static const std::string kHeaderSuccessFraction0 = static const std::string kHeaderSuccessFraction0 =
"{\"report-to\":\"group\",\"max-age\":86400,\"success-fraction\":0.0}"; "{\"report_to\":\"group\",\"max_age\":86400,\"success_fraction\":0.0}";
service()->OnHeader(kOrigin_, kHeaderSuccessFraction0); service()->OnHeader(kOrigin_, kHeaderSuccessFraction0);
// Each network error has a 0% chance of being reported. Fire off several and // Each network error has a 0% chance of being reported. Fire off several and
...@@ -365,11 +365,11 @@ TEST_F(NetworkErrorLoggingServiceTest, SuccessFraction0) { ...@@ -365,11 +365,11 @@ TEST_F(NetworkErrorLoggingServiceTest, SuccessFraction0) {
} }
TEST_F(NetworkErrorLoggingServiceTest, SuccessFractionHalf) { TEST_F(NetworkErrorLoggingServiceTest, SuccessFractionHalf) {
// Include a different value for failure-fraction to ensure that we copy the // Include a different value for failure_fraction to ensure that we copy the
// right value into sampling-fraction. // right value into sampling-fraction.
static const std::string kHeaderSuccessFractionHalf = static const std::string kHeaderSuccessFractionHalf =
"{\"report-to\":\"group\",\"max-age\":86400,\"success-fraction\":0.5," "{\"report_to\":\"group\",\"max_age\":86400,\"success_fraction\":0.5,"
"\"failure-fraction\":0.25}"; "\"failure_fraction\":0.25}";
service()->OnHeader(kOrigin_, kHeaderSuccessFractionHalf); service()->OnHeader(kOrigin_, kHeaderSuccessFractionHalf);
// Each network error has a 50% chance of being reported. Fire off several // Each network error has a 50% chance of being reported. Fire off several
...@@ -391,7 +391,7 @@ TEST_F(NetworkErrorLoggingServiceTest, SuccessFractionHalf) { ...@@ -391,7 +391,7 @@ TEST_F(NetworkErrorLoggingServiceTest, SuccessFractionHalf) {
for (const auto& report : reports()) { for (const auto& report : reports()) {
const base::DictionaryValue* body; const base::DictionaryValue* body;
ASSERT_TRUE(report.body->GetAsDictionary(&body)); ASSERT_TRUE(report.body->GetAsDictionary(&body));
// Our header includes a different value for failure-fraction, so that this // Our header includes a different value for failure_fraction, so that this
// check verifies that we copy the correct fraction into sampling-fraction. // check verifies that we copy the correct fraction into sampling-fraction.
ExpectDictDoubleValue(0.5, *body, ExpectDictDoubleValue(0.5, *body,
NetworkErrorLoggingService::kSamplingFractionKey); NetworkErrorLoggingService::kSamplingFractionKey);
...@@ -400,7 +400,7 @@ TEST_F(NetworkErrorLoggingServiceTest, SuccessFractionHalf) { ...@@ -400,7 +400,7 @@ TEST_F(NetworkErrorLoggingServiceTest, SuccessFractionHalf) {
TEST_F(NetworkErrorLoggingServiceTest, FailureFraction0) { TEST_F(NetworkErrorLoggingServiceTest, FailureFraction0) {
static const std::string kHeaderFailureFraction0 = static const std::string kHeaderFailureFraction0 =
"{\"report-to\":\"group\",\"max-age\":86400,\"failure-fraction\":0.0}"; "{\"report_to\":\"group\",\"max_age\":86400,\"failure_fraction\":0.0}";
service()->OnHeader(kOrigin_, kHeaderFailureFraction0); service()->OnHeader(kOrigin_, kHeaderFailureFraction0);
// Each network error has a 0% chance of being reported. Fire off several and // Each network error has a 0% chance of being reported. Fire off several and
...@@ -413,11 +413,11 @@ TEST_F(NetworkErrorLoggingServiceTest, FailureFraction0) { ...@@ -413,11 +413,11 @@ TEST_F(NetworkErrorLoggingServiceTest, FailureFraction0) {
} }
TEST_F(NetworkErrorLoggingServiceTest, FailureFractionHalf) { TEST_F(NetworkErrorLoggingServiceTest, FailureFractionHalf) {
// Include a different value for success-fraction to ensure that we copy the // Include a different value for success_fraction to ensure that we copy the
// right value into sampling-fraction. // right value into sampling-fraction.
static const std::string kHeaderFailureFractionHalf = static const std::string kHeaderFailureFractionHalf =
"{\"report-to\":\"group\",\"max-age\":86400,\"failure-fraction\":0.5," "{\"report_to\":\"group\",\"max_age\":86400,\"failure_fraction\":0.5,"
"\"success-fraction\":0.25}"; "\"success_fraction\":0.25}";
service()->OnHeader(kOrigin_, kHeaderFailureFractionHalf); service()->OnHeader(kOrigin_, kHeaderFailureFractionHalf);
// Each network error has a 50% chance of being reported. Fire off several // Each network error has a 50% chance of being reported. Fire off several
...@@ -551,7 +551,7 @@ TEST_F(NetworkErrorLoggingServiceTest, StatusAsValue) { ...@@ -551,7 +551,7 @@ TEST_F(NetworkErrorLoggingServiceTest, StatusAsValue) {
service()->SetTickClockForTesting(&clock); service()->SetTickClockForTesting(&clock);
static const std::string kHeaderSuccessFraction1 = static const std::string kHeaderSuccessFraction1 =
"{\"report-to\":\"group\",\"max-age\":86400,\"success-fraction\":1.0}"; "{\"report_to\":\"group\",\"max_age\":86400,\"success_fraction\":1.0}";
service()->OnHeader(kOrigin_, kHeaderSuccessFraction1); service()->OnHeader(kOrigin_, kHeaderSuccessFraction1);
service()->OnHeader(kOriginDifferentHost_, kHeader_); service()->OnHeader(kOriginDifferentHost_, kHeader_);
service()->OnHeader(kOriginSubdomain_, kHeaderIncludeSubdomains_); service()->OnHeader(kOriginSubdomain_, kHeaderIncludeSubdomains_);
......
...@@ -390,7 +390,7 @@ class ReportingCacheImpl : public ReportingCache { ...@@ -390,7 +390,7 @@ class ReportingCacheImpl : public ReportingCache {
} }
// If no clients were found, try successive superdomain suffixes until a // If no clients were found, try successive superdomain suffixes until a
// client with include-subdomains is found or there are no more domain // client with include_subdomains is found or there are no more domain
// components left. // components left.
std::string domain = origin.host(); std::string domain = origin.host();
while (clients_out->empty() && !domain.empty()) { while (clients_out->empty() && !domain.empty()) {
...@@ -629,7 +629,7 @@ class ReportingCacheImpl : public ReportingCache { ...@@ -629,7 +629,7 @@ class ReportingCacheImpl : public ReportingCache {
std::map<url::Origin, std::map<GURL, std::unique_ptr<ReportingClient>>> std::map<url::Origin, std::map<GURL, std::unique_ptr<ReportingClient>>>
clients_; clients_;
// References but does not own all clients with include-subdomains set, keyed // References but does not own all clients with include_subdomains set, keyed
// by domain name. // by domain name.
std::unordered_map<std::string, std::unordered_set<const ReportingClient*>> std::unordered_map<std::string, std::unordered_set<const ReportingClient*>>
wildcard_clients_; wildcard_clients_;
......
...@@ -152,7 +152,7 @@ class NET_EXPORT ReportingCache { ...@@ -152,7 +152,7 @@ class NET_EXPORT ReportingCache {
// have been made to |SetClient| or |RemoveEndpoint| in between. // have been made to |SetClient| or |RemoveEndpoint| in between.
// //
// If no origin match is found, the cache will return clients from the most // If no origin match is found, the cache will return clients from the most
// specific superdomain which contains any clients with include-subdomains // specific superdomain which contains any clients with include_subdomains
// set. For example, given the origin https://foo.bar.baz.com/, the cache // set. For example, given the origin https://foo.bar.baz.com/, the cache
// would prioritize returning each potential match below over the ones below // would prioritize returning each potential match below over the ones below
// it: // it:
......
...@@ -47,7 +47,7 @@ struct NET_EXPORT ReportingClient { ...@@ -47,7 +47,7 @@ struct NET_EXPORT ReportingClient {
// The endpoint group to which this client belongs. // The endpoint group to which this client belongs.
std::string group = kDefaultGroup; std::string group = kDefaultGroup;
// When this client's max-age has expired. // When this client's max_age has expired.
base::TimeTicks expires; base::TimeTicks expires;
// Priority when multiple endpoints are configured for an origin; endpoints // Priority when multiple endpoints are configured for an origin; endpoints
......
...@@ -86,11 +86,11 @@ void RecordHeaderEndpointOutcome(HeaderEndpointOutcome outcome) { ...@@ -86,11 +86,11 @@ void RecordHeaderEndpointOutcome(HeaderEndpointOutcome outcome) {
} }
const char kUrlKey[] = "url"; const char kUrlKey[] = "url";
const char kIncludeSubdomainsKey[] = "include-subdomains"; const char kIncludeSubdomainsKey[] = "include_subdomains";
const char kEndpointsKey[] = "endpoints"; const char kEndpointsKey[] = "endpoints";
const char kGroupKey[] = "group"; const char kGroupKey[] = "group";
const char kGroupDefaultValue[] = "default"; const char kGroupDefaultValue[] = "default";
const char kMaxAgeKey[] = "max-age"; const char kMaxAgeKey[] = "max_age";
const char kPriorityKey[] = "priority"; const char kPriorityKey[] = "priority";
const char kWeightKey[] = "weight"; const char kWeightKey[] = "weight";
......
...@@ -46,39 +46,39 @@ TEST_F(ReportingHeaderParserTest, Invalid) { ...@@ -46,39 +46,39 @@ TEST_F(ReportingHeaderParserTest, Invalid) {
const char* header_value; const char* header_value;
const char* description; const char* description;
} kInvalidHeaderTestCases[] = { } kInvalidHeaderTestCases[] = {
{"{\"max-age\":1, \"endpoints\": [{}]}", "missing url"}, {"{\"max_age\":1, \"endpoints\": [{}]}", "missing url"},
{"{\"max-age\":1, \"endpoints\": [{\"url\":0}]}", "non-string url"}, {"{\"max_age\":1, \"endpoints\": [{\"url\":0}]}", "non-string url"},
{"{\"max-age\":1, \"endpoints\": [{\"url\":\"http://insecure/\"}]}", {"{\"max_age\":1, \"endpoints\": [{\"url\":\"http://insecure/\"}]}",
"insecure url"}, "insecure url"},
{"{\"endpoints\": [{\"url\":\"https://endpoint/\"}]}", "missing max-age"}, {"{\"endpoints\": [{\"url\":\"https://endpoint/\"}]}", "missing max_age"},
{"{\"max-age\":\"\", \"endpoints\": [{\"url\":\"https://endpoint/\"}]}", {"{\"max_age\":\"\", \"endpoints\": [{\"url\":\"https://endpoint/\"}]}",
"non-integer max-age"}, "non-integer max_age"},
{"{\"max-age\":-1, \"endpoints\": [{\"url\":\"https://endpoint/\"}]}", {"{\"max_age\":-1, \"endpoints\": [{\"url\":\"https://endpoint/\"}]}",
"negative max-age"}, "negative max_age"},
{"{\"max-age\":1, \"group\":0, " {"{\"max_age\":1, \"group\":0, "
"\"endpoints\": [{\"url\":\"https://endpoint/\"}]}", "\"endpoints\": [{\"url\":\"https://endpoint/\"}]}",
"non-string group"}, "non-string group"},
// Note that a non-boolean include-subdomains field is *not* invalid, per // Note that a non-boolean include_subdomains field is *not* invalid, per
// the spec. // the spec.
{"{\"max-age\":1, " {"{\"max_age\":1, "
"\"endpoints\": [{\"url\":\"https://endpoint/\",\"priority\":\"\"}]}", "\"endpoints\": [{\"url\":\"https://endpoint/\",\"priority\":\"\"}]}",
"non-integer priority"}, "non-integer priority"},
{"{\"max-age\":1, " {"{\"max_age\":1, "
"\"endpoints\": [{\"url\":\"https://endpoint/\",\"weight\":\"\"}]}", "\"endpoints\": [{\"url\":\"https://endpoint/\",\"weight\":\"\"}]}",
"non-integer weight"}, "non-integer weight"},
{"{\"max-age\":1, " {"{\"max_age\":1, "
"\"endpoints\": [{\"url\":\"https://endpoint/\",\"weight\":-1}]}", "\"endpoints\": [{\"url\":\"https://endpoint/\",\"weight\":-1}]}",
"negative weight"}, "negative weight"},
{"{\"max-age\":1, " {"{\"max_age\":1, "
"\"endpoints\": [{\"url\":\"https://endpoint/\",\"weight\":0}]}", "\"endpoints\": [{\"url\":\"https://endpoint/\",\"weight\":0}]}",
"zero weight"}, "zero weight"},
{"[{\"max-age\":1, \"endpoints\": [{\"url\":\"https://a/\"}]}," {"[{\"max_age\":1, \"endpoints\": [{\"url\":\"https://a/\"}]},"
"{\"max-age\":1, \"endpoints\": [{\"url\":\"https://b/\"}]}]", "{\"max_age\":1, \"endpoints\": [{\"url\":\"https://b/\"}]}]",
"wrapped in list"}}; "wrapped in list"}};
for (size_t i = 0; i < arraysize(kInvalidHeaderTestCases); ++i) { for (size_t i = 0; i < arraysize(kInvalidHeaderTestCases); ++i) {
...@@ -95,7 +95,7 @@ TEST_F(ReportingHeaderParserTest, Invalid) { ...@@ -95,7 +95,7 @@ TEST_F(ReportingHeaderParserTest, Invalid) {
TEST_F(ReportingHeaderParserTest, Valid) { TEST_F(ReportingHeaderParserTest, Valid) {
ParseHeader(kUrl_, "{\"endpoints\": [{\"url\":\"" + kEndpoint_.spec() + ParseHeader(kUrl_, "{\"endpoints\": [{\"url\":\"" + kEndpoint_.spec() +
"\"}],\"max-age\":86400}"); "\"}],\"max_age\":86400}");
const ReportingClient* client = const ReportingClient* client =
FindClientInCache(cache(), kOrigin_, kEndpoint_); FindClientInCache(cache(), kOrigin_, kEndpoint_);
...@@ -115,15 +115,15 @@ TEST_F(ReportingHeaderParserTest, ZeroMaxAge) { ...@@ -115,15 +115,15 @@ TEST_F(ReportingHeaderParserTest, ZeroMaxAge) {
ReportingClient::kDefaultPriority, ReportingClient::kDefaultWeight); ReportingClient::kDefaultPriority, ReportingClient::kDefaultWeight);
ParseHeader(kUrl_, "{\"endpoints\":[{\"url\":\"" + kEndpoint_.spec() + ParseHeader(kUrl_, "{\"endpoints\":[{\"url\":\"" + kEndpoint_.spec() +
"\"}],\"max-age\":0}"); "\"}],\"max_age\":0}");
EXPECT_EQ(nullptr, FindClientInCache(cache(), kOrigin_, kEndpoint_)); EXPECT_EQ(nullptr, FindClientInCache(cache(), kOrigin_, kEndpoint_));
} }
TEST_F(ReportingHeaderParserTest, Subdomains) { TEST_F(ReportingHeaderParserTest, Subdomains) {
ParseHeader(kUrl_, "{\"endpoints\":[{\"url\":\"" + kEndpoint_.spec() + ParseHeader(kUrl_, "{\"endpoints\":[{\"url\":\"" + kEndpoint_.spec() +
"\"}],\"max-age\":86400," "\"}],\"max_age\":86400,"
"\"include-subdomains\":true}"); "\"include_subdomains\":true}");
const ReportingClient* client = const ReportingClient* client =
FindClientInCache(cache(), kOrigin_, kEndpoint_); FindClientInCache(cache(), kOrigin_, kEndpoint_);
...@@ -133,7 +133,7 @@ TEST_F(ReportingHeaderParserTest, Subdomains) { ...@@ -133,7 +133,7 @@ TEST_F(ReportingHeaderParserTest, Subdomains) {
TEST_F(ReportingHeaderParserTest, PriorityPositive) { TEST_F(ReportingHeaderParserTest, PriorityPositive) {
ParseHeader(kUrl_, "{\"endpoints\":[{\"url\":\"" + kEndpoint_.spec() + ParseHeader(kUrl_, "{\"endpoints\":[{\"url\":\"" + kEndpoint_.spec() +
"\",\"priority\":2}],\"max-age\":86400}"); "\",\"priority\":2}],\"max_age\":86400}");
const ReportingClient* client = const ReportingClient* client =
FindClientInCache(cache(), kOrigin_, kEndpoint_); FindClientInCache(cache(), kOrigin_, kEndpoint_);
...@@ -143,7 +143,7 @@ TEST_F(ReportingHeaderParserTest, PriorityPositive) { ...@@ -143,7 +143,7 @@ TEST_F(ReportingHeaderParserTest, PriorityPositive) {
TEST_F(ReportingHeaderParserTest, PriorityNegative) { TEST_F(ReportingHeaderParserTest, PriorityNegative) {
ParseHeader(kUrl_, "{\"endpoints\":[{\"url\":\"" + kEndpoint_.spec() + ParseHeader(kUrl_, "{\"endpoints\":[{\"url\":\"" + kEndpoint_.spec() +
"\",\"priority\":-2}],\"max-age\":86400}"); "\",\"priority\":-2}],\"max_age\":86400}");
const ReportingClient* client = const ReportingClient* client =
FindClientInCache(cache(), kOrigin_, kEndpoint_); FindClientInCache(cache(), kOrigin_, kEndpoint_);
...@@ -153,7 +153,7 @@ TEST_F(ReportingHeaderParserTest, PriorityNegative) { ...@@ -153,7 +153,7 @@ TEST_F(ReportingHeaderParserTest, PriorityNegative) {
TEST_F(ReportingHeaderParserTest, Weight) { TEST_F(ReportingHeaderParserTest, Weight) {
ParseHeader(kUrl_, "{\"endpoints\":[{\"url\":\"" + kEndpoint_.spec() + ParseHeader(kUrl_, "{\"endpoints\":[{\"url\":\"" + kEndpoint_.spec() +
"\",\"weight\":3}],\"max-age\":86400}"); "\",\"weight\":3}],\"max_age\":86400}");
const ReportingClient* client = const ReportingClient* client =
FindClientInCache(cache(), kOrigin_, kEndpoint_); FindClientInCache(cache(), kOrigin_, kEndpoint_);
...@@ -165,13 +165,13 @@ TEST_F(ReportingHeaderParserTest, RemoveOld) { ...@@ -165,13 +165,13 @@ TEST_F(ReportingHeaderParserTest, RemoveOld) {
static const GURL kDifferentEndpoint_ = GURL("https://endpoint2/"); static const GURL kDifferentEndpoint_ = GURL("https://endpoint2/");
ParseHeader(kUrl_, "{\"endpoints\":[{\"url\":\"" + kEndpoint_.spec() + ParseHeader(kUrl_, "{\"endpoints\":[{\"url\":\"" + kEndpoint_.spec() +
"\"}],\"max-age\":86400}"); "\"}],\"max_age\":86400}");
EXPECT_TRUE(FindClientInCache(cache(), kOrigin_, kEndpoint_)); EXPECT_TRUE(FindClientInCache(cache(), kOrigin_, kEndpoint_));
ParseHeader(kUrl_, "{\"endpoints\":[{\"url\":\"" + ParseHeader(kUrl_, "{\"endpoints\":[{\"url\":\"" +
kDifferentEndpoint_.spec() + kDifferentEndpoint_.spec() +
"\"}],\"max-age\":86400}"); "\"}],\"max_age\":86400}");
EXPECT_FALSE(FindClientInCache(cache(), kOrigin_, kEndpoint_)); EXPECT_FALSE(FindClientInCache(cache(), kOrigin_, kEndpoint_));
EXPECT_TRUE(FindClientInCache(cache(), kOrigin_, kDifferentEndpoint_)); EXPECT_TRUE(FindClientInCache(cache(), kOrigin_, kDifferentEndpoint_));
......
...@@ -66,7 +66,7 @@ TEST_F(ReportingServiceTest, ProcessHeader) { ...@@ -66,7 +66,7 @@ TEST_F(ReportingServiceTest, ProcessHeader) {
"\"group\":\"" + "\"group\":\"" +
kGroup_ + kGroup_ +
"\"," "\","
"\"max-age\":86400}"); "\"max_age\":86400}");
const ReportingClient* client = const ReportingClient* client =
FindClientInCache(context()->cache(), kOrigin_, kEndpoint_); FindClientInCache(context()->cache(), kOrigin_, kEndpoint_);
...@@ -86,7 +86,7 @@ TEST_F(ReportingServiceTest, ProcessHeader_TooLong) { ...@@ -86,7 +86,7 @@ TEST_F(ReportingServiceTest, ProcessHeader_TooLong) {
"\"group\":\"" + "\"group\":\"" +
kGroup_ + kGroup_ +
"\"," "\","
"\"max-age\":86400," + "\"max_age\":86400," +
"\"junk\":\"" + std::string(32 * 1024, 'a') + "\"}"; "\"junk\":\"" + std::string(32 * 1024, 'a') + "\"}";
service()->ProcessHeader(kUrl_, header_too_long); service()->ProcessHeader(kUrl_, header_too_long);
...@@ -102,7 +102,7 @@ TEST_F(ReportingServiceTest, ProcessHeader_TooDeep) { ...@@ -102,7 +102,7 @@ TEST_F(ReportingServiceTest, ProcessHeader_TooDeep) {
"\"group\":\"" + "\"group\":\"" +
kGroup_ + kGroup_ +
"\"," "\","
"\"max-age\":86400," + "\"max_age\":86400," +
"\"junk\":[[[[[[[[[[]]]]]]]]]]}"; "\"junk\":[[[[[[[[[[]]]]]]]]]]}";
service()->ProcessHeader(kUrl_, header_too_deep); service()->ProcessHeader(kUrl_, header_too_deep);
......
...@@ -1570,7 +1570,7 @@ TEST_F(NetworkContextTest, ClearNetworkErrorLogging) { ...@@ -1570,7 +1570,7 @@ TEST_F(NetworkContextTest, ClearNetworkErrorLogging) {
GURL domain("https://google.com"); GURL domain("https://google.com");
logging_service->OnHeader(url::Origin::Create(domain), logging_service->OnHeader(url::Origin::Create(domain),
"{\"report-to\":\"group\",\"max-age\":86400}"); "{\"report_to\":\"group\",\"max_age\":86400}");
ASSERT_EQ(1u, logging_service->GetPolicyOriginsForTesting().size()); ASSERT_EQ(1u, logging_service->GetPolicyOriginsForTesting().size());
...@@ -1594,10 +1594,10 @@ TEST_F(NetworkContextTest, ClearNetworkErrorLoggingWithFilter) { ...@@ -1594,10 +1594,10 @@ TEST_F(NetworkContextTest, ClearNetworkErrorLoggingWithFilter) {
GURL domain1("https://google.com"); GURL domain1("https://google.com");
logging_service->OnHeader(url::Origin::Create(domain1), logging_service->OnHeader(url::Origin::Create(domain1),
"{\"report-to\":\"group\",\"max-age\":86400}"); "{\"report_to\":\"group\",\"max_age\":86400}");
GURL domain2("https://chromium.org"); GURL domain2("https://chromium.org");
logging_service->OnHeader(url::Origin::Create(domain2), logging_service->OnHeader(url::Origin::Create(domain2),
"{\"report-to\":\"group\",\"max-age\":86400}"); "{\"report_to\":\"group\",\"max_age\":86400}");
ASSERT_EQ(2u, logging_service->GetPolicyOriginsForTesting().size()); ASSERT_EQ(2u, logging_service->GetPolicyOriginsForTesting().size());
......
...@@ -3,5 +3,5 @@ Cache-Control: no-store, no-cache, must-revalidate ...@@ -3,5 +3,5 @@ Cache-Control: no-store, no-cache, must-revalidate
Cache-Control: post-check=0, pre-check=0, false Cache-Control: post-check=0, pre-check=0, false
Pragma: no-cache Pragma: no-cache
Set-Cookie: reporting-api-doesnt-send-reports-without-violation={{$id:uuid()}}; Path=/content-security-policy/reporting-api Set-Cookie: reporting-api-doesnt-send-reports-without-violation={{$id:uuid()}}; Path=/content-security-policy/reporting-api
Report-To: { "group": "csp-group", "max-age": 10886400, "endpoints": [{ "url": "https://{{host}}:{{ports[https][0]}}/content-security-policy/support/report.py?op=put&reportID={{$id}}" }] } Report-To: { "group": "csp-group", "max_age": 10886400, "endpoints": [{ "url": "https://{{host}}:{{ports[https][0]}}/content-security-policy/support/report.py?op=put&reportID={{$id}}" }] }
Content-Security-Policy: script-src 'self' 'unsafe-inline'; img-src 'self'; report-to csp-group Content-Security-Policy: script-src 'self' 'unsafe-inline'; img-src 'self'; report-to csp-group
...@@ -3,5 +3,5 @@ Cache-Control: no-store, no-cache, must-revalidate ...@@ -3,5 +3,5 @@ Cache-Control: no-store, no-cache, must-revalidate
Cache-Control: post-check=0, pre-check=0, false Cache-Control: post-check=0, pre-check=0, false
Pragma: no-cache Pragma: no-cache
Set-Cookie: reporting-api-report-only-sends-reports-on-violation={{$id:uuid()}}; Path=/content-security-policy/reporting-api Set-Cookie: reporting-api-report-only-sends-reports-on-violation={{$id:uuid()}}; Path=/content-security-policy/reporting-api
Report-To: { "group": "csp-group", "max-age": 10886400, "endpoints": [{ "url": "https://{{host}}:{{ports[https][0]}}/content-security-policy/support/report.py?op=put&reportID={{$id}}" }] } Report-To: { "group": "csp-group", "max_age": 10886400, "endpoints": [{ "url": "https://{{host}}:{{ports[https][0]}}/content-security-policy/support/report.py?op=put&reportID={{$id}}" }] }
Content-Security-Policy-Report-Only: script-src 'self' 'unsafe-inline'; img-src 'none'; report-to csp-group Content-Security-Policy-Report-Only: script-src 'self' 'unsafe-inline'; img-src 'none'; report-to csp-group
...@@ -4,4 +4,4 @@ Cache-Control: post-check=0, pre-check=0, false ...@@ -4,4 +4,4 @@ Cache-Control: post-check=0, pre-check=0, false
Pragma: no-cache Pragma: no-cache
Set-Cookie: reporting-api-report-to-overrides-report-uri-1={{$id:uuid()}}; Path=/content-security-policy/reporting-api Set-Cookie: reporting-api-report-to-overrides-report-uri-1={{$id:uuid()}}; Path=/content-security-policy/reporting-api
Content-Security-Policy: script-src 'self' 'unsafe-inline'; img-src 'none'; report-uri "/content-security-policy/support/report.py?op=put&reportID={{$id}}"; report-to csp-group Content-Security-Policy: script-src 'self' 'unsafe-inline'; img-src 'none'; report-uri "/content-security-policy/support/report.py?op=put&reportID={{$id}}"; report-to csp-group
Report-To: { "group": "csp-group", "max-age": 10886400, "endpoints": [{ "url": "https://{{host}}:{{ports[https][0]}}/content-security-policy/support/report.py?op=put&reportID={{$id:uuid()}}" }] } Report-To: { "group": "csp-group", "max_age": 10886400, "endpoints": [{ "url": "https://{{host}}:{{ports[https][0]}}/content-security-policy/support/report.py?op=put&reportID={{$id:uuid()}}" }] }
...@@ -4,4 +4,4 @@ Cache-Control: post-check=0, pre-check=0, false ...@@ -4,4 +4,4 @@ Cache-Control: post-check=0, pre-check=0, false
Pragma: no-cache Pragma: no-cache
Set-Cookie: reporting-api-report-to-overrides-report-uri-2={{$id:uuid()}}; Path=/content-security-policy/reporting-api Set-Cookie: reporting-api-report-to-overrides-report-uri-2={{$id:uuid()}}; Path=/content-security-policy/reporting-api
Content-Security-Policy: script-src 'self' 'unsafe-inline'; img-src 'none'; report-to csp-group; report-uri "/content-security-policy/support/report.py?op=put&reportID={{$id}}" Content-Security-Policy: script-src 'self' 'unsafe-inline'; img-src 'none'; report-to csp-group; report-uri "/content-security-policy/support/report.py?op=put&reportID={{$id}}"
Report-To: { "group": "csp-group", "max-age": 10886400, "endpoints": [{ "url": "https://{{host}}:{{ports[https][0]}}/content-security-policy/support/report.py?op=put&reportID={{$id:uuid()}}" }] } Report-To: { "group": "csp-group", "max_age": 10886400, "endpoints": [{ "url": "https://{{host}}:{{ports[https][0]}}/content-security-policy/support/report.py?op=put&reportID={{$id:uuid()}}" }] }
...@@ -3,5 +3,5 @@ Cache-Control: no-store, no-cache, must-revalidate ...@@ -3,5 +3,5 @@ Cache-Control: no-store, no-cache, must-revalidate
Cache-Control: post-check=0, pre-check=0, false Cache-Control: post-check=0, pre-check=0, false
Pragma: no-cache Pragma: no-cache
Set-Cookie: reporting-api-sends-reports-on-violation={{$id:uuid()}}; Path=/content-security-policy/reporting-api Set-Cookie: reporting-api-sends-reports-on-violation={{$id:uuid()}}; Path=/content-security-policy/reporting-api
Report-To: { "group": "csp-group", "max-age": 10886400, "endpoints": [{ "url": "https://{{host}}:{{ports[https][0]}}/content-security-policy/support/report.py?op=put&reportID={{$id}}" }] } Report-To: { "group": "csp-group", "max_age": 10886400, "endpoints": [{ "url": "https://{{host}}:{{ports[https][0]}}/content-security-policy/support/report.py?op=put&reportID={{$id}}" }] }
Content-Security-Policy: script-src 'self' 'unsafe-inline'; img-src 'none'; report-to csp-group Content-Security-Policy: script-src 'self' 'unsafe-inline'; img-src 'none'; report-to csp-group
...@@ -2,5 +2,5 @@ Expires: Mon, 26 Jul 1997 05:00:00 GMT ...@@ -2,5 +2,5 @@ Expires: Mon, 26 Jul 1997 05:00:00 GMT
Cache-Control: no-store, no-cache, must-revalidate Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache Pragma: no-cache
Set-Cookie: reporting-api-works-on-frame-src={{$id:uuid()}}; Path=/content-security-policy/reporting-api Set-Cookie: reporting-api-works-on-frame-src={{$id:uuid()}}; Path=/content-security-policy/reporting-api
Report-To: { "group": "csp-group", "max-age": 10886400, "endpoints": [{ "url": "https://{{host}}:{{ports[https][0]}}/content-security-policy/support/report.py?op=put&reportID={{$id}}" }] } Report-To: { "group": "csp-group", "max_age": 10886400, "endpoints": [{ "url": "https://{{host}}:{{ports[https][0]}}/content-security-policy/support/report.py?op=put&reportID={{$id}}" }] }
Content-Security-Policy: script-src 'self' 'unsafe-inline'; frame-src 'none'; report-to csp-group Content-Security-Policy: script-src 'self' 'unsafe-inline'; frame-src 'none'; report-to csp-group
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment