#include "net/cookies/cookie_util.h"
#include <memory>
#include <optional>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#include "base/containers/contains.h"
#include "base/functional/callback.h"
#include "base/strings/strcat.h"
#include "base/strings/string_split.h"
#include "base/test/bind.h"
#include "base/test/scoped_feature_list.h"
#include "base/time/time.h"
#include "net/base/features.h"
#include "net/cookies/cookie_constants.h"
#include "net/cookies/cookie_options.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/origin.h"
namespace net {
namespace {
struct RequestCookieParsingTest { … };
void CheckParse(const std::string& str,
const base::StringPairs& parsed_expected) { … }
void CheckSerialize(const base::StringPairs& parsed,
const std::string& str_expected) { … }
TEST(CookieUtilTest, TestDomainIsHostOnly) { … }
TEST(CookieUtilTest, GetCookieDomainWithString_NonASCII) { … }
TEST(CookieUtilTest, GetCookieDomainWithString_Empty) { … }
TEST(CookieUtilTest, GetCookieDomainWithString_IP) { … }
TEST(CookieUtilTest, GetCookieDomainWithString_DotIP) { … }
TEST(CookieUtilTest, GetCookieDomainWithString_PercentEncoded) { … }
TEST(CookieUtilTest, GetCookieDomainWithString_UnCanonicalizable) { … }
TEST(CookieUtilTest, GetCookieDomainWithString_ETldMatchesUrl) { … }
TEST(CookieUtilTest, GetCookieDomainWithString_ETldMatchesUrl_DotPrefix) { … }
TEST(CookieUtilTest, GetCookieDomainWithString_ETldMatchesUrl_NonCanonical) { … }
TEST(CookieUtilTest, GetCookieDomainWithString_ETldDifferentUrl) { … }
TEST(CookieUtilTest, GetCookieDomainWithString_DifferentOrgHost) { … }
TEST(CookieUtilTest, GetCookieDomainWithString_MatchesUrl) { … }
TEST(CookieUtilTest, GetCookieDomainWithString_MatchesUrlWithDot) { … }
TEST(CookieUtilTest, GetCookieDomainWithString_Subdomain) { … }
TEST(CookieUtilTest, GetCookieDomainWithString_UrlSubdomain) { … }
TEST(CookieUtilTest, GetCookieDomainWithString_SubstringButUrlNotSubdomain) { … }
TEST(CookieUtilTest, GetCookieDomainWithString_DifferentSubdomain) { … }
TEST(CookieUtilTest, GetCookieDomainWithString_NoUrlHost) { … }
TEST(CookieUtilTest, GetCookieDomainWithString_TrailingDots) { … }
TEST(CookieUtilTest,
GetCookieDomainWithString_TrailingDots_NotMatchingUrlHost) { … }
TEST(CookieUtilTest, GetCookieDomainWithString_UrlHostIP) { … }
TEST(CookieUtilTest, GetCookieDomainWithString_UrlHostIP_DomainCookie) { … }
TEST(CookieUtilTest, GetCookieDomainWithString_UnknownRegistry) { … }
TEST(CookieUtilTest, TestCookieDateParsing) { … }
TEST(CookieUtilTest, ParseCookieExpirationTimeBeyond2038) { … }
TEST(CookieUtilTest, ParseCookieExpirationTimeBefore1970) { … }
TEST(CookieUtilTest, TestRequestCookieParsing) { … }
TEST(CookieUtilTest, TestRequestCookieParsing_Malformed) { … }
TEST(CookieUtilTest, CookieDomainAndPathToURL) { … }
TEST(CookieUtilTest, SimulatedCookieSource) { … }
TEST(CookieUtilTest, TestGetEffectiveDomain) { … }
TEST(CookieUtilTest, TestIsDomainMatch) { … }
TEST(CookieUtilTest, TestIsOnPath) { … }
TEST(CookieUtilTest, TestIsOnPathCaseSensitive) { … }
AllOf;
SameSiteCookieContext;
ContextType;
ContextRedirectTypeBug1221316;
HttpMethod;
MATCHER_P2(ContextTypeIsWithSchemefulMode, context_type, schemeful, "") { … }
MATCHER_P5(CrossSiteRedirectMetadataCorrectWithSchemefulMode,
method,
context_type_without_chain,
context_type_with_chain,
redirect_type_with_chain,
schemeful,
"") { … }
std::string UrlChainToString(const std::vector<GURL>& url_chain) { … }
class CookieUtilComputeSameSiteContextTest
: public ::testing::TestWithParam<std::tuple<bool, bool>> { … };
TEST_P(CookieUtilComputeSameSiteContextTest, UrlAndSiteForCookiesCrossSite) { … }
TEST_P(CookieUtilComputeSameSiteContextTest, SiteForCookiesNotSchemefullySame) { … }
TEST_P(CookieUtilComputeSameSiteContextTest, ForScriptGet) { … }
TEST_P(CookieUtilComputeSameSiteContextTest, ForScriptGet_SchemefulDowngrade) { … }
TEST_P(CookieUtilComputeSameSiteContextTest, ForScriptGet_WebSocketSchemes) { … }
TEST_P(CookieUtilComputeSameSiteContextTest, ForRequest) { … }
TEST_P(CookieUtilComputeSameSiteContextTest, ForRequest_SchemefulDowngrade) { … }
TEST_P(CookieUtilComputeSameSiteContextTest, ForRequest_WebSocketSchemes) { … }
TEST_P(CookieUtilComputeSameSiteContextTest, ForRequest_Redirect) { … }
TEST_P(CookieUtilComputeSameSiteContextTest, ForScriptSet) { … }
TEST_P(CookieUtilComputeSameSiteContextTest, ForScriptSet_SchemefulDowngrade) { … }
TEST_P(CookieUtilComputeSameSiteContextTest, ForScriptSet_WebSocketSchemes) { … }
TEST_P(CookieUtilComputeSameSiteContextTest, ForResponse) { … }
TEST_P(CookieUtilComputeSameSiteContextTest, ForResponse_SchemefulDowngrade) { … }
TEST_P(CookieUtilComputeSameSiteContextTest, ForResponse_WebSocketSchemes) { … }
TEST_P(CookieUtilComputeSameSiteContextTest, ForResponse_Redirect) { … }
TEST_P(CookieUtilComputeSameSiteContextTest, ForSubresource) { … }
TEST_P(CookieUtilComputeSameSiteContextTest,
ForSubresource_SchemefulDowngrade) { … }
TEST_P(CookieUtilComputeSameSiteContextTest, ForSubresource_WebSocketSchemes) { … }
TEST_P(CookieUtilComputeSameSiteContextTest, ForceIgnoreSiteForCookies) { … }
INSTANTIATE_TEST_SUITE_P(…);
TEST(CookieUtilTest, IsCookieAccessResultInclude) { … }
}
}