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

Side by Side Diff: chrome/browser/ssl/ssl_error_handler_unittest.cc

Issue 2690333006: Captive portal certificate list should be checked when name mismatch is the only error (Closed)
Patch Set: estark comments and rebase Created 3 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/ssl_error_handler.h" 5 #include "chrome/browser/ssl/ssl_error_handler.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/metrics/field_trial.h" 10 #include "base/metrics/field_trial.h"
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 bool captive_portal_interstitial_shown_; 184 bool captive_portal_interstitial_shown_;
185 bool redirected_to_suggested_url_; 185 bool redirected_to_suggested_url_;
186 bool is_overridable_error_; 186 bool is_overridable_error_;
187 CommonNameMismatchHandler::CheckUrlCallback suggested_url_callback_; 187 CommonNameMismatchHandler::CheckUrlCallback suggested_url_callback_;
188 188
189 DISALLOW_COPY_AND_ASSIGN(TestSSLErrorHandlerDelegate); 189 DISALLOW_COPY_AND_ASSIGN(TestSSLErrorHandlerDelegate);
190 }; 190 };
191 191
192 } // namespace 192 } // namespace
193 193
194 template <net::CertStatus cert_status> 194 // A class to test name mismatch errors. Creates an error handler with a name
195 class SSLErrorHandlerCertStatusTestBase 195 // mismatch error.
196 : public ChromeRenderViewHostTestHarness { 196 class SSLErrorHandlerNameMismatchTest : public ChromeRenderViewHostTestHarness {
197 public: 197 public:
198 SSLErrorHandlerCertStatusTestBase() : field_trial_list_(nullptr) {} 198 SSLErrorHandlerNameMismatchTest() : field_trial_list_(nullptr) {}
199 199
200 void SetUp() override { 200 void SetUp() override {
201 ChromeRenderViewHostTestHarness::SetUp(); 201 ChromeRenderViewHostTestHarness::SetUp();
202 SSLErrorHandler::ResetConfigForTesting(); 202 SSLErrorHandler::ResetConfigForTesting();
203 SSLErrorHandler::SetInterstitialDelayForTesting(base::TimeDelta()); 203 SSLErrorHandler::SetInterstitialDelayForTesting(base::TimeDelta());
204 ssl_info_.Reset();
204 ssl_info_.cert = 205 ssl_info_.cert =
205 net::ImportCertFromFile(net::GetTestCertsDirectory(), "ok_cert.pem"); 206 net::ImportCertFromFile(net::GetTestCertsDirectory(), "ok_cert.pem");
206 ssl_info_.cert_status = cert_status; 207 ssl_info_.cert_status = net::CERT_STATUS_COMMON_NAME_INVALID;
207 ssl_info_.public_key_hashes.push_back( 208 ssl_info_.public_key_hashes.push_back(
208 net::HashValue(kCertPublicKeyHashValue)); 209 net::HashValue(kCertPublicKeyHashValue));
209 210
210 delegate_ = 211 delegate_ =
211 new TestSSLErrorHandlerDelegate(profile(), web_contents(), ssl_info_); 212 new TestSSLErrorHandlerDelegate(profile(), web_contents(), ssl_info_);
212 error_handler_.reset(new TestSSLErrorHandler( 213 error_handler_.reset(new TestSSLErrorHandler(
213 std::unique_ptr<SSLErrorHandler::Delegate>(delegate_), web_contents(), 214 std::unique_ptr<SSLErrorHandler::Delegate>(delegate_), web_contents(),
214 profile(), net::MapCertStatusToNetError(ssl_info_.cert_status), 215 profile(), net::MapCertStatusToNetError(ssl_info_.cert_status),
215 ssl_info_, 216 ssl_info_,
216 GURL(), // request_url 217 GURL(), // request_url
217 base::Callback<void(content::CertificateRequestResultType)>())); 218 base::Callback<void(content::CertificateRequestResultType)>()));
218
219 // Enable finch experiment for captive portal interstitials.
220 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
221 "CaptivePortalInterstitial", "Enabled"));
222 // Enable finch experiment for SSL common name mismatch handling.
223 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
224 "SSLCommonNameMismatchHandling", "Enabled"));
225 } 219 }
226 220
227 void TearDown() override { 221 void TearDown() override {
222 EXPECT_FALSE(error_handler()->IsTimerRunningForTesting());
223 error_handler_.reset(nullptr);
224 SSLErrorHandler::ResetConfigForTesting();
225 ChromeRenderViewHostTestHarness::TearDown();
226 }
227
228 TestSSLErrorHandler* error_handler() { return error_handler_.get(); }
229 TestSSLErrorHandlerDelegate* delegate() { return delegate_; }
230
231 const net::SSLInfo& ssl_info() { return ssl_info_; }
232
233 private:
234 net::SSLInfo ssl_info_;
235 std::unique_ptr<TestSSLErrorHandler> error_handler_;
236 TestSSLErrorHandlerDelegate* delegate_;
237 base::FieldTrialList field_trial_list_;
238
239 DISALLOW_COPY_AND_ASSIGN(SSLErrorHandlerNameMismatchTest);
240 };
241
242 // A class to test captive portal certificate list. Creates an error handler
243 // with a name mismatch error by default. The error handler can be recreated by
244 // calling ResetErrorHandler() with an appropriate cert status.
245 class SSLErrorHandlerCaptivePortalCertListTest
246 : public ChromeRenderViewHostTestHarness {
247 public:
248 SSLErrorHandlerCaptivePortalCertListTest() : field_trial_list_(nullptr) {}
249
250 void SetUp() override {
251 ChromeRenderViewHostTestHarness::SetUp();
252 SSLErrorHandler::ResetConfigForTesting();
253 SSLErrorHandler::SetInterstitialDelayForTesting(base::TimeDelta());
254 ResetErrorHandler(net::CERT_STATUS_COMMON_NAME_INVALID);
255 }
256
257 void TearDown() override {
228 EXPECT_FALSE(error_handler()->IsTimerRunningForTesting()); 258 EXPECT_FALSE(error_handler()->IsTimerRunningForTesting());
229 error_handler_.reset(nullptr); 259 error_handler_.reset(nullptr);
230 SSLErrorHandler::ResetConfigForTesting(); 260 SSLErrorHandler::ResetConfigForTesting();
231 ChromeRenderViewHostTestHarness::TearDown(); 261 ChromeRenderViewHostTestHarness::TearDown();
232 } 262 }
233 263
234 TestSSLErrorHandler* error_handler() { return error_handler_.get(); } 264 TestSSLErrorHandler* error_handler() { return error_handler_.get(); }
235 TestSSLErrorHandlerDelegate* delegate() { return delegate_; } 265 TestSSLErrorHandlerDelegate* delegate() { return delegate_; }
236 266
237 const net::SSLInfo& ssl_info() { return ssl_info_; } 267 const net::SSLInfo& ssl_info() { return ssl_info_; }
238 268
269 protected:
270 void SetFeatureEnabled(bool enabled) {
271 if (enabled) {
272 scoped_feature_list_.InitFromCommandLine(
273 "CaptivePortalCertificateList" /* enabled */,
274 std::string() /* disabled */);
275 } else {
276 scoped_feature_list_.InitFromCommandLine(
277 std::string(), "CaptivePortalCertificateList" /* disabled */);
278 }
279 }
280
281 // Deletes the current error handler and creates a new one with the given
282 // |cert_status|.
283 void ResetErrorHandler(net::CertStatus cert_status) {
284 ssl_info_.Reset();
285 ssl_info_.cert =
286 net::ImportCertFromFile(net::GetTestCertsDirectory(), "ok_cert.pem");
287 ssl_info_.cert_status = cert_status;
288 ssl_info_.public_key_hashes.push_back(
289 net::HashValue(kCertPublicKeyHashValue));
290
291 delegate_ =
292 new TestSSLErrorHandlerDelegate(profile(), web_contents(), ssl_info_);
293 error_handler_.reset(new TestSSLErrorHandler(
294 std::unique_ptr<SSLErrorHandler::Delegate>(delegate_), web_contents(),
295 profile(), net::MapCertStatusToNetError(ssl_info_.cert_status),
296 ssl_info_,
297 GURL(), // request_url
298 base::Callback<void(content::CertificateRequestResultType)>()));
299
300 // Enable finch experiment for captive portal interstitials.
301 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
302 "CaptivePortalInterstitial", "Enabled"));
303 // Enable finch experiment for SSL common name mismatch handling.
304 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
305 "SSLCommonNameMismatchHandling", "Enabled"));
306 }
307
308 void TestNoCaptivePortalInterstitial() {
309 base::HistogramTester histograms;
310
311 EXPECT_FALSE(error_handler()->IsTimerRunningForTesting());
312 EXPECT_EQ(1u, ssl_info().public_key_hashes.size());
313
314 auto config_proto =
315 base::MakeUnique<chrome_browser_ssl::SSLErrorAssistantConfig>();
316 config_proto->add_captive_portal_cert()->set_sha256_hash(
317 "sha256/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
318 config_proto->add_captive_portal_cert()->set_sha256_hash(
319 ssl_info().public_key_hashes[0].ToString());
320 config_proto->add_captive_portal_cert()->set_sha256_hash(
321 "sha256/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
322 SSLErrorHandler::SetErrorAssistantProto(std::move(config_proto));
323
324 error_handler()->StartHandlingError();
325
326 // Timer should start for captive portal detection.
327 EXPECT_TRUE(error_handler()->IsTimerRunningForTesting());
328 EXPECT_TRUE(delegate()->captive_portal_checked());
329 EXPECT_FALSE(delegate()->ssl_interstitial_shown());
330 EXPECT_FALSE(delegate()->captive_portal_interstitial_shown());
331 EXPECT_FALSE(delegate()->suggested_url_checked());
332
333 base::RunLoop().RunUntilIdle();
334
335 EXPECT_FALSE(error_handler()->IsTimerRunningForTesting());
336 EXPECT_TRUE(delegate()->captive_portal_checked());
337 EXPECT_TRUE(delegate()->ssl_interstitial_shown());
338 EXPECT_FALSE(delegate()->captive_portal_interstitial_shown());
339 EXPECT_FALSE(delegate()->suggested_url_checked());
340
341 // Check that the histogram for the captive portal cert was recorded.
342 histograms.ExpectTotalCount(SSLErrorHandler::GetHistogramNameForTesting(),
343 2);
344 histograms.ExpectBucketCount(SSLErrorHandler::GetHistogramNameForTesting(),
345 SSLErrorHandler::HANDLE_ALL, 1);
346 histograms.ExpectBucketCount(
347 SSLErrorHandler::GetHistogramNameForTesting(),
348 SSLErrorHandler::SHOW_SSL_INTERSTITIAL_OVERRIDABLE, 1);
349 }
350
239 private: 351 private:
240 net::SSLInfo ssl_info_; 352 net::SSLInfo ssl_info_;
241 std::unique_ptr<TestSSLErrorHandler> error_handler_; 353 std::unique_ptr<TestSSLErrorHandler> error_handler_;
242 TestSSLErrorHandlerDelegate* delegate_; 354 TestSSLErrorHandlerDelegate* delegate_;
243 base::FieldTrialList field_trial_list_; 355 base::FieldTrialList field_trial_list_;
356 base::test::ScopedFeatureList scoped_feature_list_;
244 357
245 DISALLOW_COPY_AND_ASSIGN(SSLErrorHandlerCertStatusTestBase); 358 DISALLOW_COPY_AND_ASSIGN(SSLErrorHandlerCaptivePortalCertListTest);
246 }; 359 };
247 360
248 using SSLErrorHandlerNameMismatchTest =
249 SSLErrorHandlerCertStatusTestBase<net::CERT_STATUS_COMMON_NAME_INVALID>;
250 using SSLErrorHandlerAuthorityInvalidTest =
251 SSLErrorHandlerCertStatusTestBase<net::CERT_STATUS_AUTHORITY_INVALID>;
252 361
253 class SSLErrorHandlerDateInvalidTest : public ChromeRenderViewHostTestHarness { 362 class SSLErrorHandlerDateInvalidTest : public ChromeRenderViewHostTestHarness {
254 public: 363 public:
255 SSLErrorHandlerDateInvalidTest() 364 SSLErrorHandlerDateInvalidTest()
256 : field_trial_test_(new network_time::FieldTrialTest()), 365 : field_trial_test_(new network_time::FieldTrialTest()),
257 clock_(new base::SimpleTestClock), 366 clock_(new base::SimpleTestClock),
258 tick_clock_(new base::SimpleTestTickClock), 367 tick_clock_(new base::SimpleTestTickClock),
259 test_server_(new net::EmbeddedTestServer) { 368 test_server_(new net::EmbeddedTestServer) {
260 SetThreadBundleOptions(content::TestBrowserThreadBundle::REAL_IO_THREAD); 369 SetThreadBundleOptions(content::TestBrowserThreadBundle::REAL_IO_THREAD);
261 network_time::NetworkTimeTracker::RegisterPrefs(pref_service_.registry()); 370 network_time::NetworkTimeTracker::RegisterPrefs(pref_service_.registry());
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 ClearErrorHandler(); 805 ClearErrorHandler();
697 806
698 // Shut down the server to cancel the pending request. 807 // Shut down the server to cancel the pending request.
699 ASSERT_TRUE(test_server()->ShutdownAndWaitUntilComplete()); 808 ASSERT_TRUE(test_server()->ShutdownAndWaitUntilComplete());
700 } 809 }
701 810
702 #if BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION) 811 #if BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION)
703 812
704 // Tests that a certificate marked as a known captive portal certificate causes 813 // Tests that a certificate marked as a known captive portal certificate causes
705 // the captive portal interstitial to be shown. 814 // the captive portal interstitial to be shown.
706 TEST_F(SSLErrorHandlerNameMismatchTest, CaptivePortalCertificateList_Enabled) { 815 TEST_F(SSLErrorHandlerCaptivePortalCertListTest, Enabled) {
707 base::test::ScopedFeatureList scoped_feature_list; 816 SetFeatureEnabled(true);
708 scoped_feature_list.InitFromCommandLine(
709 "CaptivePortalCertificateList" /* enabled */,
710 std::string() /* disabled */);
711 817
712 EXPECT_FALSE(error_handler()->IsTimerRunningForTesting()); 818 EXPECT_FALSE(error_handler()->IsTimerRunningForTesting());
713 EXPECT_EQ(1u, ssl_info().public_key_hashes.size()); 819 EXPECT_EQ(1u, ssl_info().public_key_hashes.size());
714 820
715 auto config_proto = 821 auto config_proto =
716 base::MakeUnique<chrome_browser_ssl::SSLErrorAssistantConfig>(); 822 base::MakeUnique<chrome_browser_ssl::SSLErrorAssistantConfig>();
717 config_proto->add_captive_portal_cert()->set_sha256_hash( 823 config_proto->add_captive_portal_cert()->set_sha256_hash(
718 "sha256/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); 824 "sha256/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
719 config_proto->add_captive_portal_cert()->set_sha256_hash( 825 config_proto->add_captive_portal_cert()->set_sha256_hash(
720 ssl_info().public_key_hashes[0].ToString()); 826 ssl_info().public_key_hashes[0].ToString());
(...skipping 28 matching lines...) Expand all
749 histograms.ExpectBucketCount( 855 histograms.ExpectBucketCount(
750 SSLErrorHandler::GetHistogramNameForTesting(), 856 SSLErrorHandler::GetHistogramNameForTesting(),
751 SSLErrorHandler::SHOW_CAPTIVE_PORTAL_INTERSTITIAL_OVERRIDABLE, 1); 857 SSLErrorHandler::SHOW_CAPTIVE_PORTAL_INTERSTITIAL_OVERRIDABLE, 1);
752 histograms.ExpectBucketCount(SSLErrorHandler::GetHistogramNameForTesting(), 858 histograms.ExpectBucketCount(SSLErrorHandler::GetHistogramNameForTesting(),
753 SSLErrorHandler::CAPTIVE_PORTAL_CERT_FOUND, 1); 859 SSLErrorHandler::CAPTIVE_PORTAL_CERT_FOUND, 1);
754 } 860 }
755 861
756 // Tests that a certificate marked as a known captive portal certificate does 862 // Tests that a certificate marked as a known captive portal certificate does
757 // not cause the captive portal interstitial to be shown, if the feature is 863 // not cause the captive portal interstitial to be shown, if the feature is
758 // disabled. 864 // disabled.
759 TEST_F(SSLErrorHandlerNameMismatchTest, CaptivePortalCertificateList_Disabled) { 865 TEST_F(SSLErrorHandlerCaptivePortalCertListTest, Disabled) {
760 base::test::ScopedFeatureList scoped_feature_list; 866 SetFeatureEnabled(false);
761 scoped_feature_list.InitFromCommandLine(
762 std::string() /* enabled */,
763 "CaptivePortalCertificateList" /* disabled */);
764 867
765 base::HistogramTester histograms; 868 // Default error for SSLErrorHandlerNameMismatchTest tests is name mismatch.
766 869 TestNoCaptivePortalInterstitial();
767 EXPECT_FALSE(error_handler()->IsTimerRunningForTesting());
768 EXPECT_EQ(1u, ssl_info().public_key_hashes.size());
769
770 auto config_proto =
771 base::MakeUnique<chrome_browser_ssl::SSLErrorAssistantConfig>();
772 config_proto->add_captive_portal_cert()->set_sha256_hash(
773 "sha256/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
774 config_proto->add_captive_portal_cert()->set_sha256_hash(
775 ssl_info().public_key_hashes[0].ToString());
776 config_proto->add_captive_portal_cert()->set_sha256_hash(
777 "sha256/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
778 SSLErrorHandler::SetErrorAssistantProto(std::move(config_proto));
779
780 error_handler()->StartHandlingError();
781
782 // Timer should start since captive portal certificate list feature is
783 // disabled.
784 EXPECT_TRUE(error_handler()->IsTimerRunningForTesting());
785 EXPECT_TRUE(delegate()->captive_portal_checked());
786 EXPECT_FALSE(delegate()->ssl_interstitial_shown());
787 EXPECT_FALSE(delegate()->captive_portal_interstitial_shown());
788 EXPECT_FALSE(delegate()->suggested_url_checked());
789
790 // A buggy SSL error handler might have incorrectly started the timer. Run to
791 // completion to ensure the timer is expired.
792 base::RunLoop().RunUntilIdle();
793
794 EXPECT_FALSE(error_handler()->IsTimerRunningForTesting());
795 EXPECT_TRUE(delegate()->captive_portal_checked());
796 EXPECT_TRUE(delegate()->ssl_interstitial_shown());
797 EXPECT_FALSE(delegate()->captive_portal_interstitial_shown());
798 EXPECT_FALSE(delegate()->suggested_url_checked());
799
800 // Check that the histogram for the captive portal cert was recorded.
801 histograms.ExpectTotalCount(SSLErrorHandler::GetHistogramNameForTesting(), 2);
802 histograms.ExpectBucketCount(SSLErrorHandler::GetHistogramNameForTesting(),
803 SSLErrorHandler::HANDLE_ALL, 1);
804 histograms.ExpectBucketCount(
805 SSLErrorHandler::GetHistogramNameForTesting(),
806 SSLErrorHandler::SHOW_SSL_INTERSTITIAL_OVERRIDABLE, 1);
807 } 870 }
808 871
809 // Tests that an error other than name mismatch does not cause a captive portal 872 // Tests that an error other than name mismatch does not cause a captive portal
810 // interstitial to be shown, even if the certificate is marked as a known 873 // interstitial to be shown, even if the certificate is marked as a known
811 // captive portal certificate. 874 // captive portal certificate.
812 TEST_F(SSLErrorHandlerAuthorityInvalidTest, 875 TEST_F(SSLErrorHandlerCaptivePortalCertListTest, AuthorityInvalid) {
813 CaptivePortalCertificateList_ShouldShowGenericInterstitial) { 876 SetFeatureEnabled(true);
814 base::test::ScopedFeatureList scoped_feature_list;
815 scoped_feature_list.InitFromCommandLine(
816 "CaptivePortalCertificateList" /* enabled */,
817 std::string() /* disabled */);
818 877
819 base::HistogramTester histograms; 878 ResetErrorHandler(net::ERR_CERT_AUTHORITY_INVALID);
879 TestNoCaptivePortalInterstitial();
880 }
820 881
821 EXPECT_FALSE(error_handler()->IsTimerRunningForTesting()); 882 // Tests that an authority invalid error in addition to name mismatch error does
822 EXPECT_EQ(1u, ssl_info().public_key_hashes.size()); 883 // not cause a captive portal interstitial to be shown, even if the certificate
884 // is marked as a known captive portal certificate. The resulting error is
885 // authority-invalid.
886 TEST_F(SSLErrorHandlerCaptivePortalCertListTest,
887 NameMismatchAndAuthorityInvalid) {
888 SetFeatureEnabled(true);
823 889
824 auto config_proto = 890 // Sanity check that AUTHORITY_INVALID is seen as the net error.
estark 2017/02/28 21:12:06 same optional nit
meacer 2017/02/28 23:57:00 Done.
825 base::MakeUnique<chrome_browser_ssl::SSLErrorAssistantConfig>(); 891 const net::CertStatus cert_status =
826 config_proto->add_captive_portal_cert()->set_sha256_hash( 892 net::CERT_STATUS_COMMON_NAME_INVALID | net::CERT_STATUS_AUTHORITY_INVALID;
827 "sha256/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); 893 ASSERT_EQ(net::ERR_CERT_AUTHORITY_INVALID,
828 config_proto->add_captive_portal_cert()->set_sha256_hash( 894 net::MapCertStatusToNetError(cert_status));
829 ssl_info().public_key_hashes[0].ToString()); 895 ResetErrorHandler(cert_status);
830 config_proto->add_captive_portal_cert()->set_sha256_hash( 896 TestNoCaptivePortalInterstitial();
831 "sha256/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); 897 }
832 SSLErrorHandler::SetErrorAssistantProto(std::move(config_proto));
833 898
834 error_handler()->StartHandlingError(); 899 // Tests that another error in addition to name mismatch error does not cause a
900 // captive portal interstitial to be shown, even if the certificate is marked as
901 // a known captive portal certificate. Similar to
902 // NameMismatchAndAuthorityInvalid, except the resulting error is name mismatch.
903 TEST_F(SSLErrorHandlerCaptivePortalCertListTest, NameMismatchAndWeakKey) {
904 SetFeatureEnabled(true);
835 905
836 // Timer should start for captive portal detection. 906 // Sanity check that COMMON_NAME_INVALID is seen as the net error, since the
estark 2017/02/28 21:12:06 ditto
meacer 2017/02/28 23:57:01 Done.
837 EXPECT_TRUE(error_handler()->IsTimerRunningForTesting()); 907 // test is designed to verify that SSLErrorHandler notices other errors in the
838 EXPECT_TRUE(delegate()->captive_portal_checked()); 908 // CertStatus even when COMMON_NAME_INVALID is the net error.
839 EXPECT_FALSE(delegate()->ssl_interstitial_shown()); 909 const net::CertStatus cert_status =
840 EXPECT_FALSE(delegate()->captive_portal_interstitial_shown()); 910 net::CERT_STATUS_COMMON_NAME_INVALID | net::CERT_STATUS_WEAK_KEY;
841 EXPECT_FALSE(delegate()->suggested_url_checked()); 911 ASSERT_EQ(net::ERR_CERT_COMMON_NAME_INVALID,
912 net::MapCertStatusToNetError(cert_status));
913 ResetErrorHandler(cert_status);
914 TestNoCaptivePortalInterstitial();
915 }
842 916
843 base::RunLoop().RunUntilIdle(); 917 #else
844 918
845 EXPECT_FALSE(error_handler()->IsTimerRunningForTesting()); 919 TEST_F(SSLErrorHandlerCaptivePortalCertListTest, DisabledByBuild) {
846 EXPECT_TRUE(delegate()->captive_portal_checked()); 920 SetFeatureEnabled(true);
847 EXPECT_TRUE(delegate()->ssl_interstitial_shown());
848 EXPECT_FALSE(delegate()->captive_portal_interstitial_shown());
849 EXPECT_FALSE(delegate()->suggested_url_checked());
850 921
851 // Check that the histogram for the captive portal cert was recorded. 922 // Default error for SSLErrorHandlerNameMismatchTest tests is name mismatch,
852 histograms.ExpectTotalCount(SSLErrorHandler::GetHistogramNameForTesting(), 2); 923 // but the feature is disabled by build so no captive portal interstitial will
853 histograms.ExpectBucketCount(SSLErrorHandler::GetHistogramNameForTesting(), 924 // be displayed.
854 SSLErrorHandler::HANDLE_ALL, 1); 925 TestNoCaptivePortalInterstitial();
855 histograms.ExpectBucketCount(
856 SSLErrorHandler::GetHistogramNameForTesting(),
857 SSLErrorHandler::SHOW_SSL_INTERSTITIAL_OVERRIDABLE, 1);
858 } 926 }
859 927
860 #endif // BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION) 928 #endif // BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION)
OLDNEW
« chrome/browser/ssl/ssl_browser_tests.cc ('K') | « chrome/browser/ssl/ssl_error_handler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698