OLD | NEW |
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/chrome_ssl_host_state_delegate.h" | 5 #include "chrome/browser/ssl/chrome_ssl_host_state_delegate.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/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 *google_cert.get(), | 291 *google_cert.get(), |
292 net::CERT_STATUS_DATE_INVALID, | 292 net::CERT_STATUS_DATE_INVALID, |
293 &expired_previous_decision)); | 293 &expired_previous_decision)); |
294 EXPECT_FALSE(expired_previous_decision); | 294 EXPECT_FALSE(expired_previous_decision); |
295 } | 295 } |
296 | 296 |
297 // Tests the basic behavior of cert memory in incognito. | 297 // Tests the basic behavior of cert memory in incognito. |
298 class IncognitoSSLHostStateDelegateTest | 298 class IncognitoSSLHostStateDelegateTest |
299 : public ChromeSSLHostStateDelegateTest { | 299 : public ChromeSSLHostStateDelegateTest { |
300 protected: | 300 protected: |
301 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 301 virtual void SetUpCommandLine(CommandLine* command_line) override { |
302 ChromeSSLHostStateDelegateTest::SetUpCommandLine(command_line); | 302 ChromeSSLHostStateDelegateTest::SetUpCommandLine(command_line); |
303 command_line->AppendSwitchASCII(switches::kRememberCertErrorDecisions, | 303 command_line->AppendSwitchASCII(switches::kRememberCertErrorDecisions, |
304 kDeltaSecondsString); | 304 kDeltaSecondsString); |
305 } | 305 } |
306 }; | 306 }; |
307 | 307 |
308 IN_PROC_BROWSER_TEST_F(IncognitoSSLHostStateDelegateTest, PRE_AfterRestart) { | 308 IN_PROC_BROWSER_TEST_F(IncognitoSSLHostStateDelegateTest, PRE_AfterRestart) { |
309 scoped_refptr<net::X509Certificate> google_cert = GetGoogleCert(); | 309 scoped_refptr<net::X509Certificate> google_cert = GetGoogleCert(); |
310 content::WebContents* tab = | 310 content::WebContents* tab = |
311 browser()->tab_strip_model()->GetActiveWebContents(); | 311 browser()->tab_strip_model()->GetActiveWebContents(); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 incognito_state->QueryPolicy(kGoogleHost, | 372 incognito_state->QueryPolicy(kGoogleHost, |
373 *google_cert.get(), | 373 *google_cert.get(), |
374 net::CERT_STATUS_COMMON_NAME_INVALID, | 374 net::CERT_STATUS_COMMON_NAME_INVALID, |
375 &unused_value)); | 375 &unused_value)); |
376 } | 376 } |
377 | 377 |
378 // Tests to make sure that if the remember value is set to -1, any decisions | 378 // Tests to make sure that if the remember value is set to -1, any decisions |
379 // won't be remembered over a restart. | 379 // won't be remembered over a restart. |
380 class ForGetSSLHostStateDelegateTest : public ChromeSSLHostStateDelegateTest { | 380 class ForGetSSLHostStateDelegateTest : public ChromeSSLHostStateDelegateTest { |
381 protected: | 381 protected: |
382 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 382 virtual void SetUpCommandLine(CommandLine* command_line) override { |
383 ChromeSSLHostStateDelegateTest::SetUpCommandLine(command_line); | 383 ChromeSSLHostStateDelegateTest::SetUpCommandLine(command_line); |
384 command_line->AppendSwitchASCII(switches::kRememberCertErrorDecisions, | 384 command_line->AppendSwitchASCII(switches::kRememberCertErrorDecisions, |
385 kForgetAtSessionEnd); | 385 kForgetAtSessionEnd); |
386 } | 386 } |
387 }; | 387 }; |
388 | 388 |
389 IN_PROC_BROWSER_TEST_F(ForGetSSLHostStateDelegateTest, PRE_AfterRestart) { | 389 IN_PROC_BROWSER_TEST_F(ForGetSSLHostStateDelegateTest, PRE_AfterRestart) { |
390 scoped_refptr<net::X509Certificate> google_cert = GetGoogleCert(); | 390 scoped_refptr<net::X509Certificate> google_cert = GetGoogleCert(); |
391 content::WebContents* tab = | 391 content::WebContents* tab = |
392 browser()->tab_strip_model()->GetActiveWebContents(); | 392 browser()->tab_strip_model()->GetActiveWebContents(); |
(...skipping 25 matching lines...) Expand all Loading... |
418 *google_cert.get(), | 418 *google_cert.get(), |
419 net::CERT_STATUS_DATE_INVALID, | 419 net::CERT_STATUS_DATE_INVALID, |
420 &unused_value)); | 420 &unused_value)); |
421 } | 421 } |
422 | 422 |
423 // Tests to make sure that if the remember value is set to 0, any decisions made | 423 // Tests to make sure that if the remember value is set to 0, any decisions made |
424 // will be forgetten immediately. | 424 // will be forgetten immediately. |
425 class ForgetInstantlySSLHostStateDelegateTest | 425 class ForgetInstantlySSLHostStateDelegateTest |
426 : public ChromeSSLHostStateDelegateTest { | 426 : public ChromeSSLHostStateDelegateTest { |
427 protected: | 427 protected: |
428 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 428 virtual void SetUpCommandLine(CommandLine* command_line) override { |
429 ChromeSSLHostStateDelegateTest::SetUpCommandLine(command_line); | 429 ChromeSSLHostStateDelegateTest::SetUpCommandLine(command_line); |
430 command_line->AppendSwitchASCII(switches::kRememberCertErrorDecisions, | 430 command_line->AppendSwitchASCII(switches::kRememberCertErrorDecisions, |
431 kForgetInstantly); | 431 kForgetInstantly); |
432 } | 432 } |
433 }; | 433 }; |
434 | 434 |
435 IN_PROC_BROWSER_TEST_F(ForgetInstantlySSLHostStateDelegateTest, | 435 IN_PROC_BROWSER_TEST_F(ForgetInstantlySSLHostStateDelegateTest, |
436 MakeAndForgetException) { | 436 MakeAndForgetException) { |
437 scoped_refptr<net::X509Certificate> google_cert = GetGoogleCert(); | 437 scoped_refptr<net::X509Certificate> google_cert = GetGoogleCert(); |
438 content::WebContents* tab = | 438 content::WebContents* tab = |
(...skipping 19 matching lines...) Expand all Loading... |
458 *google_cert.get(), | 458 *google_cert.get(), |
459 net::CERT_STATUS_DATE_INVALID, | 459 net::CERT_STATUS_DATE_INVALID, |
460 &unused_value)); | 460 &unused_value)); |
461 } | 461 } |
462 | 462 |
463 // Tests to make sure that if the remember value is set to a non-zero value, | 463 // Tests to make sure that if the remember value is set to a non-zero value, |
464 // any decisions will be remembered over a restart, but only for the length | 464 // any decisions will be remembered over a restart, but only for the length |
465 // specified. | 465 // specified. |
466 class RememberSSLHostStateDelegateTest : public ChromeSSLHostStateDelegateTest { | 466 class RememberSSLHostStateDelegateTest : public ChromeSSLHostStateDelegateTest { |
467 protected: | 467 protected: |
468 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 468 virtual void SetUpCommandLine(CommandLine* command_line) override { |
469 ChromeSSLHostStateDelegateTest::SetUpCommandLine(command_line); | 469 ChromeSSLHostStateDelegateTest::SetUpCommandLine(command_line); |
470 command_line->AppendSwitchASCII(switches::kRememberCertErrorDecisions, | 470 command_line->AppendSwitchASCII(switches::kRememberCertErrorDecisions, |
471 kDeltaSecondsString); | 471 kDeltaSecondsString); |
472 } | 472 } |
473 }; | 473 }; |
474 | 474 |
475 IN_PROC_BROWSER_TEST_F(RememberSSLHostStateDelegateTest, PRE_AfterRestart) { | 475 IN_PROC_BROWSER_TEST_F(RememberSSLHostStateDelegateTest, PRE_AfterRestart) { |
476 scoped_refptr<net::X509Certificate> google_cert = GetGoogleCert(); | 476 scoped_refptr<net::X509Certificate> google_cert = GetGoogleCert(); |
477 content::WebContents* tab = | 477 content::WebContents* tab = |
478 browser()->tab_strip_model()->GetActiveWebContents(); | 478 browser()->tab_strip_model()->GetActiveWebContents(); |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 // worth of browsing history and verify that the exception has been deleted. | 618 // worth of browsing history and verify that the exception has been deleted. |
619 state->AllowCert( | 619 state->AllowCert( |
620 kGoogleHost, *google_cert.get(), net::CERT_STATUS_DATE_INVALID); | 620 kGoogleHost, *google_cert.get(), net::CERT_STATUS_DATE_INVALID); |
621 RemoveAndWait(profile); | 621 RemoveAndWait(profile); |
622 EXPECT_EQ(content::SSLHostStateDelegate::DENIED, | 622 EXPECT_EQ(content::SSLHostStateDelegate::DENIED, |
623 state->QueryPolicy(kGoogleHost, | 623 state->QueryPolicy(kGoogleHost, |
624 *google_cert.get(), | 624 *google_cert.get(), |
625 net::CERT_STATUS_DATE_INVALID, | 625 net::CERT_STATUS_DATE_INVALID, |
626 &unused_value)); | 626 &unused_value)); |
627 } | 627 } |
OLD | NEW |