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

Unified Diff: chrome/browser/ssl/chrome_security_state_model_client_browser_tests.cc

Issue 2224023003: Teach SecurityStateModel about subresources with cert errors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase fixup Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ssl/chrome_security_state_model_client_browser_tests.cc
diff --git a/chrome/browser/ssl/chrome_security_state_model_client_browser_tests.cc b/chrome/browser/ssl/chrome_security_state_model_client_browser_tests.cc
index af3fbb2454c3e5763665cf30311cba36bbf9dcb3..3cd98ca1e11174431995382b62bedf4d8191f491 100644
--- a/chrome/browser/ssl/chrome_security_state_model_client_browser_tests.cc
+++ b/chrome/browser/ssl/chrome_security_state_model_client_browser_tests.cc
@@ -438,6 +438,95 @@ IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest, MixedContent) {
false /* expect cert status error */);
}
+IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest,
+ ActiveContentWithCertErrors) {
+ ASSERT_TRUE(https_server_.Start());
+ SetUpMockCertVerifierForHttpsServer(0, net::OK);
+
+ // Navigate to an HTTPS page and simulate active content with
+ // certificate errors.
+ ui_test_utils::NavigateToURL(browser(), https_server_.GetURL("/title1.html"));
+ content::WebContents* web_contents =
+ browser()->tab_strip_model()->GetActiveWebContents();
+ ASSERT_TRUE(web_contents);
+ content::NavigationEntry* entry =
+ web_contents->GetController().GetVisibleEntry();
+ ASSERT_TRUE(entry);
+ entry->GetSSL().content_status |=
+ content::SSLStatus::RAN_CONTENT_WITH_CERT_ERRORS;
+
+ ChromeSecurityStateModelClient* model_client =
+ ChromeSecurityStateModelClient::FromWebContents(web_contents);
+ ASSERT_TRUE(model_client);
+ const SecurityStateModel::SecurityInfo& security_info =
+ model_client->GetSecurityInfo();
+
+ EXPECT_FALSE(net::IsCertStatusError(security_info.cert_status));
+ EXPECT_EQ(SecurityStateModel::SECURITY_ERROR, security_info.security_level);
+ EXPECT_EQ(SecurityStateModel::CONTENT_STATUS_RAN,
+ security_info.content_with_cert_errors_status);
+}
+
+IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest,
+ PassiveContentWithCertErrors) {
+ ASSERT_TRUE(https_server_.Start());
+ SetUpMockCertVerifierForHttpsServer(0, net::OK);
+
+ // Navigate to an HTTPS page and simulate passive content with
+ // certificate errors.
+ ui_test_utils::NavigateToURL(browser(), https_server_.GetURL("/title1.html"));
+ content::WebContents* web_contents =
+ browser()->tab_strip_model()->GetActiveWebContents();
+ ASSERT_TRUE(web_contents);
+ content::NavigationEntry* entry =
+ web_contents->GetController().GetVisibleEntry();
+ ASSERT_TRUE(entry);
+ entry->GetSSL().content_status |=
+ content::SSLStatus::DISPLAYED_CONTENT_WITH_CERT_ERRORS;
+
+ ChromeSecurityStateModelClient* model_client =
+ ChromeSecurityStateModelClient::FromWebContents(web_contents);
+ ASSERT_TRUE(model_client);
+ const SecurityStateModel::SecurityInfo& security_info =
+ model_client->GetSecurityInfo();
+
+ EXPECT_FALSE(net::IsCertStatusError(security_info.cert_status));
+ EXPECT_EQ(SecurityStateModel::NONE, security_info.security_level);
+ EXPECT_EQ(SecurityStateModel::CONTENT_STATUS_DISPLAYED,
+ security_info.content_with_cert_errors_status);
+}
+
+IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest,
+ ActiveAndPassiveContentWithCertErrors) {
+ ASSERT_TRUE(https_server_.Start());
+ SetUpMockCertVerifierForHttpsServer(0, net::OK);
+
+ // Navigate to an HTTPS page and simulate active and passive content
+ // with certificate errors.
+ ui_test_utils::NavigateToURL(browser(), https_server_.GetURL("/title1.html"));
+ content::WebContents* web_contents =
+ browser()->tab_strip_model()->GetActiveWebContents();
+ ASSERT_TRUE(web_contents);
+ content::NavigationEntry* entry =
+ web_contents->GetController().GetVisibleEntry();
+ ASSERT_TRUE(entry);
+ entry->GetSSL().content_status |=
+ content::SSLStatus::RAN_CONTENT_WITH_CERT_ERRORS;
+ entry->GetSSL().content_status |=
+ content::SSLStatus::DISPLAYED_CONTENT_WITH_CERT_ERRORS;
+
+ ChromeSecurityStateModelClient* model_client =
+ ChromeSecurityStateModelClient::FromWebContents(web_contents);
+ ASSERT_TRUE(model_client);
+ const SecurityStateModel::SecurityInfo& security_info =
+ model_client->GetSecurityInfo();
+
+ EXPECT_FALSE(net::IsCertStatusError(security_info.cert_status));
+ EXPECT_EQ(SecurityStateModel::SECURITY_ERROR, security_info.security_level);
+ EXPECT_EQ(SecurityStateModel::CONTENT_STATUS_DISPLAYED_AND_RAN,
+ security_info.content_with_cert_errors_status);
+}
+
// Same as the test above but with a long-lived SHA1 cert.
IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest,
MixedContentWithBrokenSHA1) {
« no previous file with comments | « chrome/browser/ssl/chrome_security_state_model_client.cc ('k') | components/security_state/security_state_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698