Commit 6b920324 authored by Lily Chen's avatar Lily Chen Committed by Commit Bot

Add test coverage for NetLog logging of excluded cookies

Bug: 1005217
Change-Id: I16715129269802acfd3c25413545bec02711316a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1835152
Commit-Queue: Lily Chen <chlily@chromium.org>
Reviewed-by: default avatarEric Roman <eroman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#702102}
parent 9410527e
......@@ -6926,8 +6926,10 @@ TEST_F(URLRequestTest, ReportCookieActivity) {
FilteringTestNetworkDelegate network_delegate;
network_delegate.SetCookieFilter("not_stored_cookie");
network_delegate.set_block_get_cookies();
TestNetLog net_log;
TestURLRequestContext context(true);
context.set_network_delegate(&network_delegate);
context.set_net_log(&net_log);
context.Init();
// Make sure cookies blocked from being stored are caught, and those that are
// accepted are reported as well.
......@@ -6955,6 +6957,12 @@ TEST_F(URLRequestTest, ReportCookieActivity) {
EXPECT_EQ("stored_cookie", req->maybe_stored_cookies()[1].cookie->Name());
EXPECT_TRUE(req->maybe_stored_cookies()[2].status.IsInclude());
EXPECT_EQ("path_cookie", req->maybe_stored_cookies()[2].cookie->Name());
auto entries =
net_log.GetEntriesWithType(NetLogEventType::COOKIE_INCLUSION_STATUS);
EXPECT_EQ(1u, entries.size());
EXPECT_EQ("EXCLUDE_USER_PREFERENCES, DO_NOT_WARN",
GetStringValueFromParams(entries[0], "exclusion_reason"));
net_log.Clear();
}
{
TestDelegate d;
......@@ -6982,6 +6990,18 @@ TEST_F(URLRequestTest, ReportCookieActivity) {
.status.HasExactlyExclusionReasonsForTesting(
{net::CanonicalCookie::CookieInclusionStatus::
EXCLUDE_USER_PREFERENCES}));
auto entries =
net_log.GetEntriesWithType(NetLogEventType::COOKIE_INCLUSION_STATUS);
EXPECT_EQ(2u, entries.size());
EXPECT_THAT(GetStringValueFromParams(entries[0], "exclusion_reason"),
::testing::HasSubstr("EXCLUDE_NOT_ON_PATH"));
EXPECT_THAT(GetStringValueFromParams(entries[0], "exclusion_reason"),
::testing::HasSubstr("EXCLUDE_USER_PREFERENCES"));
EXPECT_THAT(GetStringValueFromParams(entries[0], "exclusion_reason"),
::testing::HasSubstr("DO_NOT_WARN"));
EXPECT_EQ("EXCLUDE_USER_PREFERENCES, DO_NOT_WARN",
GetStringValueFromParams(entries[1], "exclusion_reason"));
net_log.Clear();
}
network_delegate.unset_block_get_cookies();
......@@ -7006,6 +7026,12 @@ TEST_F(URLRequestTest, ReportCookieActivity) {
EXCLUDE_NOT_ON_PATH}));
EXPECT_EQ("stored_cookie", req->maybe_sent_cookies()[1].cookie.Name());
EXPECT_TRUE(req->maybe_sent_cookies()[1].status.IsInclude());
auto entries =
net_log.GetEntriesWithType(NetLogEventType::COOKIE_INCLUSION_STATUS);
EXPECT_EQ(1u, entries.size());
EXPECT_EQ("EXCLUDE_NOT_ON_PATH, DO_NOT_WARN",
GetStringValueFromParams(entries[0], "exclusion_reason"));
net_log.Clear();
}
}
......
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