| 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 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 // cannot provide auth information that isn't already cached, so it's | 347 // cannot provide auth information that isn't already cached, so it's |
| 348 // necessary to preflight an HTTP request to authenticate against the proxy. | 348 // necessary to preflight an HTTP request to authenticate against the proxy. |
| 349 // It doesn't matter what the URL is, as long as it is an HTTP navigation. | 349 // It doesn't matter what the URL is, as long as it is an HTTP navigation. |
| 350 GURL http_page = | 350 GURL http_page = |
| 351 ReplaceUrlScheme(ws_server.GetURL("connect_check.html"), "http"); | 351 ReplaceUrlScheme(ws_server.GetURL("connect_check.html"), "http"); |
| 352 TestDelegate delegate; | 352 TestDelegate delegate; |
| 353 delegate.set_credentials( | 353 delegate.set_credentials( |
| 354 AuthCredentials(base::ASCIIToUTF16("foo"), base::ASCIIToUTF16("bar"))); | 354 AuthCredentials(base::ASCIIToUTF16("foo"), base::ASCIIToUTF16("bar"))); |
| 355 { | 355 { |
| 356 scoped_ptr<URLRequest> request( | 356 scoped_ptr<URLRequest> request( |
| 357 context_.CreateRequest(http_page, DEFAULT_PRIORITY, &delegate, NULL)); | 357 context_.CreateRequest(http_page, DEFAULT_PRIORITY, &delegate)); |
| 358 request->Start(); | 358 request->Start(); |
| 359 // TestDelegate exits the message loop when the request completes by | 359 // TestDelegate exits the message loop when the request completes by |
| 360 // default. | 360 // default. |
| 361 base::RunLoop().Run(); | 361 base::RunLoop().Run(); |
| 362 EXPECT_TRUE(delegate.auth_required_called()); | 362 EXPECT_TRUE(delegate.auth_required_called()); |
| 363 } | 363 } |
| 364 | 364 |
| 365 GURL ws_url = ws_server.GetURL(kEchoServer); | 365 GURL ws_url = ws_server.GetURL(kEchoServer); |
| 366 EXPECT_TRUE(ConnectAndWait(ws_url)); | 366 EXPECT_TRUE(ConnectAndWait(ws_url)); |
| 367 const TestNetworkDelegateWithProxyInfo::ResolvedProxyInfo& info = | 367 const TestNetworkDelegateWithProxyInfo::ResolvedProxyInfo& info = |
| (...skipping 25 matching lines...) Expand all Loading... |
| 393 GetWebSocketTestDataDirectory()); | 393 GetWebSocketTestDataDirectory()); |
| 394 ASSERT_TRUE(https_server.StartInBackground()); | 394 ASSERT_TRUE(https_server.StartInBackground()); |
| 395 ASSERT_TRUE(wss_server.StartInBackground()); | 395 ASSERT_TRUE(wss_server.StartInBackground()); |
| 396 ASSERT_TRUE(https_server.BlockUntilStarted()); | 396 ASSERT_TRUE(https_server.BlockUntilStarted()); |
| 397 ASSERT_TRUE(wss_server.BlockUntilStarted()); | 397 ASSERT_TRUE(wss_server.BlockUntilStarted()); |
| 398 InitialiseContext(); | 398 InitialiseContext(); |
| 399 // Set HSTS via https: | 399 // Set HSTS via https: |
| 400 TestDelegate delegate; | 400 TestDelegate delegate; |
| 401 GURL https_page = https_server.GetURL("files/hsts-headers.html"); | 401 GURL https_page = https_server.GetURL("files/hsts-headers.html"); |
| 402 scoped_ptr<URLRequest> request( | 402 scoped_ptr<URLRequest> request( |
| 403 context_.CreateRequest(https_page, DEFAULT_PRIORITY, &delegate, NULL)); | 403 context_.CreateRequest(https_page, DEFAULT_PRIORITY, &delegate)); |
| 404 request->Start(); | 404 request->Start(); |
| 405 // TestDelegate exits the message loop when the request completes. | 405 // TestDelegate exits the message loop when the request completes. |
| 406 base::RunLoop().Run(); | 406 base::RunLoop().Run(); |
| 407 EXPECT_TRUE(request->status().is_success()); | 407 EXPECT_TRUE(request->status().is_success()); |
| 408 | 408 |
| 409 // Check HSTS with ws: | 409 // Check HSTS with ws: |
| 410 // Change the scheme from wss: to ws: to verify that it is switched back. | 410 // Change the scheme from wss: to ws: to verify that it is switched back. |
| 411 GURL ws_url = ReplaceUrlScheme(wss_server.GetURL(kEchoServer), "ws"); | 411 GURL ws_url = ReplaceUrlScheme(wss_server.GetURL(kEchoServer), "ws"); |
| 412 EXPECT_TRUE(ConnectAndWait(ws_url)); | 412 EXPECT_TRUE(ConnectAndWait(ws_url)); |
| 413 } | 413 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 426 InitialiseContext(); | 426 InitialiseContext(); |
| 427 // Set HSTS via wss: | 427 // Set HSTS via wss: |
| 428 GURL wss_url = wss_server.GetURL("set-hsts"); | 428 GURL wss_url = wss_server.GetURL("set-hsts"); |
| 429 EXPECT_TRUE(ConnectAndWait(wss_url)); | 429 EXPECT_TRUE(ConnectAndWait(wss_url)); |
| 430 | 430 |
| 431 // Verify via http: | 431 // Verify via http: |
| 432 TestDelegate delegate; | 432 TestDelegate delegate; |
| 433 GURL http_page = | 433 GURL http_page = |
| 434 ReplaceUrlScheme(https_server.GetURL("files/simple.html"), "http"); | 434 ReplaceUrlScheme(https_server.GetURL("files/simple.html"), "http"); |
| 435 scoped_ptr<URLRequest> request( | 435 scoped_ptr<URLRequest> request( |
| 436 context_.CreateRequest(http_page, DEFAULT_PRIORITY, &delegate, NULL)); | 436 context_.CreateRequest(http_page, DEFAULT_PRIORITY, &delegate)); |
| 437 request->Start(); | 437 request->Start(); |
| 438 // TestDelegate exits the message loop when the request completes. | 438 // TestDelegate exits the message loop when the request completes. |
| 439 base::RunLoop().Run(); | 439 base::RunLoop().Run(); |
| 440 EXPECT_TRUE(request->status().is_success()); | 440 EXPECT_TRUE(request->status().is_success()); |
| 441 EXPECT_TRUE(request->url().SchemeIs("https")); | 441 EXPECT_TRUE(request->url().SchemeIs("https")); |
| 442 } | 442 } |
| 443 | 443 |
| 444 TEST_F(WebSocketEndToEndTest, DISABLED_ON_ANDROID(HstsWebSocketToWebSocket)) { | 444 TEST_F(WebSocketEndToEndTest, DISABLED_ON_ANDROID(HstsWebSocketToWebSocket)) { |
| 445 SpawnedTestServer::SSLOptions ssl_options; | 445 SpawnedTestServer::SSLOptions ssl_options; |
| 446 SpawnedTestServer wss_server(SpawnedTestServer::TYPE_WSS, ssl_options, | 446 SpawnedTestServer wss_server(SpawnedTestServer::TYPE_WSS, ssl_options, |
| 447 GetWebSocketTestDataDirectory()); | 447 GetWebSocketTestDataDirectory()); |
| 448 ASSERT_TRUE(wss_server.Start()); | 448 ASSERT_TRUE(wss_server.Start()); |
| 449 InitialiseContext(); | 449 InitialiseContext(); |
| 450 // Set HSTS via wss: | 450 // Set HSTS via wss: |
| 451 GURL wss_url = wss_server.GetURL("set-hsts"); | 451 GURL wss_url = wss_server.GetURL("set-hsts"); |
| 452 EXPECT_TRUE(ConnectAndWait(wss_url)); | 452 EXPECT_TRUE(ConnectAndWait(wss_url)); |
| 453 | 453 |
| 454 // Verify via wss: | 454 // Verify via wss: |
| 455 GURL ws_url = ReplaceUrlScheme(wss_server.GetURL(kEchoServer), "ws"); | 455 GURL ws_url = ReplaceUrlScheme(wss_server.GetURL(kEchoServer), "ws"); |
| 456 EXPECT_TRUE(ConnectAndWait(ws_url)); | 456 EXPECT_TRUE(ConnectAndWait(ws_url)); |
| 457 } | 457 } |
| 458 | 458 |
| 459 } // namespace | 459 } // namespace |
| 460 | 460 |
| 461 } // namespace net | 461 } // namespace net |
| OLD | NEW |