| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "chrome/browser/ssl/chrome_security_state_model_client.h" | 5 #include "chrome/browser/ssl/chrome_security_state_model_client.h" |
| 6 | 6 |
| 7 #include <openssl/ssl.h> | 7 #include <openssl/ssl.h> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/strings/string_split.h" | 12 #include "base/strings/string_split.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "chrome/browser/ssl/cert_verifier_browser_test.h" | 14 #include "chrome/browser/ssl/cert_verifier_browser_test.h" |
| 15 #include "chrome/browser/ssl/chrome_security_state_model_client.h" | 15 #include "chrome/browser/ssl/chrome_security_state_model_client.h" |
| 16 #include "chrome/browser/ssl/ssl_blocking_page.h" | 16 #include "chrome/browser/ssl/ssl_blocking_page.h" |
| 17 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
| 18 #include "chrome/browser/ui/browser_commands.h" | 18 #include "chrome/browser/ui/browser_commands.h" |
| 19 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 19 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 20 #include "chrome/common/chrome_paths.h" | 20 #include "chrome/common/chrome_paths.h" |
| 21 #include "chrome/common/chrome_switches.h" | 21 #include "chrome/common/chrome_switches.h" |
| 22 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
| 23 #include "chrome/grit/generated_resources.h" | |
| 24 #include "chrome/test/base/in_process_browser_test.h" | 23 #include "chrome/test/base/in_process_browser_test.h" |
| 25 #include "chrome/test/base/ui_test_utils.h" | 24 #include "chrome/test/base/ui_test_utils.h" |
| 26 #include "components/prefs/pref_service.h" | 25 #include "components/prefs/pref_service.h" |
| 27 #include "components/security_state/switches.h" | 26 #include "components/security_state/core/switches.h" |
| 27 #include "components/strings/grit/components_strings.h" |
| 28 #include "content/public/browser/interstitial_page.h" | 28 #include "content/public/browser/interstitial_page.h" |
| 29 #include "content/public/browser/navigation_controller.h" | 29 #include "content/public/browser/navigation_controller.h" |
| 30 #include "content/public/browser/navigation_entry.h" | 30 #include "content/public/browser/navigation_entry.h" |
| 31 #include "content/public/browser/notification_service.h" | 31 #include "content/public/browser/notification_service.h" |
| 32 #include "content/public/browser/notification_types.h" | 32 #include "content/public/browser/notification_types.h" |
| 33 #include "content/public/browser/security_style_explanation.h" | 33 #include "content/public/browser/security_style_explanation.h" |
| 34 #include "content/public/browser/security_style_explanations.h" | 34 #include "content/public/browser/security_style_explanations.h" |
| 35 #include "content/public/browser/ssl_status.h" | 35 #include "content/public/browser/ssl_status.h" |
| 36 #include "content/public/browser/web_contents.h" | 36 #include "content/public/browser/web_contents.h" |
| 37 #include "content/public/common/referrer.h" | 37 #include "content/public/common/referrer.h" |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 command_line->AppendSwitch(switches::kAllowRunningInsecureContent); | 348 command_line->AppendSwitch(switches::kAllowRunningInsecureContent); |
| 349 } | 349 } |
| 350 | 350 |
| 351 protected: | 351 protected: |
| 352 net::EmbeddedTestServer https_server_; | 352 net::EmbeddedTestServer https_server_; |
| 353 | 353 |
| 354 private: | 354 private: |
| 355 DISALLOW_COPY_AND_ASSIGN(SecurityStyleChangedTest); | 355 DISALLOW_COPY_AND_ASSIGN(SecurityStyleChangedTest); |
| 356 }; | 356 }; |
| 357 | 357 |
| 358 } // namespace |
| 359 |
| 358 IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest, HttpPage) { | 360 IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest, HttpPage) { |
| 359 ASSERT_TRUE(embedded_test_server()->Start()); | 361 ASSERT_TRUE(embedded_test_server()->Start()); |
| 360 ui_test_utils::NavigateToURL( | 362 ui_test_utils::NavigateToURL( |
| 361 browser(), embedded_test_server()->GetURL("/ssl/google.html")); | 363 browser(), embedded_test_server()->GetURL("/ssl/google.html")); |
| 362 content::WebContents* contents = | 364 content::WebContents* contents = |
| 363 browser()->tab_strip_model()->GetActiveWebContents(); | 365 browser()->tab_strip_model()->GetActiveWebContents(); |
| 364 ASSERT_TRUE(contents); | 366 ASSERT_TRUE(contents); |
| 365 | 367 |
| 366 ChromeSecurityStateModelClient* model_client = | 368 ChromeSecurityStateModelClient* model_client = |
| 367 ChromeSecurityStateModelClient::FromWebContents(contents); | 369 ChromeSecurityStateModelClient::FromWebContents(contents); |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 726 embedded_test_server()->host_port_pair(), &replacement_path); | 728 embedded_test_server()->host_port_pair(), &replacement_path); |
| 727 ui_test_utils::NavigateToURL(browser(), | 729 ui_test_utils::NavigateToURL(browser(), |
| 728 https_server_.GetURL(replacement_path)); | 730 https_server_.GetURL(replacement_path)); |
| 729 CheckSecurityInfoForSecure( | 731 CheckSecurityInfoForSecure( |
| 730 browser()->tab_strip_model()->GetActiveWebContents(), | 732 browser()->tab_strip_model()->GetActiveWebContents(), |
| 731 SecurityStateModel::DANGEROUS, SecurityStateModel::NO_DEPRECATED_SHA1, | 733 SecurityStateModel::DANGEROUS, SecurityStateModel::NO_DEPRECATED_SHA1, |
| 732 SecurityStateModel::CONTENT_STATUS_DISPLAYED, false, | 734 SecurityStateModel::CONTENT_STATUS_DISPLAYED, false, |
| 733 true /* expect cert status error */); | 735 true /* expect cert status error */); |
| 734 } | 736 } |
| 735 | 737 |
| 738 namespace { |
| 739 |
| 736 const char kReportURI[] = "https://report-hpkp.test"; | 740 const char kReportURI[] = "https://report-hpkp.test"; |
| 737 | 741 |
| 738 class PKPModelClientTest : public ChromeSecurityStateModelClientTest { | 742 class PKPModelClientTest : public ChromeSecurityStateModelClientTest { |
| 739 public: | 743 public: |
| 740 void SetUpOnMainThread() override { | 744 void SetUpOnMainThread() override { |
| 741 ASSERT_TRUE(https_server_.Start()); | 745 ASSERT_TRUE(https_server_.Start()); |
| 742 url_request_context_getter_ = browser()->profile()->GetRequestContext(); | 746 url_request_context_getter_ = browser()->profile()->GetRequestContext(); |
| 743 content::BrowserThread::PostTask( | 747 content::BrowserThread::PostTask( |
| 744 content::BrowserThread::IO, FROM_HERE, | 748 content::BrowserThread::IO, FROM_HERE, |
| 745 base::Bind(&PKPModelClientTest::SetUpOnIOThread, | 749 base::Bind(&PKPModelClientTest::SetUpOnIOThread, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 761 hashes.push_back(hash); | 765 hashes.push_back(hash); |
| 762 | 766 |
| 763 security_state->AddHPKP(https_server_.host_port_pair().host(), expiration, | 767 security_state->AddHPKP(https_server_.host_port_pair().host(), expiration, |
| 764 true, hashes, GURL(kReportURI)); | 768 true, hashes, GURL(kReportURI)); |
| 765 } | 769 } |
| 766 | 770 |
| 767 protected: | 771 protected: |
| 768 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; | 772 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; |
| 769 }; | 773 }; |
| 770 | 774 |
| 775 } // namespace |
| 776 |
| 771 IN_PROC_BROWSER_TEST_F(PKPModelClientTest, PKPBypass) { | 777 IN_PROC_BROWSER_TEST_F(PKPModelClientTest, PKPBypass) { |
| 772 content::WebContents* web_contents = | 778 content::WebContents* web_contents = |
| 773 browser()->tab_strip_model()->GetActiveWebContents(); | 779 browser()->tab_strip_model()->GetActiveWebContents(); |
| 774 SecurityStyleTestObserver observer(web_contents); | 780 SecurityStyleTestObserver observer(web_contents); |
| 775 | 781 |
| 776 scoped_refptr<net::X509Certificate> cert(https_server_.GetCertificate()); | 782 scoped_refptr<net::X509Certificate> cert(https_server_.GetCertificate()); |
| 777 net::CertVerifyResult verify_result; | 783 net::CertVerifyResult verify_result; |
| 778 // PKP is bypassed when |is_issued_by_known_root| is false. | 784 // PKP is bypassed when |is_issued_by_known_root| is false. |
| 779 verify_result.is_issued_by_known_root = false; | 785 verify_result.is_issued_by_known_root = false; |
| 780 verify_result.verified_cert = cert; | 786 verify_result.verified_cert = cert; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 813 verify_result.public_key_hashes.push_back(hash); | 819 verify_result.public_key_hashes.push_back(hash); |
| 814 | 820 |
| 815 mock_cert_verifier()->AddResultForCert(cert, verify_result, net::OK); | 821 mock_cert_verifier()->AddResultForCert(cert, verify_result, net::OK); |
| 816 | 822 |
| 817 ui_test_utils::NavigateToURL(browser(), | 823 ui_test_utils::NavigateToURL(browser(), |
| 818 https_server_.GetURL("/ssl/google.html")); | 824 https_server_.GetURL("/ssl/google.html")); |
| 819 CheckBrokenSecurityStyle(observer, net::ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN, | 825 CheckBrokenSecurityStyle(observer, net::ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN, |
| 820 browser(), cert.get()); | 826 browser(), cert.get()); |
| 821 } | 827 } |
| 822 | 828 |
| 829 namespace { |
| 830 |
| 823 // Fails requests with ERR_IO_PENDING. Can be used to simulate a navigation | 831 // Fails requests with ERR_IO_PENDING. Can be used to simulate a navigation |
| 824 // that never stops loading. | 832 // that never stops loading. |
| 825 class PendingJobInterceptor : public net::URLRequestInterceptor { | 833 class PendingJobInterceptor : public net::URLRequestInterceptor { |
| 826 public: | 834 public: |
| 827 PendingJobInterceptor() {} | 835 PendingJobInterceptor() {} |
| 828 ~PendingJobInterceptor() override {} | 836 ~PendingJobInterceptor() override {} |
| 829 | 837 |
| 830 // URLRequestInterceptor implementation | 838 // URLRequestInterceptor implementation |
| 831 net::URLRequestJob* MaybeInterceptRequest( | 839 net::URLRequestJob* MaybeInterceptRequest( |
| 832 net::URLRequest* request, | 840 net::URLRequest* request, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 858 | 866 |
| 859 content::BrowserThread::PostTask( | 867 content::BrowserThread::PostTask( |
| 860 content::BrowserThread::IO, FROM_HERE, | 868 content::BrowserThread::IO, FROM_HERE, |
| 861 base::Bind(&InstallLoadingInterceptor, | 869 base::Bind(&InstallLoadingInterceptor, |
| 862 embedded_test_server()->GetURL("/title1.html").host())); | 870 embedded_test_server()->GetURL("/title1.html").host())); |
| 863 } | 871 } |
| 864 | 872 |
| 865 DISALLOW_COPY_AND_ASSIGN(SecurityStateModelLoadingTest); | 873 DISALLOW_COPY_AND_ASSIGN(SecurityStateModelLoadingTest); |
| 866 }; | 874 }; |
| 867 | 875 |
| 876 } // namespace |
| 877 |
| 868 // Tests that navigation state changes cause the security state to be | 878 // Tests that navigation state changes cause the security state to be |
| 869 // updated. | 879 // updated. |
| 870 IN_PROC_BROWSER_TEST_F(SecurityStateModelLoadingTest, NavigationStateChanges) { | 880 IN_PROC_BROWSER_TEST_F(SecurityStateModelLoadingTest, NavigationStateChanges) { |
| 871 ASSERT_TRUE(https_server_.Start()); | 881 ASSERT_TRUE(https_server_.Start()); |
| 872 SetUpMockCertVerifierForHttpsServer(0, net::OK); | 882 SetUpMockCertVerifierForHttpsServer(0, net::OK); |
| 873 | 883 |
| 874 // Navigate to an HTTPS page. | 884 // Navigate to an HTTPS page. |
| 875 ui_test_utils::NavigateToURL(browser(), | 885 ui_test_utils::NavigateToURL(browser(), |
| 876 https_server_.GetURL("/ssl/google.html")); | 886 https_server_.GetURL("/ssl/google.html")); |
| 877 CheckSecurityInfoForSecure( | 887 CheckSecurityInfoForSecure( |
| (...skipping 30 matching lines...) Expand all Loading... |
| 908 // First, test that if the flags aren't set on the NavigationEntry, | 918 // First, test that if the flags aren't set on the NavigationEntry, |
| 909 // then they also aren't set on the VisibleSecurityState. | 919 // then they also aren't set on the VisibleSecurityState. |
| 910 content::SSLStatus& ssl_status = | 920 content::SSLStatus& ssl_status = |
| 911 contents->GetController().GetVisibleEntry()->GetSSL(); | 921 contents->GetController().GetVisibleEntry()->GetSSL(); |
| 912 ASSERT_FALSE(ssl_status.content_status & | 922 ASSERT_FALSE(ssl_status.content_status & |
| 913 content::SSLStatus::DISPLAYED_PASSWORD_FIELD_ON_HTTP); | 923 content::SSLStatus::DISPLAYED_PASSWORD_FIELD_ON_HTTP); |
| 914 ASSERT_FALSE(ssl_status.content_status & | 924 ASSERT_FALSE(ssl_status.content_status & |
| 915 content::SSLStatus::DISPLAYED_CREDIT_CARD_FIELD_ON_HTTP); | 925 content::SSLStatus::DISPLAYED_CREDIT_CARD_FIELD_ON_HTTP); |
| 916 SecurityStateModel::VisibleSecurityState | 926 SecurityStateModel::VisibleSecurityState |
| 917 visible_security_state_no_sensitive_inputs; | 927 visible_security_state_no_sensitive_inputs; |
| 918 model_client->GetVisibleSecurityState( | 928 model_client->security_state_model_->GetVisibleSecurityState( |
| 919 &visible_security_state_no_sensitive_inputs); | 929 &visible_security_state_no_sensitive_inputs); |
| 920 EXPECT_FALSE(visible_security_state_no_sensitive_inputs | 930 EXPECT_FALSE(visible_security_state_no_sensitive_inputs |
| 921 .displayed_password_field_on_http); | 931 .displayed_password_field_on_http); |
| 922 EXPECT_FALSE(visible_security_state_no_sensitive_inputs | 932 EXPECT_FALSE(visible_security_state_no_sensitive_inputs |
| 923 .displayed_credit_card_field_on_http); | 933 .displayed_credit_card_field_on_http); |
| 924 | 934 |
| 925 // Now, set the flags on the NavigationEntry and test that they are | 935 // Now, set the flags on the NavigationEntry and test that they are |
| 926 // reflected in the VisibleSecurityState. | 936 // reflected in the VisibleSecurityState. |
| 927 ssl_status.content_status |= | 937 ssl_status.content_status |= |
| 928 content::SSLStatus::DISPLAYED_PASSWORD_FIELD_ON_HTTP; | 938 content::SSLStatus::DISPLAYED_PASSWORD_FIELD_ON_HTTP; |
| 929 ssl_status.content_status |= | 939 ssl_status.content_status |= |
| 930 content::SSLStatus::DISPLAYED_CREDIT_CARD_FIELD_ON_HTTP; | 940 content::SSLStatus::DISPLAYED_CREDIT_CARD_FIELD_ON_HTTP; |
| 931 SecurityStateModel::VisibleSecurityState | 941 SecurityStateModel::VisibleSecurityState |
| 932 visible_security_state_sensitive_inputs; | 942 visible_security_state_sensitive_inputs; |
| 933 model_client->GetVisibleSecurityState( | 943 model_client->security_state_model_->GetVisibleSecurityState( |
| 934 &visible_security_state_sensitive_inputs); | 944 &visible_security_state_sensitive_inputs); |
| 935 EXPECT_TRUE( | 945 EXPECT_TRUE( |
| 936 visible_security_state_sensitive_inputs.displayed_password_field_on_http); | 946 visible_security_state_sensitive_inputs.displayed_password_field_on_http); |
| 937 EXPECT_TRUE(visible_security_state_sensitive_inputs | 947 EXPECT_TRUE(visible_security_state_sensitive_inputs |
| 938 .displayed_credit_card_field_on_http); | 948 .displayed_credit_card_field_on_http); |
| 939 } | 949 } |
| 940 | 950 |
| 941 // Tests that when a visible password field is detected on an HTTP page | 951 // Tests that when a visible password field is detected on an HTTP page |
| 942 // load, and when the command-line flag is set, the security level is | 952 // load, and when the command-line flag is set, the security level is |
| 943 // downgraded to HTTP_SHOW_WARNING. | 953 // downgraded to HTTP_SHOW_WARNING. |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1112 security_info.security_level); | 1122 security_info.security_level); |
| 1113 | 1123 |
| 1114 // The SSLStatus flags should only be set if the top-level page load was HTTP, | 1124 // The SSLStatus flags should only be set if the top-level page load was HTTP, |
| 1115 // which it was not in this case. | 1125 // which it was not in this case. |
| 1116 content::NavigationEntry* entry = contents->GetController().GetVisibleEntry(); | 1126 content::NavigationEntry* entry = contents->GetController().GetVisibleEntry(); |
| 1117 ASSERT_TRUE(entry); | 1127 ASSERT_TRUE(entry); |
| 1118 EXPECT_FALSE(entry->GetSSL().content_status & | 1128 EXPECT_FALSE(entry->GetSSL().content_status & |
| 1119 content::SSLStatus::DISPLAYED_PASSWORD_FIELD_ON_HTTP); | 1129 content::SSLStatus::DISPLAYED_PASSWORD_FIELD_ON_HTTP); |
| 1120 } | 1130 } |
| 1121 | 1131 |
| 1132 namespace { |
| 1133 |
| 1122 // A Browser subclass that keeps track of messages that have been | 1134 // A Browser subclass that keeps track of messages that have been |
| 1123 // added to the console. Messages can be retrieved or cleared with | 1135 // added to the console. Messages can be retrieved or cleared with |
| 1124 // console_messages() and ClearConsoleMessages(). The user of this class | 1136 // console_messages() and ClearConsoleMessages(). The user of this class |
| 1125 // can set a callback to run when the next console message notification | 1137 // can set a callback to run when the next console message notification |
| 1126 // arrives. | 1138 // arrives. |
| 1127 class ConsoleWebContentsDelegate : public Browser { | 1139 class ConsoleWebContentsDelegate : public Browser { |
| 1128 public: | 1140 public: |
| 1129 explicit ConsoleWebContentsDelegate(const Browser::CreateParams& params) | 1141 explicit ConsoleWebContentsDelegate(const Browser::CreateParams& params) |
| 1130 : Browser(params) {} | 1142 : Browser(params) {} |
| 1131 ~ConsoleWebContentsDelegate() override {} | 1143 ~ConsoleWebContentsDelegate() override {} |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1177 // this just looks for keywords in the string rather than the exact | 1189 // this just looks for keywords in the string rather than the exact |
| 1178 // text. | 1190 // text. |
| 1179 void CheckForOneFutureHttpWarningConsoleMessage( | 1191 void CheckForOneFutureHttpWarningConsoleMessage( |
| 1180 ConsoleWebContentsDelegate* delegate) { | 1192 ConsoleWebContentsDelegate* delegate) { |
| 1181 const std::vector<base::string16>& messages = delegate->console_messages(); | 1193 const std::vector<base::string16>& messages = delegate->console_messages(); |
| 1182 ASSERT_EQ(1u, messages.size()); | 1194 ASSERT_EQ(1u, messages.size()); |
| 1183 EXPECT_NE(base::string16::npos, | 1195 EXPECT_NE(base::string16::npos, |
| 1184 messages[0].find(base::ASCIIToUTF16("warning will be added"))); | 1196 messages[0].find(base::ASCIIToUTF16("warning will be added"))); |
| 1185 } | 1197 } |
| 1186 | 1198 |
| 1199 } // namespace |
| 1200 |
| 1187 // Tests that console messages are printed upon a call to | 1201 // Tests that console messages are printed upon a call to |
| 1188 // GetSecurityInfo() on an HTTP_SHOW_WARNING page, exactly once per | 1202 // GetSecurityInfo() on an HTTP_SHOW_WARNING page, exactly once per |
| 1189 // main-frame navigation. | 1203 // main-frame navigation. |
| 1190 IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTestWithPasswordCcSwitch, | 1204 IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTestWithPasswordCcSwitch, |
| 1191 ConsoleMessage) { | 1205 ConsoleMessage) { |
| 1192 ConsoleWebContentsDelegate* delegate = new ConsoleWebContentsDelegate( | 1206 ConsoleWebContentsDelegate* delegate = new ConsoleWebContentsDelegate( |
| 1193 Browser::CreateParams(browser()->profile())); | 1207 Browser::CreateParams(browser()->profile())); |
| 1194 content::WebContents* original_contents = | 1208 content::WebContents* original_contents = |
| 1195 browser()->tab_strip_model()->GetActiveWebContents(); | 1209 browser()->tab_strip_model()->GetActiveWebContents(); |
| 1196 content::WebContents* contents = | 1210 content::WebContents* contents = |
| (...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1743 CheckSecureExplanations(observer.latest_explanations().secure_explanations, | 1757 CheckSecureExplanations(observer.latest_explanations().secure_explanations, |
| 1744 VALID_CERTIFICATE, browser(), | 1758 VALID_CERTIFICATE, browser(), |
| 1745 https_server_.GetCertificate().get()); | 1759 https_server_.GetCertificate().get()); |
| 1746 EXPECT_TRUE(observer.latest_explanations().scheme_is_cryptographic); | 1760 EXPECT_TRUE(observer.latest_explanations().scheme_is_cryptographic); |
| 1747 EXPECT_FALSE(observer.latest_explanations().pkp_bypassed); | 1761 EXPECT_FALSE(observer.latest_explanations().pkp_bypassed); |
| 1748 EXPECT_TRUE(observer.latest_explanations().info_explanations.empty()); | 1762 EXPECT_TRUE(observer.latest_explanations().info_explanations.empty()); |
| 1749 EXPECT_FALSE(observer.latest_explanations().displayed_mixed_content); | 1763 EXPECT_FALSE(observer.latest_explanations().displayed_mixed_content); |
| 1750 EXPECT_FALSE(observer.latest_explanations().ran_mixed_content); | 1764 EXPECT_FALSE(observer.latest_explanations().ran_mixed_content); |
| 1751 } | 1765 } |
| 1752 | 1766 |
| 1767 namespace { |
| 1768 |
| 1753 // After AddNonsecureUrlHandler() is called, requests to this hostname | 1769 // After AddNonsecureUrlHandler() is called, requests to this hostname |
| 1754 // will use obsolete TLS settings. | 1770 // will use obsolete TLS settings. |
| 1755 const char kMockNonsecureHostname[] = "example-nonsecure.test"; | 1771 const char kMockNonsecureHostname[] = "example-nonsecure.test"; |
| 1756 const int kObsoleteTLSVersion = net::SSL_CONNECTION_VERSION_TLS1_1; | 1772 const int kObsoleteTLSVersion = net::SSL_CONNECTION_VERSION_TLS1_1; |
| 1757 // ECDHE_RSA + AES_128_CBC with HMAC-SHA1 | 1773 // ECDHE_RSA + AES_128_CBC with HMAC-SHA1 |
| 1758 const uint16_t kObsoleteCipherSuite = 0xc013; | 1774 const uint16_t kObsoleteCipherSuite = 0xc013; |
| 1759 | 1775 |
| 1760 // A URLRequestMockHTTPJob that mocks a TLS connection with the obsolete | 1776 // A URLRequestMockHTTPJob that mocks a TLS connection with the obsolete |
| 1761 // TLS settings specified in kObsoleteTLSVersion and | 1777 // TLS settings specified in kObsoleteTLSVersion and |
| 1762 // kObsoleteCipherSuite. | 1778 // kObsoleteCipherSuite. |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1857 &AddNonsecureUrlHandler, serve_file, cert_, | 1873 &AddNonsecureUrlHandler, serve_file, cert_, |
| 1858 make_scoped_refptr(content::BrowserThread::GetBlockingPool()))); | 1874 make_scoped_refptr(content::BrowserThread::GetBlockingPool()))); |
| 1859 } | 1875 } |
| 1860 | 1876 |
| 1861 private: | 1877 private: |
| 1862 scoped_refptr<net::X509Certificate> cert_; | 1878 scoped_refptr<net::X509Certificate> cert_; |
| 1863 | 1879 |
| 1864 DISALLOW_COPY_AND_ASSIGN(BrowserTestNonsecureURLRequest); | 1880 DISALLOW_COPY_AND_ASSIGN(BrowserTestNonsecureURLRequest); |
| 1865 }; | 1881 }; |
| 1866 | 1882 |
| 1883 } // namespace |
| 1884 |
| 1867 // Tests that a connection with obsolete TLS settings does not get a | 1885 // Tests that a connection with obsolete TLS settings does not get a |
| 1868 // secure connection explanation. | 1886 // secure connection explanation. |
| 1869 IN_PROC_BROWSER_TEST_F(BrowserTestNonsecureURLRequest, | 1887 IN_PROC_BROWSER_TEST_F(BrowserTestNonsecureURLRequest, |
| 1870 SecurityStyleChangedObserverNonsecureConnection) { | 1888 SecurityStyleChangedObserverNonsecureConnection) { |
| 1871 content::WebContents* web_contents = | 1889 content::WebContents* web_contents = |
| 1872 browser()->tab_strip_model()->GetActiveWebContents(); | 1890 browser()->tab_strip_model()->GetActiveWebContents(); |
| 1873 SecurityStyleTestObserver observer(web_contents); | 1891 SecurityStyleTestObserver observer(web_contents); |
| 1874 | 1892 |
| 1875 ui_test_utils::NavigateToURL( | 1893 ui_test_utils::NavigateToURL( |
| 1876 browser(), GURL(std::string("https://") + kMockNonsecureHostname)); | 1894 browser(), GURL(std::string("https://") + kMockNonsecureHostname)); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1904 base::ASCIIToUTF16("AES_128_CBC with HMAC-SHA1")); | 1922 base::ASCIIToUTF16("AES_128_CBC with HMAC-SHA1")); |
| 1905 base::string16 obsolete_description = l10n_util::GetStringFUTF16( | 1923 base::string16 obsolete_description = l10n_util::GetStringFUTF16( |
| 1906 IDS_OBSOLETE_SSL_DESCRIPTION, description_replacements, nullptr); | 1924 IDS_OBSOLETE_SSL_DESCRIPTION, description_replacements, nullptr); |
| 1907 | 1925 |
| 1908 EXPECT_EQ( | 1926 EXPECT_EQ( |
| 1909 obsolete_description, | 1927 obsolete_description, |
| 1910 base::ASCIIToUTF16( | 1928 base::ASCIIToUTF16( |
| 1911 observer.latest_explanations().info_explanations[0].description)); | 1929 observer.latest_explanations().info_explanations[0].description)); |
| 1912 } | 1930 } |
| 1913 | 1931 |
| 1932 namespace { |
| 1933 |
| 1914 // After AddSCTUrlHandler() is called, requests to this hostname | 1934 // After AddSCTUrlHandler() is called, requests to this hostname |
| 1915 // will be served with Signed Certificate Timestamps. | 1935 // will be served with Signed Certificate Timestamps. |
| 1916 const char kMockHostnameWithSCTs[] = "example-scts.test"; | 1936 const char kMockHostnameWithSCTs[] = "example-scts.test"; |
| 1917 | 1937 |
| 1918 // URLRequestJobWithSCTs mocks a connection that includes a set of dummy | 1938 // URLRequestJobWithSCTs mocks a connection that includes a set of dummy |
| 1919 // SCTs with these statuses. | 1939 // SCTs with these statuses. |
| 1920 const std::vector<net::ct::SCTVerifyStatus> kTestSCTStatuses{ | 1940 const std::vector<net::ct::SCTVerifyStatus> kTestSCTStatuses{ |
| 1921 net::ct::SCT_STATUS_OK, net::ct::SCT_STATUS_LOG_UNKNOWN, | 1941 net::ct::SCT_STATUS_OK, net::ct::SCT_STATUS_LOG_UNKNOWN, |
| 1922 net::ct::SCT_STATUS_OK}; | 1942 net::ct::SCT_STATUS_OK}; |
| 1923 | 1943 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2021 &AddSCTUrlHandler, serve_file, cert_, | 2041 &AddSCTUrlHandler, serve_file, cert_, |
| 2022 make_scoped_refptr(content::BrowserThread::GetBlockingPool()))); | 2042 make_scoped_refptr(content::BrowserThread::GetBlockingPool()))); |
| 2023 } | 2043 } |
| 2024 | 2044 |
| 2025 private: | 2045 private: |
| 2026 scoped_refptr<net::X509Certificate> cert_; | 2046 scoped_refptr<net::X509Certificate> cert_; |
| 2027 | 2047 |
| 2028 DISALLOW_COPY_AND_ASSIGN(BrowserTestURLRequestWithSCTs); | 2048 DISALLOW_COPY_AND_ASSIGN(BrowserTestURLRequestWithSCTs); |
| 2029 }; | 2049 }; |
| 2030 | 2050 |
| 2051 } // namespace |
| 2052 |
| 2031 // Tests that, when Signed Certificate Timestamps (SCTs) are served on a | 2053 // Tests that, when Signed Certificate Timestamps (SCTs) are served on a |
| 2032 // connection, the SCTs verification statuses are exposed on the | 2054 // connection, the SCTs verification statuses are exposed on the |
| 2033 // SecurityInfo. | 2055 // SecurityInfo. |
| 2034 IN_PROC_BROWSER_TEST_F(BrowserTestURLRequestWithSCTs, | 2056 IN_PROC_BROWSER_TEST_F(BrowserTestURLRequestWithSCTs, |
| 2035 SecurityInfoWithSCTsAttached) { | 2057 SecurityInfoWithSCTsAttached) { |
| 2036 ui_test_utils::NavigateToURL( | 2058 ui_test_utils::NavigateToURL( |
| 2037 browser(), GURL(std::string("https://") + kMockHostnameWithSCTs)); | 2059 browser(), GURL(std::string("https://") + kMockHostnameWithSCTs)); |
| 2038 | 2060 |
| 2039 content::WebContents* web_contents = | 2061 content::WebContents* web_contents = |
| 2040 browser()->tab_strip_model()->GetActiveWebContents(); | 2062 browser()->tab_strip_model()->GetActiveWebContents(); |
| 2041 ASSERT_TRUE(web_contents); | 2063 ASSERT_TRUE(web_contents); |
| 2042 ChromeSecurityStateModelClient* model_client = | 2064 ChromeSecurityStateModelClient* model_client = |
| 2043 ChromeSecurityStateModelClient::FromWebContents(web_contents); | 2065 ChromeSecurityStateModelClient::FromWebContents(web_contents); |
| 2044 ASSERT_TRUE(model_client); | 2066 ASSERT_TRUE(model_client); |
| 2045 SecurityStateModel::SecurityInfo security_info; | 2067 SecurityStateModel::SecurityInfo security_info; |
| 2046 model_client->GetSecurityInfo(&security_info); | 2068 model_client->GetSecurityInfo(&security_info); |
| 2047 EXPECT_EQ(SecurityStateModel::SECURE, security_info.security_level); | 2069 EXPECT_EQ(SecurityStateModel::SECURE, security_info.security_level); |
| 2048 EXPECT_EQ(kTestSCTStatuses, security_info.sct_verify_statuses); | 2070 EXPECT_EQ(kTestSCTStatuses, security_info.sct_verify_statuses); |
| 2049 } | 2071 } |
| 2050 | |
| 2051 } // namespace | |
| OLD | NEW |