Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(450)

Side by Side Diff: chrome/browser/ssl/ssl_browser_tests.cc

Issue 10692184: Revert 146294 - - add client cert authentication support in test websocket server (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/test/base/ui_test_utils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
14 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
15 #include "chrome/browser/ui/browser_commands.h" 13 #include "chrome/browser/ui/browser_commands.h"
16 #include "chrome/browser/ui/browser_navigator.h" 14 #include "chrome/browser/ui/browser_navigator.h"
17 #include "chrome/browser/ui/browser_tabstrip.h" 15 #include "chrome/browser/ui/browser_tabstrip.h"
18 #include "chrome/browser/ui/constrained_window_tab_helper.h" 16 #include "chrome/browser/ui/constrained_window_tab_helper.h"
19 #include "chrome/browser/ui/tab_contents/tab_contents.h" 17 #include "chrome/browser/ui/tab_contents/tab_contents.h"
20 #include "chrome/browser/ui/tabs/tab_strip_model.h" 18 #include "chrome/browser/ui/tabs/tab_strip_model.h"
21 #include "chrome/common/chrome_notification_types.h" 19 #include "chrome/common/chrome_notification_types.h"
22 #include "chrome/common/chrome_paths.h" 20 #include "chrome/common/chrome_paths.h"
23 #include "chrome/common/chrome_switches.h" 21 #include "chrome/common/chrome_switches.h"
24 #include "chrome/test/base/in_process_browser_test.h" 22 #include "chrome/test/base/in_process_browser_test.h"
25 #include "chrome/test/base/ui_test_utils.h" 23 #include "chrome/test/base/ui_test_utils.h"
26 #include "content/public/browser/interstitial_page.h" 24 #include "content/public/browser/interstitial_page.h"
27 #include "content/public/browser/navigation_controller.h" 25 #include "content/public/browser/navigation_controller.h"
28 #include "content/public/browser/navigation_entry.h" 26 #include "content/public/browser/navigation_entry.h"
29 #include "content/public/browser/notification_service.h" 27 #include "content/public/browser/notification_service.h"
30 #include "content/public/browser/render_view_host.h" 28 #include "content/public/browser/render_view_host.h"
31 #include "content/public/browser/web_contents.h" 29 #include "content/public/browser/web_contents.h"
32 #include "content/public/browser/web_contents_observer.h" 30 #include "content/public/browser/web_contents_observer.h"
33 #include "content/public/common/security_style.h" 31 #include "content/public/common/security_style.h"
34 #include "content/public/common/ssl_status.h" 32 #include "content/public/common/ssl_status.h"
35 #include "content/public/test/test_renderer_host.h" 33 #include "content/public/test/test_renderer_host.h"
36 #include "net/base/cert_database.h"
37 #include "net/base/cert_status_flags.h" 34 #include "net/base/cert_status_flags.h"
38 #include "net/base/crypto_module.h"
39 #include "net/base/net_errors.h"
40 #include "net/test/test_server.h" 35 #include "net/test/test_server.h"
41 36
42 using content::InterstitialPage; 37 using content::InterstitialPage;
43 using content::NavigationController; 38 using content::NavigationController;
44 using content::NavigationEntry; 39 using content::NavigationEntry;
45 using content::SSLStatus; 40 using content::SSLStatus;
46 using content::WebContents; 41 using content::WebContents;
47 42
48 const FilePath::CharType kDocRoot[] = FILE_PATH_LITERAL("chrome/test/data"); 43 const FilePath::CharType kDocRoot[] = FILE_PATH_LITERAL("chrome/test/data");
49 44
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 592
598 // Proceed anyway. 593 // Proceed anyway.
599 ProceedThroughInterstitial(tab); 594 ProceedThroughInterstitial(tab);
600 595
601 // Test page run a WebSocket wss connection test. The result will be shown 596 // Test page run a WebSocket wss connection test. The result will be shown
602 // as page title. 597 // as page title.
603 const string16 result = watcher.WaitAndGetTitle(); 598 const string16 result = watcher.WaitAndGetTitle();
604 EXPECT_TRUE(LowerCaseEqualsASCII(result, "pass")); 599 EXPECT_TRUE(LowerCaseEqualsASCII(result, "pass"));
605 } 600 }
606 601
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
671 // Flaky on CrOS http://crbug.com/92292 602 // Flaky on CrOS http://crbug.com/92292
672 #if defined(OS_CHROMEOS) 603 #if defined(OS_CHROMEOS)
673 #define MAYBE_TestHTTPSErrorWithNoNavEntry \ 604 #define MAYBE_TestHTTPSErrorWithNoNavEntry \
674 DISABLED_TestHTTPSErrorWithNoNavEntry 605 DISABLED_TestHTTPSErrorWithNoNavEntry
675 #else 606 #else
676 #define MAYBE_TestHTTPSErrorWithNoNavEntry TestHTTPSErrorWithNoNavEntry 607 #define MAYBE_TestHTTPSErrorWithNoNavEntry TestHTTPSErrorWithNoNavEntry
677 #endif // defined(OS_CHROMEOS) 608 #endif // defined(OS_CHROMEOS)
678 609
679 // Open a page with a HTTPS error in a tab with no prior navigation (through a 610 // Open a page with a HTTPS error in a tab with no prior navigation (through a
680 // link with a blank target). This is to test that the lack of navigation entry 611 // 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
1524 1455
1525 // Visit a page over https that contains a frame with a redirect. 1456 // Visit a page over https that contains a frame with a redirect.
1526 1457
1527 // XMLHttpRequest insecure content in synchronous mode. 1458 // XMLHttpRequest insecure content in synchronous mode.
1528 1459
1529 // XMLHttpRequest insecure content in asynchronous mode. 1460 // XMLHttpRequest insecure content in asynchronous mode.
1530 1461
1531 // XMLHttpRequest over bad ssl in synchronous mode. 1462 // XMLHttpRequest over bad ssl in synchronous mode.
1532 1463
1533 // XMLHttpRequest over OK ssl in synchronous mode. 1464 // XMLHttpRequest over OK ssl in synchronous mode.
OLDNEW
« no previous file with comments | « no previous file | chrome/test/base/ui_test_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698