Chromium Code Reviews| 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 "crypto/nss_util.h" | |
| 37 #include "net/base/cert_database.h" | |
| 34 #include "net/base/cert_status_flags.h" | 38 #include "net/base/cert_status_flags.h" |
| 39 #include "net/base/crypto_module.h" | |
| 40 #include "net/base/net_errors.h" | |
| 35 #include "net/test/test_server.h" | 41 #include "net/test/test_server.h" |
| 36 | 42 |
| 37 using content::InterstitialPage; | 43 using content::InterstitialPage; |
| 38 using content::NavigationController; | 44 using content::NavigationController; |
| 39 using content::NavigationEntry; | 45 using content::NavigationEntry; |
| 40 using content::SSLStatus; | 46 using content::SSLStatus; |
| 41 using content::WebContents; | 47 using content::WebContents; |
| 42 | 48 |
| 43 const FilePath::CharType kDocRoot[] = FILE_PATH_LITERAL("chrome/test/data"); | 49 const FilePath::CharType kDocRoot[] = FILE_PATH_LITERAL("chrome/test/data"); |
| 44 | 50 |
| (...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 592 | 598 |
| 593 // Proceed anyway. | 599 // Proceed anyway. |
| 594 ProceedThroughInterstitial(tab); | 600 ProceedThroughInterstitial(tab); |
| 595 | 601 |
| 596 // Test page run a WebSocket wss connection test. The result will be shown | 602 // Test page run a WebSocket wss connection test. The result will be shown |
| 597 // as page title. | 603 // as page title. |
| 598 const string16 result = watcher.WaitAndGetTitle(); | 604 const string16 result = watcher.WaitAndGetTitle(); |
| 599 EXPECT_TRUE(LowerCaseEqualsASCII(result, "pass")); | 605 EXPECT_TRUE(LowerCaseEqualsASCII(result, "pass")); |
| 600 } | 606 } |
| 601 | 607 |
| 608 #if defined(USE_NSS) | |
|
Ryan Sleevi
2012/07/13 19:25:06
nit: Add an explanation for why this is only for U
Takashi Toyoshima
2012/07/17 11:50:58
Done.
| |
| 609 // Visit a HTTPS page which requires client cert authentication. The client | |
| 610 // cert will be selected automatically, then a test which uses WebSocket runs. | |
| 611 IN_PROC_BROWSER_TEST_F(SSLUITest, TestWSSClientCert) { | |
| 612 // Open temporal NSSDB for test. | |
| 613 // TODO(toyoshim): This interface will be changed as a scoped resource. | |
| 614 // See also crypto/nss_util.h and http://crbug.com/136950#c5 . | |
|
Ryan Sleevi
2012/07/13 19:25:06
nit:
// Open a temporary NSS DB for testing.
// TO
Takashi Toyoshima
2012/07/17 11:50:58
Done.
| |
| 615 ASSERT_TRUE(crypto::OpenTestNSSDB()); | |
| 616 | |
| 617 // Import client cert for test. These interfaces require NSS. | |
| 618 net::CertDatabase cert_db; | |
| 619 scoped_refptr<net::CryptoModule> crypt_module = cert_db.GetPublicModule(); | |
| 620 std::string pkcs12_data; | |
| 621 FilePath cert_path; | |
| 622 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &cert_path)); | |
| 623 cert_path = cert_path.Append(FILE_PATH_LITERAL("ssl")); | |
| 624 cert_path = cert_path.Append(FILE_PATH_LITERAL("client_cert.p12")); | |
| 625 EXPECT_TRUE(file_util::ReadFileToString(cert_path, &pkcs12_data)); | |
| 626 EXPECT_EQ(net::OK, cert_db.ImportFromPKCS12(crypt_module, | |
| 627 pkcs12_data, | |
| 628 string16(), | |
| 629 true, | |
| 630 NULL)); | |
| 631 | |
| 632 // Start pywebsocket with TLS and client cert authentication. | |
| 633 ui_test_utils::TestWebSocketServer wss_server; | |
|
Ryan Sleevi
2012/07/13 19:25:06
A random note (and not a pre-requisite for this CL
Takashi Toyoshima
2012/07/17 11:50:58
I filed a bug on this as a TODO.
https://code.goog
| |
| 634 int port = wss_server.UseRandomPort(); | |
| 635 wss_server.UseTLS(); | |
| 636 wss_server.UseClientAuthentication(); | |
| 637 FilePath wss_root_dir; | |
| 638 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &wss_root_dir)); | |
| 639 ASSERT_TRUE(wss_server.Start(wss_root_dir)); | |
| 640 std::string urlPath = | |
| 641 StringPrintf("%s%d%s", "https://localhost:", port, "/wss.html"); | |
| 642 GURL url(urlPath); | |
| 643 | |
| 644 // Setup page title observer. | |
| 645 WebContents* tab = chrome::GetActiveWebContents(browser()); | |
| 646 ui_test_utils::TitleWatcher watcher(tab, ASCIIToUTF16("PASS")); | |
| 647 watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); | |
| 648 | |
| 649 // Add an entry into AutoSelectCertificateForUrls policy for automatic client | |
| 650 // cert selection. | |
| 651 Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext()); | |
| 652 DCHECK(profile); | |
| 653 scoped_ptr<DictionaryValue> dict(new DictionaryValue()); | |
| 654 dict->SetString("ISSUER.CN", "pywebsocket"); | |
| 655 profile->GetHostContentSettingsMap()->SetWebsiteSetting( | |
| 656 ContentSettingsPattern::FromURL(url), | |
| 657 ContentSettingsPattern::FromURL(url), | |
| 658 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, | |
| 659 std::string(), | |
| 660 dict.release()); | |
| 661 | |
| 662 // Visit a HTTPS page which requires client certs. | |
| 663 ui_test_utils::NavigateToURL(browser(), url); | |
| 664 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_COMMON_NAME_INVALID, | |
| 665 false, true); // Interstitial showing | |
|
Ryan Sleevi
2012/07/13 19:25:06
Since this is a browser test, you can/should be us
Takashi Toyoshima
2012/07/17 11:50:58
Currently, we use cert files in WebKit source code
| |
| 666 | |
| 667 // Proceed anyway. | |
| 668 ProceedThroughInterstitial(tab); | |
| 669 | |
| 670 // Test page runs a WebSocket wss connection test. The result will be shown | |
| 671 // as page title. | |
| 672 const string16 result = watcher.WaitAndGetTitle(); | |
| 673 EXPECT_TRUE(LowerCaseEqualsASCII(result, "pass")); | |
| 674 } | |
| 675 #endif // defined(USE_NSS) | |
| 676 | |
| 602 // Flaky on CrOS http://crbug.com/92292 | 677 // Flaky on CrOS http://crbug.com/92292 |
| 603 #if defined(OS_CHROMEOS) | 678 #if defined(OS_CHROMEOS) |
| 604 #define MAYBE_TestHTTPSErrorWithNoNavEntry \ | 679 #define MAYBE_TestHTTPSErrorWithNoNavEntry \ |
| 605 DISABLED_TestHTTPSErrorWithNoNavEntry | 680 DISABLED_TestHTTPSErrorWithNoNavEntry |
| 606 #else | 681 #else |
| 607 #define MAYBE_TestHTTPSErrorWithNoNavEntry TestHTTPSErrorWithNoNavEntry | 682 #define MAYBE_TestHTTPSErrorWithNoNavEntry TestHTTPSErrorWithNoNavEntry |
| 608 #endif // defined(OS_CHROMEOS) | 683 #endif // defined(OS_CHROMEOS) |
| 609 | 684 |
| 610 // Open a page with a HTTPS error in a tab with no prior navigation (through a | 685 // 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 | 686 // 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 | 1530 |
| 1456 // Visit a page over https that contains a frame with a redirect. | 1531 // Visit a page over https that contains a frame with a redirect. |
| 1457 | 1532 |
| 1458 // XMLHttpRequest insecure content in synchronous mode. | 1533 // XMLHttpRequest insecure content in synchronous mode. |
| 1459 | 1534 |
| 1460 // XMLHttpRequest insecure content in asynchronous mode. | 1535 // XMLHttpRequest insecure content in asynchronous mode. |
| 1461 | 1536 |
| 1462 // XMLHttpRequest over bad ssl in synchronous mode. | 1537 // XMLHttpRequest over bad ssl in synchronous mode. |
| 1463 | 1538 |
| 1464 // XMLHttpRequest over OK ssl in synchronous mode. | 1539 // XMLHttpRequest over OK ssl in synchronous mode. |
| OLD | NEW |