| 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 "components/security_state/security_state_model.h" | 5 #include "components/security_state/security_state_model.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/test/histogram_tester.h" | 10 #include "base/test/histogram_tester.h" |
| 11 #include "components/security_state/security_state_model_client.h" | 11 #include "components/security_state/security_state_model_client.h" |
| 12 #include "components/security_state/switches.h" | 12 #include "components/security_state/switches.h" |
| 13 #include "net/cert/x509_certificate.h" | 13 #include "net/cert/x509_certificate.h" |
| 14 #include "net/ssl/ssl_cipher_suite_names.h" | 14 #include "net/ssl/ssl_cipher_suite_names.h" |
| 15 #include "net/ssl/ssl_connection_status_flags.h" | 15 #include "net/ssl/ssl_connection_status_flags.h" |
| 16 #include "net/test/cert_test_util.h" | 16 #include "net/test/cert_test_util.h" |
| 17 #include "net/test/test_certificate_data.h" | 17 #include "net/test/test_certificate_data.h" |
| 18 #include "net/test/test_data_directory.h" | 18 #include "net/test/test_data_directory.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 20 | 20 |
| 21 namespace security_state { | 21 namespace security_state { |
| 22 | 22 |
| 23 namespace { | 23 namespace { |
| 24 | 24 |
| 25 const char kHttpsUrl[] = "https://foo.test"; | 25 const char kHttpsUrl[] = "https://foo.test/"; |
| 26 const char kHttpUrl[] = "http://foo.test"; | 26 const char kHttpUrl[] = "http://foo.test/"; |
| 27 | 27 |
| 28 class TestSecurityStateModelClient : public SecurityStateModelClient { | 28 class TestSecurityStateModelClient : public SecurityStateModelClient { |
| 29 public: | 29 public: |
| 30 TestSecurityStateModelClient() | 30 TestSecurityStateModelClient() |
| 31 : url_(kHttpsUrl), | 31 : url_(kHttpsUrl), |
| 32 connection_status_(net::SSL_CONNECTION_VERSION_TLS1_2 | 32 connection_status_(net::SSL_CONNECTION_VERSION_TLS1_2 |
| 33 << net::SSL_CONNECTION_VERSION_SHIFT), | 33 << net::SSL_CONNECTION_VERSION_SHIFT), |
| 34 cert_status_(net::CERT_STATUS_SHA1_SIGNATURE_PRESENT), | 34 cert_status_(net::CERT_STATUS_SHA1_SIGNATURE_PRESENT), |
| 35 displayed_mixed_content_(false), | 35 displayed_mixed_content_(false), |
| 36 ran_mixed_content_(false), | 36 ran_mixed_content_(false), |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 state->ran_mixed_content = ran_mixed_content_; | 84 state->ran_mixed_content = ran_mixed_content_; |
| 85 state->fails_malware_check = fails_malware_check_; | 85 state->fails_malware_check = fails_malware_check_; |
| 86 state->displayed_password_field_on_http = displayed_password_field_on_http_; | 86 state->displayed_password_field_on_http = displayed_password_field_on_http_; |
| 87 state->displayed_credit_card_field_on_http = | 87 state->displayed_credit_card_field_on_http = |
| 88 displayed_credit_card_field_on_http_; | 88 displayed_credit_card_field_on_http_; |
| 89 } | 89 } |
| 90 | 90 |
| 91 bool UsedPolicyInstalledCertificate() override { return false; } | 91 bool UsedPolicyInstalledCertificate() override { return false; } |
| 92 | 92 |
| 93 bool IsOriginSecure(const GURL& url) override { | 93 bool IsOriginSecure(const GURL& url) override { |
| 94 return url_ == GURL(kHttpsUrl); | 94 return url_ == kHttpsUrl; |
| 95 } | 95 } |
| 96 | 96 |
| 97 private: | 97 private: |
| 98 GURL url_; | 98 GURL url_; |
| 99 scoped_refptr<net::X509Certificate> cert_; | 99 scoped_refptr<net::X509Certificate> cert_; |
| 100 int connection_status_; | 100 int connection_status_; |
| 101 net::CertStatus cert_status_; | 101 net::CertStatus cert_status_; |
| 102 bool displayed_mixed_content_; | 102 bool displayed_mixed_content_; |
| 103 bool ran_mixed_content_; | 103 bool ran_mixed_content_; |
| 104 bool fails_malware_check_; | 104 bool fails_malware_check_; |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 | 325 |
| 326 // Ensure histogram recorded correctly even without a password input. | 326 // Ensure histogram recorded correctly even without a password input. |
| 327 client.set_displayed_password_field_on_http(false); | 327 client.set_displayed_password_field_on_http(false); |
| 328 model.GetSecurityInfo(&security_info); | 328 model.GetSecurityInfo(&security_info); |
| 329 histograms.ExpectUniqueSample(kHistogramName, 2 /* HTTP_SHOW_WARNING */, 2); | 329 histograms.ExpectUniqueSample(kHistogramName, 2 /* HTTP_SHOW_WARNING */, 2); |
| 330 } | 330 } |
| 331 | 331 |
| 332 } // namespace | 332 } // namespace |
| 333 | 333 |
| 334 } // namespace security_state | 334 } // namespace security_state |
| OLD | NEW |