OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
9 #include "base/time.h" | 9 #include "base/time.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
11 #include "chrome/app/chrome_command_ids.h" | 11 #include "chrome/app/chrome_command_ids.h" |
| 12 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 13 #include "chrome/browser/profiles/profile.h" |
12 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
13 #include "chrome/browser/ui/browser_commands.h" | 15 #include "chrome/browser/ui/browser_commands.h" |
14 #include "chrome/browser/ui/browser_navigator.h" | 16 #include "chrome/browser/ui/browser_navigator.h" |
15 #include "chrome/browser/ui/browser_tabstrip.h" | 17 #include "chrome/browser/ui/browser_tabstrip.h" |
16 #include "chrome/browser/ui/constrained_window_tab_helper.h" | 18 #include "chrome/browser/ui/constrained_window_tab_helper.h" |
17 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 19 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
18 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 20 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
19 #include "chrome/common/chrome_notification_types.h" | 21 #include "chrome/common/chrome_notification_types.h" |
20 #include "chrome/common/chrome_paths.h" | 22 #include "chrome/common/chrome_paths.h" |
21 #include "chrome/common/chrome_switches.h" | 23 #include "chrome/common/chrome_switches.h" |
22 #include "chrome/test/base/in_process_browser_test.h" | 24 #include "chrome/test/base/in_process_browser_test.h" |
23 #include "chrome/test/base/ui_test_utils.h" | 25 #include "chrome/test/base/ui_test_utils.h" |
24 #include "content/public/browser/interstitial_page.h" | 26 #include "content/public/browser/interstitial_page.h" |
25 #include "content/public/browser/navigation_controller.h" | 27 #include "content/public/browser/navigation_controller.h" |
26 #include "content/public/browser/navigation_entry.h" | 28 #include "content/public/browser/navigation_entry.h" |
27 #include "content/public/browser/notification_service.h" | 29 #include "content/public/browser/notification_service.h" |
28 #include "content/public/browser/render_view_host.h" | 30 #include "content/public/browser/render_view_host.h" |
29 #include "content/public/browser/web_contents.h" | 31 #include "content/public/browser/web_contents.h" |
30 #include "content/public/browser/web_contents_observer.h" | 32 #include "content/public/browser/web_contents_observer.h" |
31 #include "content/public/common/security_style.h" | 33 #include "content/public/common/security_style.h" |
32 #include "content/public/common/ssl_status.h" | 34 #include "content/public/common/ssl_status.h" |
33 #include "content/public/test/test_renderer_host.h" | 35 #include "content/public/test/test_renderer_host.h" |
| 36 #include "net/base/cert_database.h" |
34 #include "net/base/cert_status_flags.h" | 37 #include "net/base/cert_status_flags.h" |
| 38 #include "net/base/crypto_module.h" |
| 39 #include "net/base/net_errors.h" |
35 #include "net/test/test_server.h" | 40 #include "net/test/test_server.h" |
36 | 41 |
37 using content::InterstitialPage; | 42 using content::InterstitialPage; |
38 using content::NavigationController; | 43 using content::NavigationController; |
39 using content::NavigationEntry; | 44 using content::NavigationEntry; |
40 using content::SSLStatus; | 45 using content::SSLStatus; |
41 using content::WebContents; | 46 using content::WebContents; |
42 | 47 |
43 const FilePath::CharType kDocRoot[] = FILE_PATH_LITERAL("chrome/test/data"); | 48 const FilePath::CharType kDocRoot[] = FILE_PATH_LITERAL("chrome/test/data"); |
44 | 49 |
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 | 597 |
593 // Proceed anyway. | 598 // Proceed anyway. |
594 ProceedThroughInterstitial(tab); | 599 ProceedThroughInterstitial(tab); |
595 | 600 |
596 // Test page run a WebSocket wss connection test. The result will be shown | 601 // Test page run a WebSocket wss connection test. The result will be shown |
597 // as page title. | 602 // as page title. |
598 const string16 result = watcher.WaitAndGetTitle(); | 603 const string16 result = watcher.WaitAndGetTitle(); |
599 EXPECT_TRUE(LowerCaseEqualsASCII(result, "pass")); | 604 EXPECT_TRUE(LowerCaseEqualsASCII(result, "pass")); |
600 } | 605 } |
601 | 606 |
| 607 #if defined(USE_NSS) |
| 608 // Visit a HTTPS page which requires client cert authentication. The client |
| 609 // cert will be selected automatically, then a test which uses WebSocket runs. |
| 610 IN_PROC_BROWSER_TEST_F(SSLUITest, TestWSSClientCert) { |
| 611 // Import client cert for test. These interfaces require NSS. |
| 612 net::CertDatabase cert_db; |
| 613 scoped_refptr<net::CryptoModule> crypt_module = cert_db.GetPublicModule(); |
| 614 std::string pkcs12_data; |
| 615 FilePath cert_path; |
| 616 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &cert_path)); |
| 617 cert_path = cert_path.Append(FILE_PATH_LITERAL("ssl")); |
| 618 cert_path = cert_path.Append(FILE_PATH_LITERAL("client_cert.p12")); |
| 619 EXPECT_TRUE(file_util::ReadFileToString(cert_path, &pkcs12_data)); |
| 620 EXPECT_EQ(net::OK, cert_db.ImportFromPKCS12(crypt_module, |
| 621 pkcs12_data, |
| 622 string16(), |
| 623 true, |
| 624 NULL)); |
| 625 |
| 626 // Start pywebsocket with TLS and client cert authentication. |
| 627 ui_test_utils::TestWebSocketServer wss_server; |
| 628 int port = wss_server.UseRandomPort(); |
| 629 wss_server.UseTLS(); |
| 630 wss_server.UseClientAuthentication(); |
| 631 FilePath wss_root_dir; |
| 632 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &wss_root_dir)); |
| 633 ASSERT_TRUE(wss_server.Start(wss_root_dir)); |
| 634 std::string urlPath = |
| 635 StringPrintf("%s%d%s", "https://localhost:", port, "/wss.html"); |
| 636 GURL url(urlPath); |
| 637 |
| 638 // Setup page title observer. |
| 639 WebContents* tab = chrome::GetActiveWebContents(browser()); |
| 640 ui_test_utils::TitleWatcher watcher(tab, ASCIIToUTF16("PASS")); |
| 641 watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); |
| 642 |
| 643 // Add an entry into AutoSelectCertificateForUrls policy for automatic client |
| 644 // cert selection. |
| 645 Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext()); |
| 646 DCHECK(profile); |
| 647 scoped_ptr<DictionaryValue> dict(new DictionaryValue()); |
| 648 dict->SetString("ISSUER.CN", "pywebsocket"); |
| 649 profile->GetHostContentSettingsMap()->SetWebsiteSetting( |
| 650 ContentSettingsPattern::FromURL(url), |
| 651 ContentSettingsPattern::FromURL(url), |
| 652 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, |
| 653 std::string(), |
| 654 dict.release()); |
| 655 |
| 656 // Visit a HTTPS page which requires client certs. |
| 657 ui_test_utils::NavigateToURL(browser(), url); |
| 658 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_COMMON_NAME_INVALID, |
| 659 false, true); // Interstitial showing |
| 660 |
| 661 // Proceed anyway. |
| 662 ProceedThroughInterstitial(tab); |
| 663 |
| 664 // Test page runs a WebSocket wss connection test. The result will be shown |
| 665 // as page title. |
| 666 const string16 result = watcher.WaitAndGetTitle(); |
| 667 EXPECT_TRUE(LowerCaseEqualsASCII(result, "pass")); |
| 668 } |
| 669 #endif // defined(USE_NSS) |
| 670 |
602 // Flaky on CrOS http://crbug.com/92292 | 671 // Flaky on CrOS http://crbug.com/92292 |
603 #if defined(OS_CHROMEOS) | 672 #if defined(OS_CHROMEOS) |
604 #define MAYBE_TestHTTPSErrorWithNoNavEntry \ | 673 #define MAYBE_TestHTTPSErrorWithNoNavEntry \ |
605 DISABLED_TestHTTPSErrorWithNoNavEntry | 674 DISABLED_TestHTTPSErrorWithNoNavEntry |
606 #else | 675 #else |
607 #define MAYBE_TestHTTPSErrorWithNoNavEntry TestHTTPSErrorWithNoNavEntry | 676 #define MAYBE_TestHTTPSErrorWithNoNavEntry TestHTTPSErrorWithNoNavEntry |
608 #endif // defined(OS_CHROMEOS) | 677 #endif // defined(OS_CHROMEOS) |
609 | 678 |
610 // Open a page with a HTTPS error in a tab with no prior navigation (through a | 679 // Open a page with a HTTPS error in a tab with no prior navigation (through a |
611 // link with a blank target). This is to test that the lack of navigation entry | 680 // link with a blank target). This is to test that the lack of navigation entry |
(...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1455 | 1524 |
1456 // Visit a page over https that contains a frame with a redirect. | 1525 // Visit a page over https that contains a frame with a redirect. |
1457 | 1526 |
1458 // XMLHttpRequest insecure content in synchronous mode. | 1527 // XMLHttpRequest insecure content in synchronous mode. |
1459 | 1528 |
1460 // XMLHttpRequest insecure content in asynchronous mode. | 1529 // XMLHttpRequest insecure content in asynchronous mode. |
1461 | 1530 |
1462 // XMLHttpRequest over bad ssl in synchronous mode. | 1531 // XMLHttpRequest over bad ssl in synchronous mode. |
1463 | 1532 |
1464 // XMLHttpRequest over OK ssl in synchronous mode. | 1533 // XMLHttpRequest over OK ssl in synchronous mode. |
OLD | NEW |