| Index: chrome/browser/ssl/chrome_security_state_model_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_browser_tests.cc
|
| similarity index 92%
|
| rename from chrome/browser/ssl/chrome_security_state_model_client_browser_tests.cc
|
| rename to chrome/browser/ssl/chrome_security_state_model_browser_tests.cc
|
| index 19032113412e117a9f2506360a6fcd63ce93c759..dda1024591a4f84a13948eb914886c47ffc55967 100644
|
| --- a/chrome/browser/ssl/chrome_security_state_model_client_browser_tests.cc
|
| +++ b/chrome/browser/ssl/chrome_security_state_model_browser_tests.cc
|
| @@ -2,7 +2,7 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "chrome/browser/ssl/chrome_security_state_model_client.h"
|
| +#include "chrome/browser/ssl/chrome_security_state_model.h"
|
|
|
| #include <openssl/ssl.h>
|
|
|
| @@ -12,7 +12,7 @@
|
| #include "base/strings/string_split.h"
|
| #include "base/strings/utf_string_conversions.h"
|
| #include "chrome/browser/ssl/cert_verifier_browser_test.h"
|
| -#include "chrome/browser/ssl/chrome_security_state_model_client.h"
|
| +#include "chrome/browser/ssl/chrome_security_state_model.h"
|
| #include "chrome/browser/ssl/ssl_blocking_page.h"
|
| #include "chrome/browser/ui/browser.h"
|
| #include "chrome/browser/ui/browser_commands.h"
|
| @@ -20,11 +20,11 @@
|
| #include "chrome/common/chrome_paths.h"
|
| #include "chrome/common/chrome_switches.h"
|
| #include "chrome/common/pref_names.h"
|
| -#include "chrome/grit/generated_resources.h"
|
| #include "chrome/test/base/in_process_browser_test.h"
|
| #include "chrome/test/base/ui_test_utils.h"
|
| #include "components/prefs/pref_service.h"
|
| -#include "components/security_state/switches.h"
|
| +#include "components/security_state/core/switches.h"
|
| +#include "components/strings/grit/components_strings.h"
|
| #include "content/public/browser/interstitial_page.h"
|
| #include "content/public/browser/navigation_controller.h"
|
| #include "content/public/browser/navigation_entry.h"
|
| @@ -170,7 +170,7 @@ void CheckSecureExplanations(
|
| content::WebContents* web_contents =
|
| browser->tab_strip_model()->GetActiveWebContents();
|
| SecurityStateModel::SecurityInfo security_info;
|
| - ChromeSecurityStateModelClient::FromWebContents(web_contents)
|
| + ChromeSecurityStateModel::FromWebContents(web_contents)
|
| ->GetSecurityInfo(&security_info);
|
|
|
| const char *protocol, *key_exchange, *cipher, *mac;
|
| @@ -214,11 +214,11 @@ void CheckSecurityInfoForSecure(
|
| bool expect_cert_error) {
|
| ASSERT_TRUE(contents);
|
|
|
| - ChromeSecurityStateModelClient* model_client =
|
| - ChromeSecurityStateModelClient::FromWebContents(contents);
|
| - ASSERT_TRUE(model_client);
|
| + ChromeSecurityStateModel* model =
|
| + ChromeSecurityStateModel::FromWebContents(contents);
|
| + ASSERT_TRUE(model);
|
| SecurityStateModel::SecurityInfo security_info;
|
| - model_client->GetSecurityInfo(&security_info);
|
| + model->GetSecurityInfo(&security_info);
|
| EXPECT_EQ(expect_security_level, security_info.security_level);
|
| EXPECT_EQ(expect_sha1_status, security_info.sha1_deprecation_status);
|
| EXPECT_EQ(expect_mixed_content_status, security_info.mixed_content_status);
|
| @@ -234,11 +234,11 @@ void CheckSecurityInfoForSecure(
|
| void CheckSecurityInfoForNonSecure(content::WebContents* contents) {
|
| ASSERT_TRUE(contents);
|
|
|
| - ChromeSecurityStateModelClient* model_client =
|
| - ChromeSecurityStateModelClient::FromWebContents(contents);
|
| - ASSERT_TRUE(model_client);
|
| + ChromeSecurityStateModel* model =
|
| + ChromeSecurityStateModel::FromWebContents(contents);
|
| + ASSERT_TRUE(model);
|
| SecurityStateModel::SecurityInfo security_info;
|
| - model_client->GetSecurityInfo(&security_info);
|
| + model->GetSecurityInfo(&security_info);
|
| EXPECT_EQ(SecurityStateModel::NONE, security_info.security_level);
|
| EXPECT_EQ(SecurityStateModel::NO_DEPRECATED_SHA1,
|
| security_info.sha1_deprecation_status);
|
| @@ -274,9 +274,9 @@ void GetFilePathWithHostAndPortReplacement(
|
| original_file_path, replacement_text, replacement_path);
|
| }
|
|
|
| -class ChromeSecurityStateModelClientTest : public CertVerifierBrowserTest {
|
| +class ChromeSecurityStateModelTest : public CertVerifierBrowserTest {
|
| public:
|
| - ChromeSecurityStateModelClientTest()
|
| + ChromeSecurityStateModelTest()
|
| : https_server_(net::EmbeddedTestServer::TYPE_HTTPS) {
|
| https_server_.ServeFilesFromSourceDirectory(base::FilePath(kDocRoot));
|
| }
|
| @@ -301,7 +301,7 @@ class ChromeSecurityStateModelClientTest : public CertVerifierBrowserTest {
|
| net::EmbeddedTestServer https_server_;
|
|
|
| private:
|
| - DISALLOW_COPY_AND_ASSIGN(ChromeSecurityStateModelClientTest);
|
| + DISALLOW_COPY_AND_ASSIGN(ChromeSecurityStateModelTest);
|
| };
|
|
|
| GURL GetURLWithNonLocalHostname(net::EmbeddedTestServer* server,
|
| @@ -311,11 +311,11 @@ GURL GetURLWithNonLocalHostname(net::EmbeddedTestServer* server,
|
| return server->GetURL(path).ReplaceComponents(replace_host);
|
| }
|
|
|
| -class ChromeSecurityStateModelClientTestWithPasswordCcSwitch
|
| - : public ChromeSecurityStateModelClientTest {
|
| +class ChromeSecurityStateModelTestWithPasswordCcSwitch
|
| + : public ChromeSecurityStateModelTest {
|
| public:
|
| - ChromeSecurityStateModelClientTestWithPasswordCcSwitch()
|
| - : ChromeSecurityStateModelClientTest() {}
|
| + ChromeSecurityStateModelTestWithPasswordCcSwitch()
|
| + : ChromeSecurityStateModelTest() {}
|
|
|
| void SetUpOnMainThread() override {
|
| ASSERT_TRUE(embedded_test_server()->Start());
|
| @@ -325,7 +325,7 @@ class ChromeSecurityStateModelClientTestWithPasswordCcSwitch
|
| }
|
|
|
| void SetUpCommandLine(base::CommandLine* command_line) override {
|
| - ChromeSecurityStateModelClientTest::SetUpCommandLine(command_line);
|
| + ChromeSecurityStateModelTest::SetUpCommandLine(command_line);
|
| command_line->AppendSwitchASCII(
|
| security_state::switches::kMarkHttpAs,
|
| security_state::switches::kMarkHttpWithPasswordsOrCcWithChip);
|
| @@ -333,7 +333,7 @@ class ChromeSecurityStateModelClientTestWithPasswordCcSwitch
|
|
|
| private:
|
| DISALLOW_COPY_AND_ASSIGN(
|
| - ChromeSecurityStateModelClientTestWithPasswordCcSwitch);
|
| + ChromeSecurityStateModelTestWithPasswordCcSwitch);
|
| };
|
|
|
| class SecurityStyleChangedTest : public InProcessBrowserTest {
|
| @@ -355,7 +355,9 @@ class SecurityStyleChangedTest : public InProcessBrowserTest {
|
| DISALLOW_COPY_AND_ASSIGN(SecurityStyleChangedTest);
|
| };
|
|
|
| -IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest, HttpPage) {
|
| +} // namespace
|
| +
|
| +IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelTest, HttpPage) {
|
| ASSERT_TRUE(embedded_test_server()->Start());
|
| ui_test_utils::NavigateToURL(
|
| browser(), embedded_test_server()->GetURL("/ssl/google.html"));
|
| @@ -363,11 +365,11 @@ IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest, HttpPage) {
|
| browser()->tab_strip_model()->GetActiveWebContents();
|
| ASSERT_TRUE(contents);
|
|
|
| - ChromeSecurityStateModelClient* model_client =
|
| - ChromeSecurityStateModelClient::FromWebContents(contents);
|
| - ASSERT_TRUE(model_client);
|
| + ChromeSecurityStateModel* model =
|
| + ChromeSecurityStateModel::FromWebContents(contents);
|
| + ASSERT_TRUE(model);
|
| SecurityStateModel::SecurityInfo security_info;
|
| - model_client->GetSecurityInfo(&security_info);
|
| + model->GetSecurityInfo(&security_info);
|
| EXPECT_EQ(SecurityStateModel::NONE, security_info.security_level);
|
| EXPECT_EQ(SecurityStateModel::NO_DEPRECATED_SHA1,
|
| security_info.sha1_deprecation_status);
|
| @@ -381,7 +383,7 @@ IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest, HttpPage) {
|
| EXPECT_EQ(0, security_info.connection_status);
|
| }
|
|
|
| -IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest, HttpsPage) {
|
| +IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelTest, HttpsPage) {
|
| ASSERT_TRUE(https_server_.Start());
|
| SetUpMockCertVerifierForHttpsServer(0, net::OK);
|
|
|
| @@ -394,7 +396,7 @@ IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest, HttpsPage) {
|
| false /* expect cert status error */);
|
| }
|
|
|
| -IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest, SHA1Broken) {
|
| +IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelTest, SHA1Broken) {
|
| ASSERT_TRUE(https_server_.Start());
|
| // The test server uses a long-lived cert by default, so a SHA1
|
| // signature in it will register as a "broken" condition rather than
|
| @@ -411,7 +413,7 @@ IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest, SHA1Broken) {
|
| false /* expect cert status error */);
|
| }
|
|
|
| -IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest, MixedContent) {
|
| +IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelTest, MixedContent) {
|
| ASSERT_TRUE(embedded_test_server()->Start());
|
| ASSERT_TRUE(https_server_.Start());
|
| SetUpMockCertVerifierForHttpsServer(0, net::OK);
|
| @@ -502,7 +504,7 @@ IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest, MixedContent) {
|
| false /* expect cert status error */);
|
| }
|
|
|
| -IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest,
|
| +IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelTest,
|
| ActiveContentWithCertErrors) {
|
| ASSERT_TRUE(https_server_.Start());
|
| SetUpMockCertVerifierForHttpsServer(0, net::OK);
|
| @@ -519,11 +521,11 @@ IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest,
|
| entry->GetSSL().content_status |=
|
| content::SSLStatus::RAN_CONTENT_WITH_CERT_ERRORS;
|
|
|
| - ChromeSecurityStateModelClient* model_client =
|
| - ChromeSecurityStateModelClient::FromWebContents(web_contents);
|
| - ASSERT_TRUE(model_client);
|
| + ChromeSecurityStateModel* model =
|
| + ChromeSecurityStateModel::FromWebContents(web_contents);
|
| + ASSERT_TRUE(model);
|
| SecurityStateModel::SecurityInfo security_info;
|
| - model_client->GetSecurityInfo(&security_info);
|
| + model->GetSecurityInfo(&security_info);
|
|
|
| EXPECT_FALSE(net::IsCertStatusError(security_info.cert_status));
|
| EXPECT_EQ(SecurityStateModel::DANGEROUS, security_info.security_level);
|
| @@ -531,7 +533,7 @@ IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest,
|
| security_info.content_with_cert_errors_status);
|
| }
|
|
|
| -IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest,
|
| +IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelTest,
|
| PassiveContentWithCertErrors) {
|
| ASSERT_TRUE(https_server_.Start());
|
| SetUpMockCertVerifierForHttpsServer(0, net::OK);
|
| @@ -548,11 +550,11 @@ IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest,
|
| entry->GetSSL().content_status |=
|
| content::SSLStatus::DISPLAYED_CONTENT_WITH_CERT_ERRORS;
|
|
|
| - ChromeSecurityStateModelClient* model_client =
|
| - ChromeSecurityStateModelClient::FromWebContents(web_contents);
|
| - ASSERT_TRUE(model_client);
|
| + ChromeSecurityStateModel* model =
|
| + ChromeSecurityStateModel::FromWebContents(web_contents);
|
| + ASSERT_TRUE(model);
|
| SecurityStateModel::SecurityInfo security_info;
|
| - model_client->GetSecurityInfo(&security_info);
|
| + model->GetSecurityInfo(&security_info);
|
|
|
| EXPECT_FALSE(net::IsCertStatusError(security_info.cert_status));
|
| EXPECT_EQ(SecurityStateModel::NONE, security_info.security_level);
|
| @@ -560,7 +562,7 @@ IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest,
|
| security_info.content_with_cert_errors_status);
|
| }
|
|
|
| -IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest,
|
| +IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelTest,
|
| ActiveAndPassiveContentWithCertErrors) {
|
| ASSERT_TRUE(https_server_.Start());
|
| SetUpMockCertVerifierForHttpsServer(0, net::OK);
|
| @@ -579,11 +581,11 @@ IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest,
|
| entry->GetSSL().content_status |=
|
| content::SSLStatus::DISPLAYED_CONTENT_WITH_CERT_ERRORS;
|
|
|
| - ChromeSecurityStateModelClient* model_client =
|
| - ChromeSecurityStateModelClient::FromWebContents(web_contents);
|
| - ASSERT_TRUE(model_client);
|
| + ChromeSecurityStateModel* model =
|
| + ChromeSecurityStateModel::FromWebContents(web_contents);
|
| + ASSERT_TRUE(model);
|
| SecurityStateModel::SecurityInfo security_info;
|
| - model_client->GetSecurityInfo(&security_info);
|
| + model->GetSecurityInfo(&security_info);
|
|
|
| EXPECT_FALSE(net::IsCertStatusError(security_info.cert_status));
|
| EXPECT_EQ(SecurityStateModel::DANGEROUS, security_info.security_level);
|
| @@ -592,7 +594,7 @@ IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest,
|
| }
|
|
|
| // Same as the test above but with a long-lived SHA1 cert.
|
| -IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest,
|
| +IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelTest,
|
| MixedContentWithBrokenSHA1) {
|
| ASSERT_TRUE(embedded_test_server()->Start());
|
| ASSERT_TRUE(https_server_.Start());
|
| @@ -671,7 +673,7 @@ IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest,
|
|
|
| // Tests that the Content Security Policy block-all-mixed-content
|
| // directive stops mixed content from running.
|
| -IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest,
|
| +IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelTest,
|
| MixedContentStrictBlocking) {
|
| ASSERT_TRUE(https_server_.Start());
|
| SetUpMockCertVerifierForHttpsServer(0, net::OK);
|
| @@ -696,7 +698,7 @@ IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest,
|
| false /* expect cert status error */);
|
| }
|
|
|
| -IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest, BrokenHTTPS) {
|
| +IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelTest, BrokenHTTPS) {
|
| ASSERT_TRUE(embedded_test_server()->Start());
|
| ASSERT_TRUE(https_server_.Start());
|
| SetUpMockCertVerifierForHttpsServer(net::CERT_STATUS_DATE_INVALID,
|
| @@ -733,9 +735,11 @@ IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest, BrokenHTTPS) {
|
| true /* expect cert status error */);
|
| }
|
|
|
| +namespace {
|
| +
|
| const char kReportURI[] = "https://report-hpkp.test";
|
|
|
| -class PKPModelClientTest : public ChromeSecurityStateModelClientTest {
|
| +class PKPModelClientTest : public ChromeSecurityStateModelTest {
|
| public:
|
| void SetUpOnMainThread() override {
|
| ASSERT_TRUE(https_server_.Start());
|
| @@ -768,6 +772,8 @@ class PKPModelClientTest : public ChromeSecurityStateModelClientTest {
|
| scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_;
|
| };
|
|
|
| +} // namespace
|
| +
|
| IN_PROC_BROWSER_TEST_F(PKPModelClientTest, PKPBypass) {
|
| content::WebContents* web_contents =
|
| browser()->tab_strip_model()->GetActiveWebContents();
|
| @@ -820,6 +826,8 @@ IN_PROC_BROWSER_TEST_F(PKPModelClientTest, PKPEnforced) {
|
| browser(), cert.get());
|
| }
|
|
|
| +namespace {
|
| +
|
| // Fails requests with ERR_IO_PENDING. Can be used to simulate a navigation
|
| // that never stops loading.
|
| class PendingJobInterceptor : public net::URLRequestInterceptor {
|
| @@ -847,9 +855,9 @@ void InstallLoadingInterceptor(const std::string& host) {
|
| }
|
|
|
| class SecurityStateModelLoadingTest
|
| - : public ChromeSecurityStateModelClientTest {
|
| + : public ChromeSecurityStateModelTest {
|
| public:
|
| - SecurityStateModelLoadingTest() : ChromeSecurityStateModelClientTest() {}
|
| + SecurityStateModelLoadingTest() : ChromeSecurityStateModelTest() {}
|
| ~SecurityStateModelLoadingTest() override{};
|
|
|
| protected:
|
| @@ -865,6 +873,8 @@ class SecurityStateModelLoadingTest
|
| DISALLOW_COPY_AND_ASSIGN(SecurityStateModelLoadingTest);
|
| };
|
|
|
| +} // namespace
|
| +
|
| // Tests that navigation state changes cause the security state to be
|
| // updated.
|
| IN_PROC_BROWSER_TEST_F(SecurityStateModelLoadingTest, NavigationStateChanges) {
|
| @@ -891,7 +901,7 @@ IN_PROC_BROWSER_TEST_F(SecurityStateModelLoadingTest, NavigationStateChanges) {
|
|
|
| // Tests that the NavigationEntry's flags for nonsecure password/credit
|
| // card inputs are reflected in the VisibleSecurityState.
|
| -IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest,
|
| +IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelTest,
|
| VisibleSecurityStateNonsecureFormInputs) {
|
| ASSERT_TRUE(https_server_.Start());
|
| ui_test_utils::NavigateToURL(browser(),
|
| @@ -901,9 +911,9 @@ IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest,
|
| browser()->tab_strip_model()->GetActiveWebContents();
|
| ASSERT_TRUE(contents);
|
|
|
| - ChromeSecurityStateModelClient* model_client =
|
| - ChromeSecurityStateModelClient::FromWebContents(contents);
|
| - ASSERT_TRUE(model_client);
|
| + ChromeSecurityStateModel* model =
|
| + ChromeSecurityStateModel::FromWebContents(contents);
|
| + ASSERT_TRUE(model);
|
|
|
| // First, test that if the flags aren't set on the NavigationEntry,
|
| // then they also aren't set on the VisibleSecurityState.
|
| @@ -913,14 +923,14 @@ IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest,
|
| content::SSLStatus::DISPLAYED_PASSWORD_FIELD_ON_HTTP);
|
| ASSERT_FALSE(ssl_status.content_status &
|
| content::SSLStatus::DISPLAYED_CREDIT_CARD_FIELD_ON_HTTP);
|
| - SecurityStateModel::VisibleSecurityState
|
| - visible_security_state_no_sensitive_inputs;
|
| - model_client->GetVisibleSecurityState(
|
| - &visible_security_state_no_sensitive_inputs);
|
| + std::unique_ptr<SecurityStateModel::VisibleSecurityState>
|
| + visible_security_state_no_sensitive_inputs =
|
| + model->web_contents_model_->GetVisibleSecurityState(
|
| + model->GetMalwareStatus());
|
| EXPECT_FALSE(visible_security_state_no_sensitive_inputs
|
| - .displayed_password_field_on_http);
|
| + ->displayed_password_field_on_http);
|
| EXPECT_FALSE(visible_security_state_no_sensitive_inputs
|
| - .displayed_credit_card_field_on_http);
|
| + ->displayed_credit_card_field_on_http);
|
|
|
| // Now, set the flags on the NavigationEntry and test that they are
|
| // reflected in the VisibleSecurityState.
|
| @@ -928,34 +938,34 @@ IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest,
|
| content::SSLStatus::DISPLAYED_PASSWORD_FIELD_ON_HTTP;
|
| ssl_status.content_status |=
|
| content::SSLStatus::DISPLAYED_CREDIT_CARD_FIELD_ON_HTTP;
|
| - SecurityStateModel::VisibleSecurityState
|
| - visible_security_state_sensitive_inputs;
|
| - model_client->GetVisibleSecurityState(
|
| - &visible_security_state_sensitive_inputs);
|
| - EXPECT_TRUE(
|
| - visible_security_state_sensitive_inputs.displayed_password_field_on_http);
|
| + std::unique_ptr<SecurityStateModel::VisibleSecurityState>
|
| + visible_security_state_sensitive_inputs =
|
| + model->web_contents_model_->GetVisibleSecurityState(
|
| + model->GetMalwareStatus());
|
| EXPECT_TRUE(visible_security_state_sensitive_inputs
|
| - .displayed_credit_card_field_on_http);
|
| + ->displayed_password_field_on_http);
|
| + EXPECT_TRUE(visible_security_state_sensitive_inputs
|
| + ->displayed_credit_card_field_on_http);
|
| }
|
|
|
| // Tests that when a visible password field is detected on an HTTP page
|
| // load, and when the command-line flag is set, the security level is
|
| // downgraded to HTTP_SHOW_WARNING.
|
| -IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTestWithPasswordCcSwitch,
|
| +IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelTestWithPasswordCcSwitch,
|
| PasswordSecurityLevelDowngraded) {
|
| content::WebContents* contents =
|
| browser()->tab_strip_model()->GetActiveWebContents();
|
| ASSERT_TRUE(contents);
|
|
|
| - ChromeSecurityStateModelClient* model_client =
|
| - ChromeSecurityStateModelClient::FromWebContents(contents);
|
| - ASSERT_TRUE(model_client);
|
| + ChromeSecurityStateModel* model =
|
| + ChromeSecurityStateModel::FromWebContents(contents);
|
| + ASSERT_TRUE(model);
|
|
|
| ui_test_utils::NavigateToURL(
|
| browser(), GetURLWithNonLocalHostname(embedded_test_server(),
|
| "/password/simple_password.html"));
|
| security_state::SecurityStateModel::SecurityInfo security_info;
|
| - model_client->GetSecurityInfo(&security_info);
|
| + model->GetSecurityInfo(&security_info);
|
| EXPECT_EQ(security_state::SecurityStateModel::HTTP_SHOW_WARNING,
|
| security_info.security_level);
|
|
|
| @@ -968,22 +978,22 @@ IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTestWithPasswordCcSwitch,
|
| // Tests that when an invisible password field is present on an HTTP page
|
| // load, and when the command-line flag is set, the security level is
|
| // *not* downgraded to HTTP_SHOW_WARNING.
|
| -IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTestWithPasswordCcSwitch,
|
| +IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelTestWithPasswordCcSwitch,
|
| PasswordSecurityLevelNotDowngradedForInvisibleInput) {
|
| content::WebContents* contents =
|
| browser()->tab_strip_model()->GetActiveWebContents();
|
| ASSERT_TRUE(contents);
|
|
|
| - ChromeSecurityStateModelClient* model_client =
|
| - ChromeSecurityStateModelClient::FromWebContents(contents);
|
| - ASSERT_TRUE(model_client);
|
| + ChromeSecurityStateModel* model =
|
| + ChromeSecurityStateModel::FromWebContents(contents);
|
| + ASSERT_TRUE(model);
|
|
|
| ui_test_utils::NavigateToURL(
|
| browser(),
|
| GetURLWithNonLocalHostname(embedded_test_server(),
|
| "/password/invisible_password.html"));
|
| security_state::SecurityStateModel::SecurityInfo security_info;
|
| - model_client->GetSecurityInfo(&security_info);
|
| + model->GetSecurityInfo(&security_info);
|
| EXPECT_EQ(security_state::SecurityStateModel::NONE,
|
| security_info.security_level);
|
|
|
| @@ -996,22 +1006,22 @@ IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTestWithPasswordCcSwitch,
|
| // Tests that when a visible password field is detected inside an iframe
|
| // on an HTTP page load, and when the command-line flag is set, the
|
| // security level is downgraded to HTTP_SHOW_WARNING.
|
| -IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTestWithPasswordCcSwitch,
|
| +IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelTestWithPasswordCcSwitch,
|
| PasswordSecurityLevelDowngradedFromIframe) {
|
| content::WebContents* contents =
|
| browser()->tab_strip_model()->GetActiveWebContents();
|
| ASSERT_TRUE(contents);
|
|
|
| - ChromeSecurityStateModelClient* model_client =
|
| - ChromeSecurityStateModelClient::FromWebContents(contents);
|
| - ASSERT_TRUE(model_client);
|
| + ChromeSecurityStateModel* model =
|
| + ChromeSecurityStateModel::FromWebContents(contents);
|
| + ASSERT_TRUE(model);
|
|
|
| ui_test_utils::NavigateToURL(
|
| browser(),
|
| GetURLWithNonLocalHostname(embedded_test_server(),
|
| "/password/simple_password_in_iframe.html"));
|
| security_state::SecurityStateModel::SecurityInfo security_info;
|
| - model_client->GetSecurityInfo(&security_info);
|
| + model->GetSecurityInfo(&security_info);
|
| EXPECT_EQ(security_state::SecurityStateModel::HTTP_SHOW_WARNING,
|
| security_info.security_level);
|
|
|
| @@ -1025,15 +1035,15 @@ IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTestWithPasswordCcSwitch,
|
| // on an HTTP page load, and when the command-line flag is set, the
|
| // security level is downgraded to HTTP_SHOW_WARNING, even if the iframe
|
| // itself was loaded over HTTPS.
|
| -IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTestWithPasswordCcSwitch,
|
| +IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelTestWithPasswordCcSwitch,
|
| PasswordSecurityLevelDowngradedFromHttpsIframe) {
|
| content::WebContents* contents =
|
| browser()->tab_strip_model()->GetActiveWebContents();
|
| ASSERT_TRUE(contents);
|
|
|
| - ChromeSecurityStateModelClient* model_client =
|
| - ChromeSecurityStateModelClient::FromWebContents(contents);
|
| - ASSERT_TRUE(model_client);
|
| + ChromeSecurityStateModel* model =
|
| + ChromeSecurityStateModel::FromWebContents(contents);
|
| + ASSERT_TRUE(model);
|
|
|
| // Navigate to an HTTP URL, which loads an iframe using the host and port of
|
| // |https_server_|.
|
| @@ -1045,7 +1055,7 @@ IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTestWithPasswordCcSwitch,
|
| browser(),
|
| GetURLWithNonLocalHostname(embedded_test_server(), replacement_path));
|
| security_state::SecurityStateModel::SecurityInfo security_info;
|
| - model_client->GetSecurityInfo(&security_info);
|
| + model->GetSecurityInfo(&security_info);
|
| EXPECT_EQ(security_state::SecurityStateModel::HTTP_SHOW_WARNING,
|
| security_info.security_level);
|
|
|
| @@ -1058,7 +1068,7 @@ IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTestWithPasswordCcSwitch,
|
| // Tests that when a visible password field is detected on an HTTP page
|
| // load, and when the command-line flag is *not* set, the security level is
|
| // *not* downgraded to HTTP_SHOW_WARNING.
|
| -IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest,
|
| +IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelTest,
|
| PasswordSecurityLevelNotDowngradedWithoutSwitch) {
|
| ASSERT_TRUE(embedded_test_server()->Start());
|
| host_resolver()->AddRule("*", embedded_test_server()->GetURL("/").host());
|
| @@ -1067,9 +1077,9 @@ IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest,
|
| browser()->tab_strip_model()->GetActiveWebContents();
|
| ASSERT_TRUE(contents);
|
|
|
| - ChromeSecurityStateModelClient* model_client =
|
| - ChromeSecurityStateModelClient::FromWebContents(contents);
|
| - ASSERT_TRUE(model_client);
|
| + ChromeSecurityStateModel* model =
|
| + ChromeSecurityStateModel::FromWebContents(contents);
|
| + ASSERT_TRUE(model);
|
|
|
| ui_test_utils::NavigateToURL(
|
| browser(), GetURLWithNonLocalHostname(embedded_test_server(),
|
| @@ -1077,7 +1087,7 @@ IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest,
|
| // The security level should not be HTTP_SHOW_WARNING, because the
|
| // command-line switch was not set.
|
| security_state::SecurityStateModel::SecurityInfo security_info;
|
| - model_client->GetSecurityInfo(&security_info);
|
| + model->GetSecurityInfo(&security_info);
|
| EXPECT_EQ(security_state::SecurityStateModel::NONE,
|
| security_info.security_level);
|
|
|
| @@ -1091,15 +1101,15 @@ IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest,
|
| // Tests that when a visible password field is detected on an HTTPS page
|
| // load, and when the command-line flag is set, the security level is
|
| // *not* downgraded to HTTP_SHOW_WARNING.
|
| -IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTestWithPasswordCcSwitch,
|
| +IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelTestWithPasswordCcSwitch,
|
| PasswordSecurityLevelNotDowngradedOnHttps) {
|
| content::WebContents* contents =
|
| browser()->tab_strip_model()->GetActiveWebContents();
|
| ASSERT_TRUE(contents);
|
|
|
| - ChromeSecurityStateModelClient* model_client =
|
| - ChromeSecurityStateModelClient::FromWebContents(contents);
|
| - ASSERT_TRUE(model_client);
|
| + ChromeSecurityStateModel* model =
|
| + ChromeSecurityStateModel::FromWebContents(contents);
|
| + ASSERT_TRUE(model);
|
|
|
| GURL url = GetURLWithNonLocalHostname(&https_server_,
|
| "/password/simple_password.html");
|
| @@ -1107,7 +1117,7 @@ IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTestWithPasswordCcSwitch,
|
| // The security level should not be HTTP_SHOW_WARNING, because the page was
|
| // HTTPS instead of HTTP.
|
| security_state::SecurityStateModel::SecurityInfo security_info;
|
| - model_client->GetSecurityInfo(&security_info);
|
| + model->GetSecurityInfo(&security_info);
|
| EXPECT_EQ(security_state::SecurityStateModel::SECURE,
|
| security_info.security_level);
|
|
|
| @@ -1119,6 +1129,8 @@ IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTestWithPasswordCcSwitch,
|
| content::SSLStatus::DISPLAYED_PASSWORD_FIELD_ON_HTTP);
|
| }
|
|
|
| +namespace {
|
| +
|
| // A Browser subclass that keeps track of messages that have been
|
| // added to the console. Messages can be retrieved or cleared with
|
| // console_messages() and ClearConsoleMessages(). The user of this class
|
| @@ -1184,10 +1196,12 @@ void CheckForOneFutureHttpWarningConsoleMessage(
|
| messages[0].find(base::ASCIIToUTF16("warning will be added")));
|
| }
|
|
|
| +} // namespace
|
| +
|
| // Tests that console messages are printed upon a call to
|
| // GetSecurityInfo() on an HTTP_SHOW_WARNING page, exactly once per
|
| // main-frame navigation.
|
| -IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTestWithPasswordCcSwitch,
|
| +IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelTestWithPasswordCcSwitch,
|
| ConsoleMessage) {
|
| ConsoleWebContentsDelegate* delegate = new ConsoleWebContentsDelegate(
|
| Browser::CreateParams(browser()->profile()));
|
| @@ -1220,8 +1234,8 @@ IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTestWithPasswordCcSwitch,
|
| first_message.Run();
|
|
|
| // Check that the HTTP_SHOW_WARNING state was actually triggered.
|
| - ChromeSecurityStateModelClient* client =
|
| - ChromeSecurityStateModelClient::FromWebContents(contents);
|
| + ChromeSecurityStateModel* client =
|
| + ChromeSecurityStateModel::FromWebContents(contents);
|
| ASSERT_TRUE(client);
|
| security_state::SecurityStateModel::SecurityInfo security_info;
|
| client->GetSecurityInfo(&security_info);
|
| @@ -1258,7 +1272,7 @@ IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTestWithPasswordCcSwitch,
|
| // Tests that console messages are printed upon a call to
|
| // GetSecurityInfo() on a NONE page that will be marked
|
| // HTTP_SHOW_WARNING in future, exactly once per main-frame navigation.
|
| -IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest, ConsoleMessage) {
|
| +IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelTest, ConsoleMessage) {
|
| ASSERT_TRUE(embedded_test_server()->Start());
|
| host_resolver()->AddRule("*", embedded_test_server()->GetURL("/").host());
|
| ConsoleWebContentsDelegate* delegate = new ConsoleWebContentsDelegate(
|
| @@ -1292,8 +1306,8 @@ IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest, ConsoleMessage) {
|
| first_message.Run();
|
|
|
| // Check that the correct state was actually triggered.
|
| - ChromeSecurityStateModelClient* client =
|
| - ChromeSecurityStateModelClient::FromWebContents(contents);
|
| + ChromeSecurityStateModel* client =
|
| + ChromeSecurityStateModel::FromWebContents(contents);
|
| ASSERT_TRUE(client);
|
| security_state::SecurityStateModel::SecurityInfo security_info;
|
| client->GetSecurityInfo(&security_info);
|
| @@ -1331,7 +1345,7 @@ IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest, ConsoleMessage) {
|
|
|
| // Tests that additional HTTP_SHOW_WARNING console messages are not
|
| // printed after subframe navigations.
|
| -IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTestWithPasswordCcSwitch,
|
| +IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelTestWithPasswordCcSwitch,
|
| ConsoleMessageNotPrintedForFrameNavigation) {
|
| ConsoleWebContentsDelegate* delegate = new ConsoleWebContentsDelegate(
|
| Browser::CreateParams(browser()->profile()));
|
| @@ -1364,8 +1378,8 @@ IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTestWithPasswordCcSwitch,
|
| first_message.Run();
|
|
|
| // Check that the HTTP_SHOW_WARNING state was actually triggered.
|
| - ChromeSecurityStateModelClient* client =
|
| - ChromeSecurityStateModelClient::FromWebContents(contents);
|
| + ChromeSecurityStateModel* client =
|
| + ChromeSecurityStateModel::FromWebContents(contents);
|
| ASSERT_TRUE(client);
|
| security_state::SecurityStateModel::SecurityInfo security_info;
|
| client->GetSecurityInfo(&security_info);
|
| @@ -1415,7 +1429,7 @@ IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTestWithPasswordCcSwitch,
|
|
|
| // Tests that additional HTTP_SHOW_WARNING console messages are not
|
| // printed after pushState navigations.
|
| -IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTestWithPasswordCcSwitch,
|
| +IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelTestWithPasswordCcSwitch,
|
| ConsoleMessageNotPrintedForPushStateNavigation) {
|
| ConsoleWebContentsDelegate* delegate = new ConsoleWebContentsDelegate(
|
| Browser::CreateParams(browser()->profile()));
|
| @@ -1448,8 +1462,8 @@ IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTestWithPasswordCcSwitch,
|
| first_message.Run();
|
|
|
| // Check that the HTTP_SHOW_WARNING state was actually triggered.
|
| - ChromeSecurityStateModelClient* client =
|
| - ChromeSecurityStateModelClient::FromWebContents(contents);
|
| + ChromeSecurityStateModel* client =
|
| + ChromeSecurityStateModel::FromWebContents(contents);
|
| ASSERT_TRUE(client);
|
| security_state::SecurityStateModel::SecurityInfo security_info;
|
| client->GetSecurityInfo(&security_info);
|
| @@ -1494,7 +1508,7 @@ IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTestWithPasswordCcSwitch,
|
|
|
| // Tests that the SecurityStateModel for a WebContents is up to date
|
| // when the WebContents is inserted into a Browser's TabStripModel.
|
| -IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest, AddedTab) {
|
| +IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelTest, AddedTab) {
|
| ASSERT_TRUE(https_server_.Start());
|
| SetUpMockCertVerifierForHttpsServer(0, net::OK);
|
|
|
| @@ -1505,7 +1519,7 @@ IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest, AddedTab) {
|
| content::WebContents* new_contents = content::WebContents::Create(
|
| content::WebContents::CreateParams(tab->GetBrowserContext()));
|
| content::NavigationController& controller = new_contents->GetController();
|
| - ChromeSecurityStateModelClient::CreateForWebContents(new_contents);
|
| + ChromeSecurityStateModel::CreateForWebContents(new_contents);
|
| CheckSecurityInfoForNonSecure(new_contents);
|
| controller.LoadURL(https_server_.GetURL("/title1.html"), content::Referrer(),
|
| ui::PAGE_TRANSITION_TYPED, std::string());
|
| @@ -1750,6 +1764,8 @@ IN_PROC_BROWSER_TEST_F(SecurityStyleChangedTest,
|
| EXPECT_FALSE(observer.latest_explanations().ran_mixed_content);
|
| }
|
|
|
| +namespace {
|
| +
|
| // After AddNonsecureUrlHandler() is called, requests to this hostname
|
| // will use obsolete TLS settings.
|
| const char kMockNonsecureHostname[] = "example-nonsecure.test";
|
| @@ -1864,6 +1880,8 @@ class BrowserTestNonsecureURLRequest : public InProcessBrowserTest {
|
| DISALLOW_COPY_AND_ASSIGN(BrowserTestNonsecureURLRequest);
|
| };
|
|
|
| +} // namespace
|
| +
|
| // Tests that a connection with obsolete TLS settings does not get a
|
| // secure connection explanation.
|
| IN_PROC_BROWSER_TEST_F(BrowserTestNonsecureURLRequest,
|
| @@ -1911,6 +1929,8 @@ IN_PROC_BROWSER_TEST_F(BrowserTestNonsecureURLRequest,
|
| observer.latest_explanations().info_explanations[0].description));
|
| }
|
|
|
| +namespace {
|
| +
|
| // After AddSCTUrlHandler() is called, requests to this hostname
|
| // will be served with Signed Certificate Timestamps.
|
| const char kMockHostnameWithSCTs[] = "example-scts.test";
|
| @@ -2028,6 +2048,8 @@ class BrowserTestURLRequestWithSCTs : public InProcessBrowserTest {
|
| DISALLOW_COPY_AND_ASSIGN(BrowserTestURLRequestWithSCTs);
|
| };
|
|
|
| +} // namespace
|
| +
|
| // Tests that, when Signed Certificate Timestamps (SCTs) are served on a
|
| // connection, the SCTs verification statuses are exposed on the
|
| // SecurityInfo.
|
| @@ -2039,13 +2061,11 @@ IN_PROC_BROWSER_TEST_F(BrowserTestURLRequestWithSCTs,
|
| content::WebContents* web_contents =
|
| browser()->tab_strip_model()->GetActiveWebContents();
|
| ASSERT_TRUE(web_contents);
|
| - ChromeSecurityStateModelClient* model_client =
|
| - ChromeSecurityStateModelClient::FromWebContents(web_contents);
|
| - ASSERT_TRUE(model_client);
|
| + ChromeSecurityStateModel* model =
|
| + ChromeSecurityStateModel::FromWebContents(web_contents);
|
| + ASSERT_TRUE(model);
|
| SecurityStateModel::SecurityInfo security_info;
|
| - model_client->GetSecurityInfo(&security_info);
|
| + model->GetSecurityInfo(&security_info);
|
| EXPECT_EQ(SecurityStateModel::SECURE, security_info.security_level);
|
| EXPECT_EQ(kTestSCTStatuses, security_info.sct_verify_statuses);
|
| }
|
| -
|
| -} // namespace
|
|
|