Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(212)

Unified Diff: net/cookies/cookie_store_unittest.h

Issue 11339032: Account for server vs host clock skew in cookie expiration times. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Disable test on Android as there's no test server Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/cookies/cookie_options.h ('k') | net/url_request/url_request_http_job.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/cookies/cookie_store_unittest.h
diff --git a/net/cookies/cookie_store_unittest.h b/net/cookies/cookie_store_unittest.h
index 575b0cd84e9f7bba97e9be78dd2fca568c3e5f94..51c389da293d2c0c1c6ffae9223a9df789605613 100644
--- a/net/cookies/cookie_store_unittest.h
+++ b/net/cookies/cookie_store_unittest.h
@@ -147,6 +147,17 @@ class CookieStoreTest : public testing::Test {
return callback.result();
}
+ bool SetCookieWithServerTime(CookieStore* cs,
+ const GURL& url,
+ const std::string& cookie_line,
+ const base::Time& server_time) {
+ CookieOptions options;
+ if (!CookieStoreTestTraits::supports_http_only)
+ options.set_include_httponly();
+ options.set_server_time(server_time);
+ return SetCookieWithOptions(cs, url, cookie_line, options);
+ }
+
bool SetCookie(CookieStore* cs,
const GURL& url,
const std::string& cookie_line) {
@@ -702,6 +713,22 @@ TYPED_TEST_P(CookieStoreTest, TestCookieDeletion) {
std::string(kValidCookieLine) +
"; expires=Mon, 18-Apr-22 22:50:13 GMT"));
this->MatchCookieLines("A=B", this->GetCookies(cs, this->url_google_));
+ // Check that it is not deleted with significant enough clock skew.
+ base::Time server_time;
+ EXPECT_TRUE(base::Time::FromString("Sun, 17-Apr-1977 22:50:13 GMT",
+ &server_time));
+ EXPECT_TRUE(this->SetCookieWithServerTime(
+ cs, this->url_google_,
+ std::string(kValidCookieLine) +
+ "; expires=Mon, 18-Apr-1977 22:50:13 GMT",
+ server_time));
+ this->MatchCookieLines("A=B", this->GetCookies(cs, this->url_google_));
+
+ // Create a persistent cookie.
+ EXPECT_TRUE(this->SetCookie(cs, this->url_google_,
+ std::string(kValidCookieLine) +
+ "; expires=Mon, 18-Apr-22 22:50:13 GMT"));
+ this->MatchCookieLines("A=B", this->GetCookies(cs, this->url_google_));
// Delete it via Expires, with a unix epoch of 0.
EXPECT_TRUE(this->SetCookie(cs, this->url_google_,
std::string(kValidCookieLine) +
« no previous file with comments | « net/cookies/cookie_options.h ('k') | net/url_request/url_request_http_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698