summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarkusheintz@chromium.org <markusheintz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-10 22:45:19 +0000
committermarkusheintz@chromium.org <markusheintz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-10 22:45:19 +0000
commitddb905097f9edd45501454be91425532c2795c82 (patch)
treefd5f8d6c2af3da961d212a6ad1bdd511cf7b7c30
parent593246fee1efbc2bb5820fd9338b7e33d81dc54d (diff)
downloadchromium_src-ddb905097f9edd45501454be91425532c2795c82.zip
chromium_src-ddb905097f9edd45501454be91425532c2795c82.tar.gz
chromium_src-ddb905097f9edd45501454be91425532c2795c82.tar.bz2
Add tests that test creating secure and http-only cookies using CanonicalCookie::Create.
TEST=CanonicalCookieTest.Create (net_unittests) BUG=161767 Review URL: https://chromiumcodereview.appspot.com/11452003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@172164 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--net/cookies/canonical_cookie_unittest.cc21
1 files changed, 21 insertions, 0 deletions
diff --git a/net/cookies/canonical_cookie_unittest.cc b/net/cookies/canonical_cookie_unittest.cc
index b46a3f2..e4f0048 100644
--- a/net/cookies/canonical_cookie_unittest.cc
+++ b/net/cookies/canonical_cookie_unittest.cc
@@ -67,6 +67,7 @@ TEST(CanonicalCookieTest, Constructor) {
}
TEST(CanonicalCookieTest, Create) {
+ // Test creating cookies from a cookie string.
GURL url("http://www.example.com/test/foo.html");
base::Time creation_time = base::Time::Now();
CookieOptions options;
@@ -89,6 +90,26 @@ TEST(CanonicalCookieTest, Create) {
EXPECT_EQ("/", cookie->Path());
EXPECT_FALSE(cookie->IsSecure());
+ // Test creating secure cookies. RFC 6265 allows insecure urls to set secure
+ // cookies.
+ cookie.reset(
+ CanonicalCookie::Create(url, "A=2; Secure", creation_time, options));
+ EXPECT_TRUE(cookie.get());
+ EXPECT_TRUE(cookie->IsSecure());
+
+ // Test creating http only cookies.
+ cookie.reset(
+ CanonicalCookie::Create(url, "A=2; HttpOnly", creation_time, options));
+ EXPECT_FALSE(cookie.get());
+ CookieOptions httponly_options;
+ httponly_options.set_include_httponly();
+ cookie.reset(
+ CanonicalCookie::Create(url, "A=2; HttpOnly", creation_time,
+ httponly_options));
+ EXPECT_TRUE(cookie->IsHttpOnly());
+
+ // Test the creating cookies using specific parameter instead of a cookie
+ // string.
cookie.reset(CanonicalCookie::Create(
url, "A", "2", "www.example.com", "/test", "", "", creation_time,
base::Time(), false, false));