OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // End-to-end tests for WebSocket. | 5 // End-to-end tests for WebSocket. |
6 // | 6 // |
7 // A python server is (re)started for each test, which is moderately | 7 // A python server is (re)started for each test, which is moderately |
8 // inefficient. However, it makes these tests a good fit for scenarios which | 8 // inefficient. However, it makes these tests a good fit for scenarios which |
9 // require special server configurations. | 9 // require special server configurations. |
10 | 10 |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 GetWebSocketTestDataDirectory()); | 378 GetWebSocketTestDataDirectory()); |
379 ASSERT_TRUE(ws_server.Start()); | 379 ASSERT_TRUE(ws_server.Start()); |
380 InitialiseContext(); | 380 InitialiseContext(); |
381 | 381 |
382 GURL ws_url = ws_server.GetURL("truncated-headers"); | 382 GURL ws_url = ws_server.GetURL("truncated-headers"); |
383 EXPECT_FALSE(ConnectAndWait(ws_url)); | 383 EXPECT_FALSE(ConnectAndWait(ws_url)); |
384 } | 384 } |
385 | 385 |
386 // Regression test for crbug.com/455215 "HSTS not applied to WebSocket" | 386 // Regression test for crbug.com/455215 "HSTS not applied to WebSocket" |
387 TEST_F(WebSocketEndToEndTest, DISABLED_ON_ANDROID(HstsHttpsToWebSocket)) { | 387 TEST_F(WebSocketEndToEndTest, DISABLED_ON_ANDROID(HstsHttpsToWebSocket)) { |
388 SpawnedTestServer::SSLOptions ssl_options; | 388 SpawnedTestServer::SSLOptions ssl_options( |
| 389 SpawnedTestServer::SSLOptions::CERT_COMMON_NAME_IS_DOMAIN); |
389 SpawnedTestServer https_server( | 390 SpawnedTestServer https_server( |
390 SpawnedTestServer::TYPE_HTTPS, ssl_options, | 391 SpawnedTestServer::TYPE_HTTPS, ssl_options, |
391 base::FilePath(FILE_PATH_LITERAL("net/data/url_request_unittest"))); | 392 base::FilePath(FILE_PATH_LITERAL("net/data/url_request_unittest"))); |
392 SpawnedTestServer wss_server(SpawnedTestServer::TYPE_WSS, ssl_options, | 393 SpawnedTestServer wss_server(SpawnedTestServer::TYPE_WSS, ssl_options, |
393 GetWebSocketTestDataDirectory()); | 394 GetWebSocketTestDataDirectory()); |
| 395 |
394 ASSERT_TRUE(https_server.StartInBackground()); | 396 ASSERT_TRUE(https_server.StartInBackground()); |
395 ASSERT_TRUE(wss_server.StartInBackground()); | 397 ASSERT_TRUE(wss_server.StartInBackground()); |
396 ASSERT_TRUE(https_server.BlockUntilStarted()); | 398 ASSERT_TRUE(https_server.BlockUntilStarted()); |
397 ASSERT_TRUE(wss_server.BlockUntilStarted()); | 399 ASSERT_TRUE(wss_server.BlockUntilStarted()); |
398 InitialiseContext(); | 400 InitialiseContext(); |
399 // Set HSTS via https: | 401 // Set HSTS via https: |
400 TestDelegate delegate; | 402 TestDelegate delegate; |
401 GURL https_page = https_server.GetURL("files/hsts-headers.html"); | 403 GURL https_page = https_server.GetURL("files/hsts-headers.html"); |
402 scoped_ptr<URLRequest> request( | 404 scoped_ptr<URLRequest> request( |
403 context_.CreateRequest(https_page, DEFAULT_PRIORITY, &delegate)); | 405 context_.CreateRequest(https_page, DEFAULT_PRIORITY, &delegate)); |
404 request->Start(); | 406 request->Start(); |
405 // TestDelegate exits the message loop when the request completes. | 407 // TestDelegate exits the message loop when the request completes. |
406 base::RunLoop().Run(); | 408 base::RunLoop().Run(); |
407 EXPECT_TRUE(request->status().is_success()); | 409 EXPECT_TRUE(request->status().is_success()); |
408 | 410 |
409 // Check HSTS with ws: | 411 // Check HSTS with ws: |
410 // Change the scheme from wss: to ws: to verify that it is switched back. | 412 // Change the scheme from wss: to ws: to verify that it is switched back. |
411 GURL ws_url = ReplaceUrlScheme(wss_server.GetURL(kEchoServer), "ws"); | 413 GURL ws_url = ReplaceUrlScheme(wss_server.GetURL(kEchoServer), "ws"); |
412 EXPECT_TRUE(ConnectAndWait(ws_url)); | 414 EXPECT_TRUE(ConnectAndWait(ws_url)); |
413 } | 415 } |
414 | 416 |
415 TEST_F(WebSocketEndToEndTest, DISABLED_ON_ANDROID(HstsWebSocketToHttps)) { | 417 TEST_F(WebSocketEndToEndTest, DISABLED_ON_ANDROID(HstsWebSocketToHttps)) { |
416 SpawnedTestServer::SSLOptions ssl_options; | 418 SpawnedTestServer::SSLOptions ssl_options( |
| 419 SpawnedTestServer::SSLOptions::CERT_COMMON_NAME_IS_DOMAIN); |
417 SpawnedTestServer https_server( | 420 SpawnedTestServer https_server( |
418 SpawnedTestServer::TYPE_HTTPS, ssl_options, | 421 SpawnedTestServer::TYPE_HTTPS, ssl_options, |
419 base::FilePath(FILE_PATH_LITERAL("net/data/url_request_unittest"))); | 422 base::FilePath(FILE_PATH_LITERAL("net/data/url_request_unittest"))); |
420 SpawnedTestServer wss_server(SpawnedTestServer::TYPE_WSS, ssl_options, | 423 SpawnedTestServer wss_server(SpawnedTestServer::TYPE_WSS, ssl_options, |
421 GetWebSocketTestDataDirectory()); | 424 GetWebSocketTestDataDirectory()); |
422 ASSERT_TRUE(https_server.StartInBackground()); | 425 ASSERT_TRUE(https_server.StartInBackground()); |
423 ASSERT_TRUE(wss_server.StartInBackground()); | 426 ASSERT_TRUE(wss_server.StartInBackground()); |
424 ASSERT_TRUE(https_server.BlockUntilStarted()); | 427 ASSERT_TRUE(https_server.BlockUntilStarted()); |
425 ASSERT_TRUE(wss_server.BlockUntilStarted()); | 428 ASSERT_TRUE(wss_server.BlockUntilStarted()); |
426 InitialiseContext(); | 429 InitialiseContext(); |
427 // Set HSTS via wss: | 430 // Set HSTS via wss: |
428 GURL wss_url = wss_server.GetURL("set-hsts"); | 431 GURL wss_url = wss_server.GetURL("set-hsts"); |
429 EXPECT_TRUE(ConnectAndWait(wss_url)); | 432 EXPECT_TRUE(ConnectAndWait(wss_url)); |
430 | 433 |
431 // Verify via http: | 434 // Verify via http: |
432 TestDelegate delegate; | 435 TestDelegate delegate; |
433 GURL http_page = | 436 GURL http_page = |
434 ReplaceUrlScheme(https_server.GetURL("files/simple.html"), "http"); | 437 ReplaceUrlScheme(https_server.GetURL("files/simple.html"), "http"); |
435 scoped_ptr<URLRequest> request( | 438 scoped_ptr<URLRequest> request( |
436 context_.CreateRequest(http_page, DEFAULT_PRIORITY, &delegate)); | 439 context_.CreateRequest(http_page, DEFAULT_PRIORITY, &delegate)); |
437 request->Start(); | 440 request->Start(); |
438 // TestDelegate exits the message loop when the request completes. | 441 // TestDelegate exits the message loop when the request completes. |
439 base::RunLoop().Run(); | 442 base::RunLoop().Run(); |
440 EXPECT_TRUE(request->status().is_success()); | 443 EXPECT_TRUE(request->status().is_success()); |
441 EXPECT_TRUE(request->url().SchemeIs("https")); | 444 EXPECT_TRUE(request->url().SchemeIs("https")); |
442 } | 445 } |
443 | 446 |
444 TEST_F(WebSocketEndToEndTest, DISABLED_ON_ANDROID(HstsWebSocketToWebSocket)) { | 447 TEST_F(WebSocketEndToEndTest, DISABLED_ON_ANDROID(HstsWebSocketToWebSocket)) { |
445 SpawnedTestServer::SSLOptions ssl_options; | 448 SpawnedTestServer::SSLOptions ssl_options( |
| 449 SpawnedTestServer::SSLOptions::CERT_COMMON_NAME_IS_DOMAIN); |
446 SpawnedTestServer wss_server(SpawnedTestServer::TYPE_WSS, ssl_options, | 450 SpawnedTestServer wss_server(SpawnedTestServer::TYPE_WSS, ssl_options, |
447 GetWebSocketTestDataDirectory()); | 451 GetWebSocketTestDataDirectory()); |
448 ASSERT_TRUE(wss_server.Start()); | 452 ASSERT_TRUE(wss_server.Start()); |
449 InitialiseContext(); | 453 InitialiseContext(); |
450 // Set HSTS via wss: | 454 // Set HSTS via wss: |
451 GURL wss_url = wss_server.GetURL("set-hsts"); | 455 GURL wss_url = wss_server.GetURL("set-hsts"); |
452 EXPECT_TRUE(ConnectAndWait(wss_url)); | 456 EXPECT_TRUE(ConnectAndWait(wss_url)); |
453 | 457 |
454 // Verify via wss: | 458 // Verify via wss: |
455 GURL ws_url = ReplaceUrlScheme(wss_server.GetURL(kEchoServer), "ws"); | 459 GURL ws_url = ReplaceUrlScheme(wss_server.GetURL(kEchoServer), "ws"); |
(...skipping 28 matching lines...) Expand all Loading... |
484 GURL ws_url = ws_server.GetURL("header-continuation"); | 488 GURL ws_url = ws_server.GetURL("header-continuation"); |
485 | 489 |
486 EXPECT_TRUE(ConnectAndWait(ws_url)); | 490 EXPECT_TRUE(ConnectAndWait(ws_url)); |
487 EXPECT_EQ("permessage-deflate; server_max_window_bits=10", | 491 EXPECT_EQ("permessage-deflate; server_max_window_bits=10", |
488 event_interface_->extensions()); | 492 event_interface_->extensions()); |
489 } | 493 } |
490 | 494 |
491 } // namespace | 495 } // namespace |
492 | 496 |
493 } // namespace net | 497 } // namespace net |
OLD | NEW |