blob: 72644b870626bd3cbe9c5ba070ab2983837f5969 [file] [log] [blame]
Avi Drissman64595482022-09-14 20:52:291// Copyright 2015 The Chromium Authors
yhirano01a5d662015-02-12 04:33:062// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include <string>
Victor Costan85874942018-02-28 04:11:446#include <utility>
yhirano01a5d662015-02-12 04:33:067
Sebastien Marchand6d0558fd2019-01-25 16:49:378#include "base/bind.h"
yhirano01a5d662015-02-12 04:33:069#include "base/memory/weak_ptr.h"
yhirano01a5d662015-02-12 04:33:0610#include "base/run_loop.h"
11#include "base/strings/string_util.h"
12#include "base/strings/stringprintf.h"
Sean Maher5b9af51f2022-11-21 15:32:4713#include "base/task/single_thread_task_runner.h"
Matt Menke29a538d2020-04-29 16:12:1714#include "net/base/isolation_info.h"
Victor Costan85874942018-02-28 04:11:4415#include "net/cookies/canonical_cookie.h"
16#include "net/cookies/canonical_cookie_test_helpers.h"
Ayu Ishiif3966ca2020-07-08 17:35:1217#include "net/cookies/cookie_access_result.h"
yhirano01a5d662015-02-12 04:33:0618#include "net/cookies/cookie_store.h"
Lily Chenf068a762019-08-21 21:10:5019#include "net/cookies/cookie_util.h"
Yutaka Hirano2f65eec2018-05-23 01:58:2220#include "net/http/http_request_headers.h"
yhirano01a5d662015-02-12 04:33:0621#include "net/socket/socket_test_util.h"
22#include "net/websockets/websocket_stream_create_test_base.h"
23#include "net/websockets/websocket_test_util.h"
Victor Costan85874942018-02-28 04:11:4424#include "testing/gmock/include/gmock/gmock.h"
yhirano01a5d662015-02-12 04:33:0625#include "testing/gtest/include/gtest/gtest.h"
26#include "url/gurl.h"
mkwst4997ce82015-07-25 12:00:0527#include "url/origin.h"
yhirano01a5d662015-02-12 04:33:0628
29namespace net {
30namespace {
31
32using ::testing::TestWithParam;
33using ::testing::ValuesIn;
34
Yoichi Osatoef37ee42022-03-08 04:56:3235const WebSocketExtraHeaders kNoCookieHeader = {};
yhirano01a5d662015-02-12 04:33:0636
37class TestBase : public WebSocketStreamCreateTestBase {
38 public:
39 void CreateAndConnect(const GURL& url,
mkwst4997ce82015-07-25 12:00:0540 const url::Origin& origin,
Maks Orlovich8be0e252019-12-09 18:35:4941 const SiteForCookies& site_for_cookies,
Matt Menke29a538d2020-04-29 16:12:1742 const IsolationInfo& isolation_info,
Yoichi Osatoef37ee42022-03-08 04:56:3243 const WebSocketExtraHeaders& cookie_header,
yhirano01a5d662015-02-12 04:33:0644 const std::string& response_body) {
yhirano01a5d662015-02-12 04:33:0645 url_request_context_host_.SetExpectations(
Yoichi Osatoeffb00c12022-02-24 06:55:3546 WebSocketStandardRequestWithCookies(
47 url.path(), url.host(), origin, cookie_header,
48 /*send_additional_request_headers=*/{}, /*extra_headers=*/{}),
yhirano01a5d662015-02-12 04:33:0649 response_body);
Yutaka Hirano2f65eec2018-05-23 01:58:2250 CreateAndConnectStream(url, NoSubProtocols(), origin, site_for_cookies,
Matt Menke29a538d2020-04-29 16:12:1751 isolation_info, HttpRequestHeaders(), nullptr);
yhirano01a5d662015-02-12 04:33:0652 }
yhirano01a5d662015-02-12 04:33:0653};
54
55struct ClientUseCookieParameter {
56 // The URL for the WebSocket connection.
57 const char* const url;
58 // The URL for the previously set cookies.
59 const char* const cookie_url;
60 // The previously set cookies contents.
61 const char* const cookie_line;
Yoichi Osatoef37ee42022-03-08 04:56:3262 // The Cookie: HTTP header expected to appear in the WS request.
63 const WebSocketExtraHeaders cookie_header;
yhirano01a5d662015-02-12 04:33:0664};
65
66class WebSocketStreamClientUseCookieTest
67 : public TestBase,
68 public TestWithParam<ClientUseCookieParameter> {
69 public:
70 ~WebSocketStreamClientUseCookieTest() override {
71 // Permit any endpoint locks to be released.
72 stream_request_.reset();
73 stream_.reset();
74 base::RunLoop().RunUntilIdle();
75 }
76
Jihwan Marc Kim3e132f12020-05-20 17:33:1977 static void SetCookieHelperFunction(const base::RepeatingClosure& task,
78 base::WeakPtr<bool> weak_is_called,
79 base::WeakPtr<bool> weak_result,
Ayu Ishiif3966ca2020-07-08 17:35:1280 CookieAccessResult access_result) {
yhirano01a5d662015-02-12 04:33:0681 *weak_is_called = true;
Ayu Ishiif3966ca2020-07-08 17:35:1282 *weak_result = access_result.status.IsInclude();
Sean Maher5b9af51f2022-11-21 15:32:4783 base::SingleThreadTaskRunner::GetCurrentDefault()->PostTask(FROM_HERE,
84 task);
yhirano01a5d662015-02-12 04:33:0685 }
86};
87
88struct ServerSetCookieParameter {
89 // The URL for the WebSocket connection.
90 const char* const url;
91 // The URL used to query cookies after the response received.
92 const char* const cookie_url;
93 // The cookies expected to appear for |cookie_url| inquiry.
94 const char* const cookie_line;
95 // The Set-Cookie: HTTP header attached to the response.
Yoichi Osatoef37ee42022-03-08 04:56:3296 const WebSocketExtraHeaders cookie_header;
yhirano01a5d662015-02-12 04:33:0697};
98
99class WebSocketStreamServerSetCookieTest
100 : public TestBase,
101 public TestWithParam<ServerSetCookieParameter> {
102 public:
103 ~WebSocketStreamServerSetCookieTest() override {
104 // Permit any endpoint locks to be released.
105 stream_request_.reset();
106 stream_.reset();
107 base::RunLoop().RunUntilIdle();
108 }
109
Aaron Tagliaboschia4c64b52019-01-25 03:28:49110 static void GetCookieListHelperFunction(
111 base::OnceClosure task,
112 base::WeakPtr<bool> weak_is_called,
113 base::WeakPtr<CookieList> weak_result,
Ayu Ishiibc6fdb0a2020-06-08 22:59:19114 const CookieAccessResultList& cookie_list,
115 const CookieAccessResultList& excluded_cookies) {
yhirano01a5d662015-02-12 04:33:06116 *weak_is_called = true;
Ayu Ishiibc6fdb0a2020-06-08 22:59:19117 *weak_result = cookie_util::StripAccessResults(cookie_list);
Sean Maher5b9af51f2022-11-21 15:32:47118 base::SingleThreadTaskRunner::GetCurrentDefault()->PostTask(
119 FROM_HERE, std::move(task));
yhirano01a5d662015-02-12 04:33:06120 }
121};
122
123TEST_P(WebSocketStreamClientUseCookieTest, ClientUseCookie) {
124 // For wss tests.
Bence Béky63842f02018-03-05 13:48:21125 url_request_context_host_.AddSSLSocketDataProvider(
126 std::make_unique<SSLSocketDataProvider>(ASYNC, OK));
yhirano01a5d662015-02-12 04:33:06127
128 CookieStore* store =
129 url_request_context_host_.GetURLRequestContext()->cookie_store();
130
131 const GURL url(GetParam().url);
132 const GURL cookie_url(GetParam().cookie_url);
Steven Bingler9b8d9f02021-03-15 20:30:58133 const url::Origin origin = url::Origin::Create(GURL(GetParam().url));
Maks Orlovich8be0e252019-12-09 18:35:49134 const SiteForCookies site_for_cookies = SiteForCookies::FromOrigin(origin);
Matt Menke29a538d2020-04-29 16:12:17135 const IsolationInfo isolation_info =
shivanigithub4e78015f592020-10-21 13:26:23136 IsolationInfo::Create(IsolationInfo::RequestType::kOther, origin, origin,
137 SiteForCookies::FromOrigin(origin));
yhirano01a5d662015-02-12 04:33:06138 const std::string cookie_line(GetParam().cookie_line);
yhirano01a5d662015-02-12 04:33:06139
140 bool is_called = false;
141 bool set_cookie_result = false;
142 base::WeakPtrFactory<bool> weak_is_called(&is_called);
143 base::WeakPtrFactory<bool> weak_set_cookie_result(&set_cookie_result);
144
145 base::RunLoop run_loop;
Lily Chen0f208ea2019-08-08 23:37:53146 auto cookie =
147 CanonicalCookie::Create(cookie_url, cookie_line, base::Time::Now(),
Dylan Cutlerf4a802b2021-08-03 16:38:54148 absl::nullopt /* server_time */,
149 absl::nullopt /* cookie_partition_key */);
Lily Chen0f208ea2019-08-08 23:37:53150 store->SetCanonicalCookieAsync(
Lily Chen96f29a132020-04-15 17:59:36151 std::move(cookie), cookie_url, net::CookieOptions::MakeAllInclusive(),
Yannic Bonenberger782a28602019-09-03 10:36:52152 base::BindOnce(&SetCookieHelperFunction, run_loop.QuitClosure(),
153 weak_is_called.GetWeakPtr(),
154 weak_set_cookie_result.GetWeakPtr()));
yhirano01a5d662015-02-12 04:33:06155 run_loop.Run();
156 ASSERT_TRUE(is_called);
157 ASSERT_TRUE(set_cookie_result);
158
Yoichi Osatoef37ee42022-03-08 04:56:32159 CreateAndConnect(url, origin, site_for_cookies, isolation_info,
160 GetParam().cookie_header, WebSocketStandardResponse(""));
yhirano01a5d662015-02-12 04:33:06161 WaitUntilConnectDone();
162 EXPECT_FALSE(has_failed());
163}
164
165TEST_P(WebSocketStreamServerSetCookieTest, ServerSetCookie) {
166 // For wss tests.
Bence Béky63842f02018-03-05 13:48:21167 url_request_context_host_.AddSSLSocketDataProvider(
168 std::make_unique<SSLSocketDataProvider>(ASYNC, OK));
yhirano01a5d662015-02-12 04:33:06169
170 const GURL url(GetParam().url);
171 const GURL cookie_url(GetParam().cookie_url);
Steven Bingler9b8d9f02021-03-15 20:30:58172 const url::Origin origin = url::Origin::Create(GURL(GetParam().url));
Maks Orlovich8be0e252019-12-09 18:35:49173 const SiteForCookies site_for_cookies = SiteForCookies::FromOrigin(origin);
Matt Menke29a538d2020-04-29 16:12:17174 const IsolationInfo isolation_info =
shivanigithub4e78015f592020-10-21 13:26:23175 IsolationInfo::Create(IsolationInfo::RequestType::kOther, origin, origin,
176 SiteForCookies::FromOrigin(origin));
yhirano01a5d662015-02-12 04:33:06177 const std::string cookie_line(GetParam().cookie_line);
Yoichi Osatoef37ee42022-03-08 04:56:32178 HttpRequestHeaders headers;
179 for (const auto& [key, value] : GetParam().cookie_header)
180 headers.SetHeader(key, value);
181 std::string cookie_header(headers.ToString());
yhirano01a5d662015-02-12 04:33:06182 const std::string response = base::StringPrintf(
183 "HTTP/1.1 101 Switching Protocols\r\n"
184 "Upgrade: websocket\r\n"
185 "Connection: Upgrade\r\n"
yhirano01a5d662015-02-12 04:33:06186 "Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=\r\n"
Yoichi Osatoef37ee42022-03-08 04:56:32187 "%s",
yhirano01a5d662015-02-12 04:33:06188 cookie_header.c_str());
yhirano01a5d662015-02-12 04:33:06189 CookieStore* store =
190 url_request_context_host_.GetURLRequestContext()->cookie_store();
191
Yoichi Osatoef37ee42022-03-08 04:56:32192 CreateAndConnect(url, origin, site_for_cookies, isolation_info,
193 /*cookie_header=*/{}, response);
yhirano01a5d662015-02-12 04:33:06194 WaitUntilConnectDone();
Yoichi Osatoef37ee42022-03-08 04:56:32195 EXPECT_FALSE(has_failed()) << failure_message();
yhirano01a5d662015-02-12 04:33:06196
197 bool is_called = false;
Victor Costan85874942018-02-28 04:11:44198 CookieList get_cookie_list_result;
yhirano01a5d662015-02-12 04:33:06199 base::WeakPtrFactory<bool> weak_is_called(&is_called);
Victor Costan85874942018-02-28 04:11:44200 base::WeakPtrFactory<CookieList> weak_get_cookie_list_result(
201 &get_cookie_list_result);
yhirano01a5d662015-02-12 04:33:06202 base::RunLoop run_loop;
Victor Costan85874942018-02-28 04:11:44203 store->GetCookieListWithOptionsAsync(
Maks Orlovichfc69c6f2019-10-22 15:58:54204 cookie_url, net::CookieOptions::MakeAllInclusive(),
Aykut Bulut244341e2021-12-09 15:57:25205 CookiePartitionKeyCollection(),
Victor Costan85874942018-02-28 04:11:44206 base::BindOnce(&GetCookieListHelperFunction, run_loop.QuitClosure(),
207 weak_is_called.GetWeakPtr(),
208 weak_get_cookie_list_result.GetWeakPtr()));
yhirano01a5d662015-02-12 04:33:06209 run_loop.Run();
210 EXPECT_TRUE(is_called);
Victor Costan85874942018-02-28 04:11:44211 EXPECT_THAT(get_cookie_list_result, MatchesCookieLine(cookie_line));
yhirano01a5d662015-02-12 04:33:06212}
213
214// Test parameters definitions follow...
215
216const ClientUseCookieParameter kClientUseCookieParameters[] = {
217 // Non-secure cookies for ws
218 {"ws://www.example.com",
219 "http://www.example.com",
220 "test-cookie",
Yoichi Osatoef37ee42022-03-08 04:56:32221 {{"Cookie", "test-cookie"}}},
yhirano01a5d662015-02-12 04:33:06222
223 {"ws://www.example.com",
224 "https://www.example.com",
225 "test-cookie",
Yoichi Osatoef37ee42022-03-08 04:56:32226 {{"Cookie", "test-cookie"}}},
yhirano01a5d662015-02-12 04:33:06227
228 {"ws://www.example.com",
229 "ws://www.example.com",
230 "test-cookie",
Yoichi Osatoef37ee42022-03-08 04:56:32231 {{"Cookie", "test-cookie"}}},
yhirano01a5d662015-02-12 04:33:06232
233 {"ws://www.example.com",
234 "wss://www.example.com",
235 "test-cookie",
Yoichi Osatoef37ee42022-03-08 04:56:32236 {{"Cookie", "test-cookie"}}},
yhirano01a5d662015-02-12 04:33:06237
238 // Non-secure cookies for wss
239 {"wss://www.example.com",
240 "http://www.example.com",
241 "test-cookie",
Yoichi Osatoef37ee42022-03-08 04:56:32242 {{"Cookie", "test-cookie"}}},
yhirano01a5d662015-02-12 04:33:06243
244 {"wss://www.example.com",
245 "https://www.example.com",
246 "test-cookie",
Yoichi Osatoef37ee42022-03-08 04:56:32247 {{"Cookie", "test-cookie"}}},
yhirano01a5d662015-02-12 04:33:06248
249 {"wss://www.example.com",
250 "ws://www.example.com",
251 "test-cookie",
Yoichi Osatoef37ee42022-03-08 04:56:32252 {{"Cookie", "test-cookie"}}},
yhirano01a5d662015-02-12 04:33:06253
254 {"wss://www.example.com",
255 "wss://www.example.com",
256 "test-cookie",
Yoichi Osatoef37ee42022-03-08 04:56:32257 {{"Cookie", "test-cookie"}}},
yhirano01a5d662015-02-12 04:33:06258
259 // Secure-cookies for ws
Yoichi Osatoef37ee42022-03-08 04:56:32260 {"ws://www.example.com", "https://www.example.com", "test-cookie; secure",
yhirano01a5d662015-02-12 04:33:06261 kNoCookieHeader},
262
Yoichi Osatoef37ee42022-03-08 04:56:32263 {"ws://www.example.com", "wss://www.example.com", "test-cookie; secure",
yhirano01a5d662015-02-12 04:33:06264 kNoCookieHeader},
265
266 // Secure-cookies for wss
267 {"wss://www.example.com",
268 "https://www.example.com",
269 "test-cookie; secure",
Yoichi Osatoef37ee42022-03-08 04:56:32270 {{"Cookie", "test-cookie"}}},
yhirano01a5d662015-02-12 04:33:06271
272 {"wss://www.example.com",
273 "wss://www.example.com",
274 "test-cookie; secure",
Yoichi Osatoef37ee42022-03-08 04:56:32275 {{"Cookie", "test-cookie"}}},
yhirano01a5d662015-02-12 04:33:06276
277 // Non-secure cookies for ws (sharing domain)
278 {"ws://www.example.com",
279 "http://www2.example.com",
280 "test-cookie; Domain=example.com",
Yoichi Osatoef37ee42022-03-08 04:56:32281 {{"Cookie", "test-cookie"}}},
yhirano01a5d662015-02-12 04:33:06282
283 {"ws://www.example.com",
284 "https://www2.example.com",
285 "test-cookie; Domain=example.com",
Yoichi Osatoef37ee42022-03-08 04:56:32286 {{"Cookie", "test-cookie"}}},
yhirano01a5d662015-02-12 04:33:06287
288 {"ws://www.example.com",
289 "ws://www2.example.com",
290 "test-cookie; Domain=example.com",
Yoichi Osatoef37ee42022-03-08 04:56:32291 {{"Cookie", "test-cookie"}}},
yhirano01a5d662015-02-12 04:33:06292
293 {"ws://www.example.com",
294 "wss://www2.example.com",
295 "test-cookie; Domain=example.com",
Yoichi Osatoef37ee42022-03-08 04:56:32296 {{"Cookie", "test-cookie"}}},
yhirano01a5d662015-02-12 04:33:06297
298 // Non-secure cookies for wss (sharing domain)
299 {"wss://www.example.com",
300 "http://www2.example.com",
301 "test-cookie; Domain=example.com",
Yoichi Osatoef37ee42022-03-08 04:56:32302 {{"Cookie", "test-cookie"}}},
yhirano01a5d662015-02-12 04:33:06303
304 {"wss://www.example.com",
305 "https://www2.example.com",
306 "test-cookie; Domain=example.com",
Yoichi Osatoef37ee42022-03-08 04:56:32307 {{"Cookie", "test-cookie"}}},
yhirano01a5d662015-02-12 04:33:06308
309 {"wss://www.example.com",
310 "ws://www2.example.com",
311 "test-cookie; Domain=example.com",
Yoichi Osatoef37ee42022-03-08 04:56:32312 {{"Cookie", "test-cookie"}}},
yhirano01a5d662015-02-12 04:33:06313
314 {"wss://www.example.com",
315 "wss://www2.example.com",
316 "test-cookie; Domain=example.com",
Yoichi Osatoef37ee42022-03-08 04:56:32317 {{"Cookie", "test-cookie"}}},
yhirano01a5d662015-02-12 04:33:06318
319 // Secure-cookies for ws (sharing domain)
Yoichi Osatoef37ee42022-03-08 04:56:32320 {"ws://www.example.com", "https://www2.example.com",
321 "test-cookie; Domain=example.com; secure", kNoCookieHeader},
yhirano01a5d662015-02-12 04:33:06322
Yoichi Osatoef37ee42022-03-08 04:56:32323 {"ws://www.example.com", "wss://www2.example.com",
324 "test-cookie; Domain=example.com; secure", kNoCookieHeader},
yhirano01a5d662015-02-12 04:33:06325
326 // Secure-cookies for wss (sharing domain)
327 {"wss://www.example.com",
328 "https://www2.example.com",
329 "test-cookie; Domain=example.com; secure",
Yoichi Osatoef37ee42022-03-08 04:56:32330 {{"Cookie", "test-cookie"}}},
yhirano01a5d662015-02-12 04:33:06331
332 {"wss://www.example.com",
333 "wss://www2.example.com",
334 "test-cookie; Domain=example.com; secure",
Yoichi Osatoef37ee42022-03-08 04:56:32335 {{"Cookie", "test-cookie"}}},
yhirano01a5d662015-02-12 04:33:06336
337 // Non-matching cookies for ws
Yoichi Osatoef37ee42022-03-08 04:56:32338 {"ws://www.example.com", "http://www2.example.com", "test-cookie",
yhirano01a5d662015-02-12 04:33:06339 kNoCookieHeader},
340
Yoichi Osatoef37ee42022-03-08 04:56:32341 {"ws://www.example.com", "https://www2.example.com", "test-cookie",
yhirano01a5d662015-02-12 04:33:06342 kNoCookieHeader},
343
Yoichi Osatoef37ee42022-03-08 04:56:32344 {"ws://www.example.com", "ws://www2.example.com", "test-cookie",
yhirano01a5d662015-02-12 04:33:06345 kNoCookieHeader},
346
Yoichi Osatoef37ee42022-03-08 04:56:32347 {"ws://www.example.com", "wss://www2.example.com", "test-cookie",
yhirano01a5d662015-02-12 04:33:06348 kNoCookieHeader},
349
350 // Non-matching cookies for wss
Yoichi Osatoef37ee42022-03-08 04:56:32351 {"wss://www.example.com", "http://www2.example.com", "test-cookie",
yhirano01a5d662015-02-12 04:33:06352 kNoCookieHeader},
353
Yoichi Osatoef37ee42022-03-08 04:56:32354 {"wss://www.example.com", "https://www2.example.com", "test-cookie",
yhirano01a5d662015-02-12 04:33:06355 kNoCookieHeader},
356
Yoichi Osatoef37ee42022-03-08 04:56:32357 {"wss://www.example.com", "ws://www2.example.com", "test-cookie",
yhirano01a5d662015-02-12 04:33:06358 kNoCookieHeader},
359
Yoichi Osatoef37ee42022-03-08 04:56:32360 {"wss://www.example.com", "wss://www2.example.com", "test-cookie",
yhirano01a5d662015-02-12 04:33:06361 kNoCookieHeader},
362};
363
Victor Costan2309ea02019-02-13 21:35:47364INSTANTIATE_TEST_SUITE_P(WebSocketStreamClientUseCookieTest,
365 WebSocketStreamClientUseCookieTest,
366 ValuesIn(kClientUseCookieParameters));
yhirano01a5d662015-02-12 04:33:06367
368const ServerSetCookieParameter kServerSetCookieParameters[] = {
369 // Cookies coming from ws
370 {"ws://www.example.com",
371 "http://www.example.com",
372 "test-cookie",
Yoichi Osatoef37ee42022-03-08 04:56:32373 {{"Set-Cookie", "test-cookie"}}},
yhirano01a5d662015-02-12 04:33:06374
375 {"ws://www.example.com",
376 "https://www.example.com",
377 "test-cookie",
Yoichi Osatoef37ee42022-03-08 04:56:32378 {{"Set-Cookie", "test-cookie"}}},
yhirano01a5d662015-02-12 04:33:06379
380 {"ws://www.example.com",
381 "ws://www.example.com",
382 "test-cookie",
Yoichi Osatoef37ee42022-03-08 04:56:32383 {{"Set-Cookie", "test-cookie"}}},
yhirano01a5d662015-02-12 04:33:06384
385 {"ws://www.example.com",
386 "wss://www.example.com",
387 "test-cookie",
Yoichi Osatoef37ee42022-03-08 04:56:32388 {{"Set-Cookie", "test-cookie"}}},
yhirano01a5d662015-02-12 04:33:06389
390 // Cookies coming from wss
391 {"wss://www.example.com",
392 "http://www.example.com",
393 "test-cookie",
Yoichi Osatoef37ee42022-03-08 04:56:32394 {{"Set-Cookie", "test-cookie"}}},
yhirano01a5d662015-02-12 04:33:06395
396 {"wss://www.example.com",
397 "https://www.example.com",
398 "test-cookie",
Yoichi Osatoef37ee42022-03-08 04:56:32399 {{"Set-Cookie", "test-cookie"}}},
yhirano01a5d662015-02-12 04:33:06400
401 {"wss://www.example.com",
402 "ws://www.example.com",
403 "test-cookie",
Yoichi Osatoef37ee42022-03-08 04:56:32404 {{"Set-Cookie", "test-cookie"}}},
yhirano01a5d662015-02-12 04:33:06405
406 {"wss://www.example.com",
407 "wss://www.example.com",
408 "test-cookie",
Yoichi Osatoef37ee42022-03-08 04:56:32409 {{"Set-Cookie", "test-cookie"}}},
yhirano01a5d662015-02-12 04:33:06410
411 // cookies coming from ws (sharing domain)
412 {"ws://www.example.com",
413 "http://www2.example.com",
414 "test-cookie",
Yoichi Osatoef37ee42022-03-08 04:56:32415 {{"Set-Cookie", "test-cookie; Domain=example.com"}}},
yhirano01a5d662015-02-12 04:33:06416
417 {"ws://www.example.com",
418 "https://www2.example.com",
419 "test-cookie",
Yoichi Osatoef37ee42022-03-08 04:56:32420 {{"Set-Cookie", "test-cookie; Domain=example.com"}}},
yhirano01a5d662015-02-12 04:33:06421
422 {"ws://www.example.com",
423 "ws://www2.example.com",
424 "test-cookie",
Yoichi Osatoef37ee42022-03-08 04:56:32425 {{"Set-Cookie", "test-cookie; Domain=example.com"}}},
yhirano01a5d662015-02-12 04:33:06426
427 {"ws://www.example.com",
428 "wss://www2.example.com",
429 "test-cookie",
Yoichi Osatoef37ee42022-03-08 04:56:32430 {{"Set-Cookie", "test-cookie; Domain=example.com"}}},
yhirano01a5d662015-02-12 04:33:06431
432 // cookies coming from wss (sharing domain)
433 {"wss://www.example.com",
434 "http://www2.example.com",
435 "test-cookie",
Yoichi Osatoef37ee42022-03-08 04:56:32436 {{"Set-Cookie", "test-cookie; Domain=example.com"}}},
yhirano01a5d662015-02-12 04:33:06437
438 {"wss://www.example.com",
439 "https://www2.example.com",
440 "test-cookie",
Yoichi Osatoef37ee42022-03-08 04:56:32441 {{"Set-Cookie", "test-cookie; Domain=example.com"}}},
yhirano01a5d662015-02-12 04:33:06442
443 {"wss://www.example.com",
444 "ws://www2.example.com",
445 "test-cookie",
Yoichi Osatoef37ee42022-03-08 04:56:32446 {{"Set-Cookie", "test-cookie; Domain=example.com"}}},
yhirano01a5d662015-02-12 04:33:06447
448 {"wss://www.example.com",
449 "wss://www2.example.com",
450 "test-cookie",
Yoichi Osatoef37ee42022-03-08 04:56:32451 {{"Set-Cookie", "test-cookie; Domain=example.com"}}},
yhirano01a5d662015-02-12 04:33:06452
453 // Non-matching cookies coming from ws
454 {"ws://www.example.com",
455 "http://www2.example.com",
456 "",
Yoichi Osatoef37ee42022-03-08 04:56:32457 {{"Set-Cookie", "test-cookie"}}},
yhirano01a5d662015-02-12 04:33:06458
459 {"ws://www.example.com",
460 "https://www2.example.com",
461 "",
Yoichi Osatoef37ee42022-03-08 04:56:32462 {{"Set-Cookie", "test-cookie"}}},
yhirano01a5d662015-02-12 04:33:06463
464 {"ws://www.example.com",
465 "ws://www2.example.com",
466 "",
Yoichi Osatoef37ee42022-03-08 04:56:32467 {{"Set-Cookie", "test-cookie"}}},
yhirano01a5d662015-02-12 04:33:06468
469 {"ws://www.example.com",
470 "wss://www2.example.com",
471 "",
Yoichi Osatoef37ee42022-03-08 04:56:32472 {{"Set-Cookie", "test-cookie"}}},
yhirano01a5d662015-02-12 04:33:06473
474 // Non-matching cookies coming from wss
475 {"wss://www.example.com",
476 "http://www2.example.com",
477 "",
Yoichi Osatoef37ee42022-03-08 04:56:32478 {{"Set-Cookie", "test-cookie"}}},
yhirano01a5d662015-02-12 04:33:06479
480 {"wss://www.example.com",
481 "https://www2.example.com",
482 "",
Yoichi Osatoef37ee42022-03-08 04:56:32483 {{"Set-Cookie", "test-cookie"}}},
yhirano01a5d662015-02-12 04:33:06484
485 {"wss://www.example.com",
486 "ws://www2.example.com",
487 "",
Yoichi Osatoef37ee42022-03-08 04:56:32488 {{"Set-Cookie", "test-cookie"}}},
yhirano01a5d662015-02-12 04:33:06489
490 {"wss://www.example.com",
491 "wss://www2.example.com",
492 "",
Yoichi Osatoef37ee42022-03-08 04:56:32493 {{"Set-Cookie", "test-cookie"}}},
yhirano01a5d662015-02-12 04:33:06494};
495
Victor Costan2309ea02019-02-13 21:35:47496INSTANTIATE_TEST_SUITE_P(WebSocketStreamServerSetCookieTest,
497 WebSocketStreamServerSetCookieTest,
498 ValuesIn(kServerSetCookieParameters));
yhirano01a5d662015-02-12 04:33:06499
500} // namespace
501} // namespace net