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

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

Issue 16207: Make ssl_client_socket_unittest use a local server (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 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 | « chrome/browser/net/url_fetcher_unittest.cc ('k') | net/base/ssl_client_socket_nss.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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 <Windows.h> 5 #include <Windows.h>
6 #include <Wincrypt.h> 6 #include <Wincrypt.h>
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "chrome/common/filter_policy.h" 10 #include "chrome/common/filter_policy.h"
11 #include "chrome/common/pref_names.h" 11 #include "chrome/common/pref_names.h"
12 #include "chrome/test/automation/browser_proxy.h" 12 #include "chrome/test/automation/browser_proxy.h"
13 #include "chrome/test/automation/tab_proxy.h" 13 #include "chrome/test/automation/tab_proxy.h"
14 #include "chrome/test/ui/ui_test.h" 14 #include "chrome/test/ui/ui_test.h"
15 #include "net/base/ssl_test_util.h" 15 #include "net/base/ssl_test_util.h"
16 #include "net/url_request/url_request_unittest.h" 16 #include "net/url_request/url_request_unittest.h"
17 17
18 namespace { 18 namespace {
19 19
20 const wchar_t kDocRoot[] = L"chrome/test/data"; 20 const wchar_t kDocRoot[] = L"chrome/test/data";
21 21
22 class SSLUITest : public UITest { 22 class SSLUITest : public UITest {
23 protected: 23 protected:
24 SSLUITest() { 24 SSLUITest() {
25 dom_automation_enabled_ = true; 25 dom_automation_enabled_ = true;
26 EXPECT_TRUE(util_.CheckCATrusted());
27 } 26 }
28 27
29 TabProxy* GetActiveTabProxy() { 28 TabProxy* GetActiveTabProxy() {
30 scoped_ptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0)); 29 scoped_ptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0));
31 EXPECT_TRUE(browser_proxy.get()); 30 EXPECT_TRUE(browser_proxy.get());
32 return browser_proxy->GetActiveTab(); 31 return browser_proxy->GetActiveTab();
33 } 32 }
34 33
35 void NavigateTab(TabProxy* tab_proxy, const GURL& url) { 34 void NavigateTab(TabProxy* tab_proxy, const GURL& url) {
36 ASSERT_TRUE(tab_proxy->NavigateToURL(url)); 35 ASSERT_TRUE(tab_proxy->NavigateToURL(url));
37 } 36 }
38 37
39 void AppendTab(const GURL& url) { 38 void AppendTab(const GURL& url) {
40 scoped_ptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0)); 39 scoped_ptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0));
41 EXPECT_TRUE(browser_proxy.get()); 40 EXPECT_TRUE(browser_proxy.get());
42 EXPECT_TRUE(browser_proxy->AppendTab(url)); 41 EXPECT_TRUE(browser_proxy->AppendTab(url));
43 } 42 }
44 43
45 HTTPTestServer* PlainServer() { 44 HTTPTestServer* PlainServer() {
46 return HTTPTestServer::CreateServer(kDocRoot, NULL); 45 return HTTPTestServer::CreateServer(kDocRoot, NULL);
47 } 46 }
48 47
49 HTTPSTestServer* GoodCertServer() { 48 HTTPSTestServer* GoodCertServer() {
50 return HTTPSTestServer::CreateServer(util_.kHostName, util_.kOKHTTPSPort, 49 return HTTPSTestServer::CreateGoodServer(kDocRoot);
51 kDocRoot, util_.GetOKCertPath().ToWStringHack());
52 } 50 }
53 51
54 HTTPSTestServer* BadCertServer() { 52 HTTPSTestServer* BadCertServer() {
55 return HTTPSTestServer::CreateServer(util_.kHostName, util_.kBadHTTPSPort, 53 return HTTPSTestServer::CreateExpiredServer(kDocRoot);
56 kDocRoot, util_.GetExpiredCertPath().ToWStringHack());
57 } 54 }
58 55
59 protected: 56 protected:
60 SSLTestUtil util_;
61
62 DISALLOW_COPY_AND_ASSIGN(SSLUITest); 57 DISALLOW_COPY_AND_ASSIGN(SSLUITest);
63 }; 58 };
64 59
65 } // namespace 60 } // namespace
66 61
67 // Visits a regular page over http. 62 // Visits a regular page over http.
68 TEST_F(SSLUITest, TestHTTP) { 63 TEST_F(SSLUITest, TestHTTP) {
69 scoped_refptr<HTTPTestServer> server = PlainServer(); 64 scoped_refptr<HTTPTestServer> server = PlainServer();
70 65
71 scoped_ptr<TabProxy> tab(GetActiveTabProxy()); 66 scoped_ptr<TabProxy> tab(GetActiveTabProxy());
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 cert_status & net::CERT_STATUS_ALL_ERRORS); // No errors expected. 412 cert_status & net::CERT_STATUS_ALL_ERRORS); // No errors expected.
418 EXPECT_EQ(NavigationEntry::SSLStatus::MIXED_CONTENT, mixed_content_state); 413 EXPECT_EQ(NavigationEntry::SSLStatus::MIXED_CONTENT, mixed_content_state);
419 } 414 }
420 415
421 // This test ensures the CN invalid status does not 'stick' to a certificate 416 // This test ensures the CN invalid status does not 'stick' to a certificate
422 // (see bug #1044942) and that it depends on the host-name. 417 // (see bug #1044942) and that it depends on the host-name.
423 // TODO(jcampan): this test is flacky and fails sometimes (bug #1065095) 418 // TODO(jcampan): this test is flacky and fails sometimes (bug #1065095)
424 TEST_F(SSLUITest, DISABLED_TestCNInvalidStickiness) { 419 TEST_F(SSLUITest, DISABLED_TestCNInvalidStickiness) {
425 const std::string kLocalHost = "localhost"; 420 const std::string kLocalHost = "localhost";
426 scoped_refptr<HTTPSTestServer> https_server = 421 scoped_refptr<HTTPSTestServer> https_server =
427 HTTPSTestServer::CreateServer(kLocalHost, util_.kOKHTTPSPort, 422 HTTPSTestServer::CreateMismatchedServer(kDocRoot);
428 kDocRoot, util_.GetOKCertPath().ToWStringHack());
429 ASSERT_TRUE(NULL != https_server.get()); 423 ASSERT_TRUE(NULL != https_server.get());
430 424
431 // First we hit the server with hostname, this generates an invalid policy 425 // First we hit the server with hostname, this generates an invalid policy
432 // error. 426 // error.
433 scoped_ptr<TabProxy> tab(GetActiveTabProxy()); 427 scoped_ptr<TabProxy> tab(GetActiveTabProxy());
434 NavigateTab(tab.get(), https_server->TestServerPageW( 428 NavigateTab(tab.get(), https_server->TestServerPageW(
435 L"files/ssl/google.html")); 429 L"files/ssl/google.html"));
436 430
437 // We get an interstitial page as a result. 431 // We get an interstitial page as a result.
438 NavigationEntry::PageType page_type; 432 NavigationEntry::PageType page_type;
(...skipping 16 matching lines...) Expand all
455 EXPECT_EQ(NavigationEntry::NORMAL_PAGE, page_type); 449 EXPECT_EQ(NavigationEntry::NORMAL_PAGE, page_type);
456 450
457 // Now we try again with the right host name this time. 451 // Now we try again with the right host name this time.
458 452
459 // Let's change the host-name in the url. 453 // Let's change the host-name in the url.
460 GURL url = https_server->TestServerPageW(L"files/ssl/google.html"); 454 GURL url = https_server->TestServerPageW(L"files/ssl/google.html");
461 std::string::size_type hostname_index = url.spec().find(kLocalHost); 455 std::string::size_type hostname_index = url.spec().find(kLocalHost);
462 ASSERT_TRUE(hostname_index != std::string::npos); // Test sanity check. 456 ASSERT_TRUE(hostname_index != std::string::npos); // Test sanity check.
463 std::string new_url; 457 std::string new_url;
464 new_url.append(url.spec().substr(0, hostname_index)); 458 new_url.append(url.spec().substr(0, hostname_index));
465 new_url.append(util_.kHostName); 459 new_url.append(net::TestServerLauncher::kHostName);
466 new_url.append(url.spec().substr(hostname_index + kLocalHost.size())); 460 new_url.append(url.spec().substr(hostname_index + kLocalHost.size()));
467 461
468 NavigateTab(tab.get(), GURL(new_url)); 462 NavigateTab(tab.get(), GURL(new_url));
469 463
470 // Security state should be OK. 464 // Security state should be OK.
471 EXPECT_TRUE(tab->GetSecurityState(&security_style, &cert_status, 465 EXPECT_TRUE(tab->GetSecurityState(&security_style, &cert_status,
472 &mixed_content_state)); 466 &mixed_content_state));
473 EXPECT_EQ(SECURITY_STYLE_AUTHENTICATED, security_style); 467 EXPECT_EQ(SECURITY_STYLE_AUTHENTICATED, security_style);
474 EXPECT_EQ(0, 468 EXPECT_EQ(0,
475 cert_status & net::CERT_STATUS_ALL_ERRORS); // No errors expected. 469 cert_status & net::CERT_STATUS_ALL_ERRORS); // No errors expected.
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
924 918
925 // Visit a page over https that contains a frame with a redirect. 919 // Visit a page over https that contains a frame with a redirect.
926 920
927 // XMLHttpRequest mixed in synchronous mode. 921 // XMLHttpRequest mixed in synchronous mode.
928 922
929 // XMLHttpRequest mixed in asynchronous mode. 923 // XMLHttpRequest mixed in asynchronous mode.
930 924
931 // XMLHttpRequest over bad ssl in synchronous mode. 925 // XMLHttpRequest over bad ssl in synchronous mode.
932 926
933 // XMLHttpRequest over OK ssl in synchronous mode. 927 // XMLHttpRequest over OK ssl in synchronous mode.
OLDNEW
« no previous file with comments | « chrome/browser/net/url_fetcher_unittest.cc ('k') | net/base/ssl_client_socket_nss.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698