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

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

Issue 1355413003: Move error classification into the ssl_errors component (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes for estark Created 5 years, 2 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
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/bind.h" 5 #include "base/bind.h"
6 #include "base/bind_helpers.h" 6 #include "base/bind_helpers.h"
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/metrics/field_trial.h" 10 #include "base/metrics/field_trial.h"
(...skipping 13 matching lines...) Expand all
24 #include "chrome/browser/interstitials/security_interstitial_page_test_utils.h" 24 #include "chrome/browser/interstitials/security_interstitial_page_test_utils.h"
25 #include "chrome/browser/profiles/profile.h" 25 #include "chrome/browser/profiles/profile.h"
26 #include "chrome/browser/ssl/bad_clock_blocking_page.h" 26 #include "chrome/browser/ssl/bad_clock_blocking_page.h"
27 #include "chrome/browser/ssl/cert_report_helper.h" 27 #include "chrome/browser/ssl/cert_report_helper.h"
28 #include "chrome/browser/ssl/cert_verifier_browser_test.h" 28 #include "chrome/browser/ssl/cert_verifier_browser_test.h"
29 #include "chrome/browser/ssl/certificate_reporting_test_utils.h" 29 #include "chrome/browser/ssl/certificate_reporting_test_utils.h"
30 #include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h" 30 #include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h"
31 #include "chrome/browser/ssl/common_name_mismatch_handler.h" 31 #include "chrome/browser/ssl/common_name_mismatch_handler.h"
32 #include "chrome/browser/ssl/security_state_model.h" 32 #include "chrome/browser/ssl/security_state_model.h"
33 #include "chrome/browser/ssl/ssl_blocking_page.h" 33 #include "chrome/browser/ssl/ssl_blocking_page.h"
34 #include "chrome/browser/ssl/ssl_error_classification.h"
35 #include "chrome/browser/ssl/ssl_error_handler.h" 34 #include "chrome/browser/ssl/ssl_error_handler.h"
36 #include "chrome/browser/ui/browser.h" 35 #include "chrome/browser/ui/browser.h"
37 #include "chrome/browser/ui/browser_commands.h" 36 #include "chrome/browser/ui/browser_commands.h"
38 #include "chrome/browser/ui/browser_navigator.h" 37 #include "chrome/browser/ui/browser_navigator.h"
39 #include "chrome/browser/ui/browser_navigator_params.h" 38 #include "chrome/browser/ui/browser_navigator_params.h"
40 #include "chrome/browser/ui/browser_tabstrip.h" 39 #include "chrome/browser/ui/browser_tabstrip.h"
41 #include "chrome/browser/ui/tabs/tab_strip_model.h" 40 #include "chrome/browser/ui/tabs/tab_strip_model.h"
42 #include "chrome/common/chrome_paths.h" 41 #include "chrome/common/chrome_paths.h"
43 #include "chrome/common/chrome_switches.h" 42 #include "chrome/common/chrome_switches.h"
44 #include "chrome/common/pref_names.h" 43 #include "chrome/common/pref_names.h"
45 #include "chrome/test/base/in_process_browser_test.h" 44 #include "chrome/test/base/in_process_browser_test.h"
46 #include "chrome/test/base/ui_test_utils.h" 45 #include "chrome/test/base/ui_test_utils.h"
47 #include "components/content_settings/core/browser/host_content_settings_map.h" 46 #include "components/content_settings/core/browser/host_content_settings_map.h"
48 #include "components/security_interstitials/core/metrics_helper.h" 47 #include "components/security_interstitials/core/metrics_helper.h"
48 #include "components/ssl_errors/error_classification.h"
49 #include "components/variations/variations_associated_data.h" 49 #include "components/variations/variations_associated_data.h"
50 #include "components/web_modal/web_contents_modal_dialog_manager.h" 50 #include "components/web_modal/web_contents_modal_dialog_manager.h"
51 #include "content/public/browser/browser_context.h" 51 #include "content/public/browser/browser_context.h"
52 #include "content/public/browser/cert_store.h" 52 #include "content/public/browser/cert_store.h"
53 #include "content/public/browser/interstitial_page.h" 53 #include "content/public/browser/interstitial_page.h"
54 #include "content/public/browser/navigation_controller.h" 54 #include "content/public/browser/navigation_controller.h"
55 #include "content/public/browser/navigation_entry.h" 55 #include "content/public/browser/navigation_entry.h"
56 #include "content/public/browser/notification_service.h" 56 #include "content/public/browser/notification_service.h"
57 #include "content/public/browser/render_frame_host.h" 57 #include "content/public/browser/render_frame_host.h"
58 #include "content/public/browser/render_view_host.h" 58 #include "content/public/browser/render_view_host.h"
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 Browser* browser) { 502 Browser* browser) {
503 base::RunLoop run_loop; 503 base::RunLoop run_loop;
504 ASSERT_TRUE(https_server_expired_.Start()); 504 ASSERT_TRUE(https_server_expired_.Start());
505 ASSERT_NO_FATAL_FAILURE(SetUpMockReporter()); 505 ASSERT_NO_FATAL_FAILURE(SetUpMockReporter());
506 506
507 // Set up the build and current clock times to be more than a year apart. 507 // Set up the build and current clock times to be more than a year apart.
508 scoped_ptr<base::SimpleTestClock> mock_clock(new base::SimpleTestClock()); 508 scoped_ptr<base::SimpleTestClock> mock_clock(new base::SimpleTestClock());
509 mock_clock->SetNow(base::Time::NowFromSystemTime()); 509 mock_clock->SetNow(base::Time::NowFromSystemTime());
510 mock_clock->Advance(base::TimeDelta::FromDays(367)); 510 mock_clock->Advance(base::TimeDelta::FromDays(367));
511 SSLErrorHandler::SetClockForTest(mock_clock.get()); 511 SSLErrorHandler::SetClockForTest(mock_clock.get());
512 SSLErrorClassification::SetBuildTimeForTesting( 512 ssl_errors::SetBuildTimeForTesting(base::Time::NowFromSystemTime());
513 base::Time::NowFromSystemTime());
514 513
515 // Opt in to sending reports for invalid certificate chains. 514 // Opt in to sending reports for invalid certificate chains.
516 certificate_reporting_test_utils::SetCertReportingOptIn(browser, opt_in); 515 certificate_reporting_test_utils::SetCertReportingOptIn(browser, opt_in);
517 516
518 ui_test_utils::NavigateToURL(browser, https_server_expired_.GetURL("/")); 517 ui_test_utils::NavigateToURL(browser, https_server_expired_.GetURL("/"));
519 518
520 WebContents* tab = browser->tab_strip_model()->GetActiveWebContents(); 519 WebContents* tab = browser->tab_strip_model()->GetActiveWebContents();
521 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, 520 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID,
522 AuthState::SHOWING_INTERSTITIAL); 521 AuthState::SHOWING_INTERSTITIAL);
523 522
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 } 856 }
858 857
859 IN_PROC_BROWSER_TEST_F(SSLUITest, TestHTTPSErrorCausedByClock) { 858 IN_PROC_BROWSER_TEST_F(SSLUITest, TestHTTPSErrorCausedByClock) {
860 ASSERT_TRUE(https_server_expired_.Start()); 859 ASSERT_TRUE(https_server_expired_.Start());
861 860
862 // Set up the build and current clock times to be more than a year apart. 861 // Set up the build and current clock times to be more than a year apart.
863 scoped_ptr<base::SimpleTestClock> mock_clock(new base::SimpleTestClock()); 862 scoped_ptr<base::SimpleTestClock> mock_clock(new base::SimpleTestClock());
864 mock_clock->SetNow(base::Time::NowFromSystemTime()); 863 mock_clock->SetNow(base::Time::NowFromSystemTime());
865 mock_clock->Advance(base::TimeDelta::FromDays(367)); 864 mock_clock->Advance(base::TimeDelta::FromDays(367));
866 SSLErrorHandler::SetClockForTest(mock_clock.get()); 865 SSLErrorHandler::SetClockForTest(mock_clock.get());
867 SSLErrorClassification::SetBuildTimeForTesting( 866 ssl_errors::SetBuildTimeForTesting(base::Time::NowFromSystemTime());
868 base::Time::NowFromSystemTime());
869 867
870 ui_test_utils::NavigateToURL(browser(), https_server_expired_.GetURL("/")); 868 ui_test_utils::NavigateToURL(browser(), https_server_expired_.GetURL("/"));
871 WebContents* clock_tab = browser()->tab_strip_model()->GetActiveWebContents(); 869 WebContents* clock_tab = browser()->tab_strip_model()->GetActiveWebContents();
872 content::WaitForInterstitialAttach(clock_tab); 870 content::WaitForInterstitialAttach(clock_tab);
873 InterstitialPage* clock_interstitial = clock_tab->GetInterstitialPage(); 871 InterstitialPage* clock_interstitial = clock_tab->GetInterstitialPage();
874 ASSERT_TRUE(clock_interstitial); 872 ASSERT_TRUE(clock_interstitial);
875 EXPECT_EQ(BadClockBlockingPage::kTypeForTesting, 873 EXPECT_EQ(BadClockBlockingPage::kTypeForTesting,
876 clock_interstitial->GetDelegateForTesting()->GetTypeForTesting()); 874 clock_interstitial->GetDelegateForTesting()->GetTypeForTesting());
877 } 875 }
878 876
(...skipping 1605 matching lines...) Expand 10 before | Expand all | Expand 10 after
2484 SSLStatusMatchesonClockInterstitialAndAfterProceed) { 2482 SSLStatusMatchesonClockInterstitialAndAfterProceed) {
2485 ASSERT_TRUE(https_server_expired_.Start()); 2483 ASSERT_TRUE(https_server_expired_.Start());
2486 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); 2484 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
2487 ASSERT_TRUE(tab); 2485 ASSERT_TRUE(tab);
2488 2486
2489 // Set up the build and current clock times to be more than a year apart. 2487 // Set up the build and current clock times to be more than a year apart.
2490 base::SimpleTestClock mock_clock; 2488 base::SimpleTestClock mock_clock;
2491 mock_clock.SetNow(base::Time::NowFromSystemTime()); 2489 mock_clock.SetNow(base::Time::NowFromSystemTime());
2492 mock_clock.Advance(base::TimeDelta::FromDays(367)); 2490 mock_clock.Advance(base::TimeDelta::FromDays(367));
2493 SSLErrorHandler::SetClockForTest(&mock_clock); 2491 SSLErrorHandler::SetClockForTest(&mock_clock);
2494 SSLErrorClassification::SetBuildTimeForTesting( 2492 ssl_errors::SetBuildTimeForTesting(base::Time::NowFromSystemTime());
2495 base::Time::NowFromSystemTime());
2496 2493
2497 ui_test_utils::NavigateToURL(browser(), https_server_expired_.GetURL("/")); 2494 ui_test_utils::NavigateToURL(browser(), https_server_expired_.GetURL("/"));
2498 content::WaitForInterstitialAttach(tab); 2495 content::WaitForInterstitialAttach(tab);
2499 InterstitialPage* clock_interstitial = tab->GetInterstitialPage(); 2496 InterstitialPage* clock_interstitial = tab->GetInterstitialPage();
2500 ASSERT_TRUE(clock_interstitial); 2497 ASSERT_TRUE(clock_interstitial);
2501 EXPECT_EQ(BadClockBlockingPage::kTypeForTesting, 2498 EXPECT_EQ(BadClockBlockingPage::kTypeForTesting,
2502 clock_interstitial->GetDelegateForTesting()->GetTypeForTesting()); 2499 clock_interstitial->GetDelegateForTesting()->GetTypeForTesting());
2503 2500
2504 // Grab the SSLStatus on the clock interstitial. 2501 // Grab the SSLStatus on the clock interstitial.
2505 content::NavigationEntry* entry = tab->GetController().GetActiveEntry(); 2502 content::NavigationEntry* entry = tab->GetController().GetActiveEntry();
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
2907 2904
2908 // Visit a page over https that contains a frame with a redirect. 2905 // Visit a page over https that contains a frame with a redirect.
2909 2906
2910 // XMLHttpRequest insecure content in synchronous mode. 2907 // XMLHttpRequest insecure content in synchronous mode.
2911 2908
2912 // XMLHttpRequest insecure content in asynchronous mode. 2909 // XMLHttpRequest insecure content in asynchronous mode.
2913 2910
2914 // XMLHttpRequest over bad ssl in synchronous mode. 2911 // XMLHttpRequest over bad ssl in synchronous mode.
2915 2912
2916 // XMLHttpRequest over OK ssl in synchronous mode. 2913 // XMLHttpRequest over OK ssl in synchronous mode.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698