summaryrefslogtreecommitdiffstats
path: root/net/cookies/cookie_store_unittest.h
diff options
context:
space:
mode:
authorpauljensen@chromium.org <pauljensen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-13 19:27:48 +0000
committerpauljensen@chromium.org <pauljensen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-13 19:27:48 +0000
commitbb3c4c5de24a6732e6f13f96935eea8cb1392c04 (patch)
treefb2b7ca0ed7ca8164b849c0824c01ff8e498c2cf /net/cookies/cookie_store_unittest.h
parent052f0983c534482292715f256fc99df4996ae6e7 (diff)
downloadchromium_src-bb3c4c5de24a6732e6f13f96935eea8cb1392c04.zip
chromium_src-bb3c4c5de24a6732e6f13f96935eea8cb1392c04.tar.gz
chromium_src-bb3c4c5de24a6732e6f13f96935eea8cb1392c04.tar.bz2
Account for server vs host clock skew in cookie expiration times.
When setting a cookie's expiration time in the cookie store we need to take into account any difference between the HTTP server and the host machine's real time clock. BUG=135131 TEST=net_unittests --gtest_filter=CookieMonster/CookieStoreTest/0.TestCookieDeletion Review URL: https://chromiumcodereview.appspot.com/10692137 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@146616 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/cookies/cookie_store_unittest.h')
-rw-r--r--net/cookies/cookie_store_unittest.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/net/cookies/cookie_store_unittest.h b/net/cookies/cookie_store_unittest.h
index be34c4a..592d52a 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) +