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

Unified Diff: net/http/http_response_headers_unittest.cc

Issue 18533: Merge r5767 - Protect cookie headers from XHR... (Closed) Base URL: svn://chrome-svn/chrome/branches/release_154.next/src/
Patch Set: Created 11 years, 11 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/http/http_response_headers.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_response_headers_unittest.cc
===================================================================
--- net/http/http_response_headers_unittest.cc (revision 8522)
+++ net/http/http_response_headers_unittest.cc (working copy)
@@ -289,24 +289,29 @@
TEST(HttpResponseHeadersTest, Persist) {
const struct {
+ net::HttpResponseHeaders::PersistOptions options;
const char* raw_headers;
const char* expected_headers;
} tests[] = {
- { "HTTP/1.1 200 OK\n"
+ { net::HttpResponseHeaders::PERSIST_ALL,
+ "HTTP/1.1 200 OK\n"
"Cache-control:private\n"
"cache-Control:no-store\n",
"HTTP/1.1 200 OK\n"
"Cache-control: private, no-store\n"
},
- { "HTTP/1.1 200 OK\n"
+ { net::HttpResponseHeaders::PERSIST_SANS_HOP_BY_HOP,
+ "HTTP/1.1 200 OK\n"
"connection: keep-alive\n"
"server: blah\n",
"HTTP/1.1 200 OK\n"
"server: blah\n"
},
- { "HTTP/1.1 200 OK\n"
+ { net::HttpResponseHeaders::PERSIST_SANS_NON_CACHEABLE |
+ net::HttpResponseHeaders::PERSIST_SANS_HOP_BY_HOP,
+ "HTTP/1.1 200 OK\n"
"fOo: 1\n"
"Foo: 2\n"
"Transfer-Encoding: chunked\n"
@@ -316,7 +321,8 @@
"HTTP/1.1 200 OK\n"
"cache-control: private, no-cache=\"foo\"\n"
},
- { "HTTP/1.1 200 OK\n"
+ { net::HttpResponseHeaders::PERSIST_SANS_NON_CACHEABLE,
+ "HTTP/1.1 200 OK\n"
"Foo: 2\n"
"Cache-Control: private,no-cache=\"foo, bar\"\n"
"bar",
@@ -325,7 +331,8 @@
"Cache-Control: private,no-cache=\"foo, bar\"\n"
},
// ignore bogus no-cache value
- { "HTTP/1.1 200 OK\n"
+ { net::HttpResponseHeaders::PERSIST_SANS_NON_CACHEABLE,
+ "HTTP/1.1 200 OK\n"
"Foo: 2\n"
"Cache-Control: private,no-cache=foo\n",
@@ -334,7 +341,8 @@
"Cache-Control: private,no-cache=foo\n"
},
// ignore bogus no-cache value
- { "HTTP/1.1 200 OK\n"
+ { net::HttpResponseHeaders::PERSIST_SANS_NON_CACHEABLE,
+ "HTTP/1.1 200 OK\n"
"Foo: 2\n"
"Cache-Control: private, no-cache=\n",
@@ -343,7 +351,8 @@
"Cache-Control: private, no-cache=\n"
},
// ignore empty no-cache value
- { "HTTP/1.1 200 OK\n"
+ { net::HttpResponseHeaders::PERSIST_SANS_NON_CACHEABLE,
+ "HTTP/1.1 200 OK\n"
"Foo: 2\n"
"Cache-Control: private, no-cache=\"\"\n",
@@ -352,7 +361,8 @@
"Cache-Control: private, no-cache=\"\"\n"
},
// ignore wrong quotes no-cache value
- { "HTTP/1.1 200 OK\n"
+ { net::HttpResponseHeaders::PERSIST_SANS_NON_CACHEABLE,
+ "HTTP/1.1 200 OK\n"
"Foo: 2\n"
"Cache-Control: private, no-cache=\'foo\'\n",
@@ -361,7 +371,8 @@
"Cache-Control: private, no-cache=\'foo\'\n"
},
// ignore unterminated quotes no-cache value
- { "HTTP/1.1 200 OK\n"
+ { net::HttpResponseHeaders::PERSIST_SANS_NON_CACHEABLE,
+ "HTTP/1.1 200 OK\n"
"Foo: 2\n"
"Cache-Control: private, no-cache=\"foo\n",
@@ -370,7 +381,8 @@
"Cache-Control: private, no-cache=\"foo\n"
},
// accept sloppy LWS
- { "HTTP/1.1 200 OK\n"
+ { net::HttpResponseHeaders::PERSIST_SANS_NON_CACHEABLE,
+ "HTTP/1.1 200 OK\n"
"Foo: 2\n"
"Cache-Control: private, no-cache=\" foo\t, bar\"\n",
@@ -378,7 +390,8 @@
"Cache-Control: private, no-cache=\" foo\t, bar\"\n"
},
// header name appears twice, separated by another header
- { "HTTP/1.1 200 OK\n"
+ { net::HttpResponseHeaders::PERSIST_ALL,
+ "HTTP/1.1 200 OK\n"
"Foo: 1\n"
"Bar: 2\n"
"Foo: 3\n",
@@ -388,7 +401,8 @@
"Bar: 2\n"
},
// header name appears twice, separated by another header (type 2)
- { "HTTP/1.1 200 OK\n"
+ { net::HttpResponseHeaders::PERSIST_ALL,
+ "HTTP/1.1 200 OK\n"
"Foo: 1, 3\n"
"Bar: 2\n"
"Foo: 4\n",
@@ -397,6 +411,17 @@
"Foo: 1, 3, 4\n"
"Bar: 2\n"
},
+ // Test filtering of cookie headers.
+ { net::HttpResponseHeaders::PERSIST_SANS_COOKIES,
+ "HTTP/1.1 200 OK\n"
+ "Set-Cookie: foo=bar; httponly\n"
+ "Set-Cookie: bar=foo\n"
+ "Bar: 1\n"
+ "Set-Cookie2: bar2=foo2\n",
+
+ "HTTP/1.1 200 OK\n"
+ "Bar: 1\n"
+ },
};
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
@@ -406,7 +431,7 @@
new HttpResponseHeaders(headers);
Pickle pickle;
- parsed1->Persist(&pickle, true);
+ parsed1->Persist(&pickle, tests[i].options);
void* iter = NULL;
scoped_refptr<HttpResponseHeaders> parsed2 =
« no previous file with comments | « net/http/http_response_headers.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698