Chromium Code Reviews| Index: components/security_state/security_state_model_unittest.cc |
| diff --git a/chrome/browser/ssl/security_state_model_unittest.cc b/components/security_state/security_state_model_unittest.cc |
| similarity index 87% |
| rename from chrome/browser/ssl/security_state_model_unittest.cc |
| rename to components/security_state/security_state_model_unittest.cc |
| index af14dfabf97e92833c2b2e00f79409791ca48286..302215dc51968cb4ca78e4bfc50412f143e85d54 100644 |
| --- a/chrome/browser/ssl/security_state_model_unittest.cc |
| +++ b/components/security_state/security_state_model_unittest.cc |
| @@ -2,15 +2,9 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#include "chrome/browser/ssl/security_state_model.h" |
| - |
| -#include "chrome/browser/ssl/security_state_model_client.h" |
| -#include "chrome/test/base/chrome_render_view_host_test_harness.h" |
| -#include "chrome/test/base/testing_profile.h" |
| -#include "content/public/browser/cert_store.h" |
| -#include "content/public/common/origin_util.h" |
| -#include "content/public/test/mock_render_process_host.h" |
| -#include "content/public/test/test_browser_thread_bundle.h" |
| +#include "components/security_state/security_state_model.h" |
| + |
| +#include "components/security_state/security_state_model_client.h" |
| #include "net/base/test_data_directory.h" |
| #include "net/cert/x509_certificate.h" |
| #include "net/ssl/ssl_connection_status_flags.h" |
| @@ -18,6 +12,8 @@ |
| #include "net/test/test_certificate_data.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| +namespace security_state { |
| + |
| namespace { |
| const char kUrl[] = "https://foo.test"; |
| @@ -31,6 +27,7 @@ class TestSecurityStateModelClient : public SecurityStateModelClient { |
| cert_status_(net::CERT_STATUS_SHA1_SIGNATURE_PRESENT), |
| displayed_mixed_content_(false), |
| ran_mixed_content_(false) { |
| + LOG(ERROR) << "Test certs directory: " << net::GetTestCertsDirectory().value(); |
|
blundell
2016/01/05 16:02:16
this should go before landing, of course.
estark
2016/01/05 22:59:30
Done.
|
| cert_ = |
| net::ImportCertFromFile(net::GetTestCertsDirectory(), "sha1_2016.pem"); |
| } |
| @@ -77,9 +74,7 @@ class TestSecurityStateModelClient : public SecurityStateModelClient { |
| bool UsedPolicyInstalledCertificate() override { return false; } |
| - bool IsOriginSecure(const GURL& url) override { |
| - return content::IsOriginSecure(url); |
| - } |
| + bool IsOriginSecure(const GURL& url) override { return true; } |
| private: |
| SecurityStateModel::SecurityLevel initial_security_level_; |
| @@ -90,11 +85,9 @@ class TestSecurityStateModelClient : public SecurityStateModelClient { |
| bool ran_mixed_content_; |
| }; |
| -class SecurityStateModelTest : public ChromeRenderViewHostTestHarness {}; |
| - |
| // Tests that SHA1-signed certificates expiring in 2016 downgrade the |
| // security state of the page. |
| -TEST_F(SecurityStateModelTest, SHA1Warning) { |
| +TEST(SecurityStateModelTest, SHA1Warning) { |
| TestSecurityStateModelClient client; |
| SecurityStateModel model; |
| model.SetClient(&client); |
| @@ -107,7 +100,7 @@ TEST_F(SecurityStateModelTest, SHA1Warning) { |
| // Tests that SHA1 warnings don't interfere with the handling of mixed |
| // content. |
| -TEST_F(SecurityStateModelTest, SHA1WarningMixedContent) { |
| +TEST(SecurityStateModelTest, SHA1WarningMixedContent) { |
| TestSecurityStateModelClient client; |
| SecurityStateModel model; |
| model.SetClient(&client); |
| @@ -134,7 +127,7 @@ TEST_F(SecurityStateModelTest, SHA1WarningMixedContent) { |
| // Tests that SHA1 warnings don't interfere with the handling of major |
| // cert errors. |
| -TEST_F(SecurityStateModelTest, SHA1WarningBrokenHTTPS) { |
| +TEST(SecurityStateModelTest, SHA1WarningBrokenHTTPS) { |
| TestSecurityStateModelClient client; |
| SecurityStateModel model; |
| model.SetClient(&client); |
| @@ -149,7 +142,7 @@ TEST_F(SecurityStateModelTest, SHA1WarningBrokenHTTPS) { |
| // Tests that |security_info.is_secure_protocol_and_ciphersuite| is |
| // computed correctly. |
| -TEST_F(SecurityStateModelTest, SecureProtocolAndCiphersuite) { |
| +TEST(SecurityStateModelTest, SecureProtocolAndCiphersuite) { |
| TestSecurityStateModelClient client; |
| SecurityStateModel model; |
| model.SetClient(&client); |
| @@ -164,7 +157,7 @@ TEST_F(SecurityStateModelTest, SecureProtocolAndCiphersuite) { |
| EXPECT_TRUE(security_info.is_secure_protocol_and_ciphersuite); |
| } |
| -TEST_F(SecurityStateModelTest, NonsecureProtocol) { |
| +TEST(SecurityStateModelTest, NonsecureProtocol) { |
| TestSecurityStateModelClient client; |
| SecurityStateModel model; |
| model.SetClient(&client); |
| @@ -179,7 +172,7 @@ TEST_F(SecurityStateModelTest, NonsecureProtocol) { |
| EXPECT_FALSE(security_info.is_secure_protocol_and_ciphersuite); |
| } |
| -TEST_F(SecurityStateModelTest, NonsecureCiphersuite) { |
| +TEST(SecurityStateModelTest, NonsecureCiphersuite) { |
| TestSecurityStateModelClient client; |
| SecurityStateModel model; |
| model.SetClient(&client); |
| @@ -195,3 +188,5 @@ TEST_F(SecurityStateModelTest, NonsecureCiphersuite) { |
| } |
| } // namespace |
| + |
| +} // namespace security_state |