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 <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/test/simple_test_clock.h" | 9 #include "base/test/simple_test_clock.h" |
10 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 10 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
11 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 11 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
12 #include "chrome/browser/browsing_data/browsing_data_remover_test_util.h" | 12 #include "chrome/browser/browsing_data/browsing_data_remover_test_util.h" |
13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h" | 14 #include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h" |
willchan no longer on Chromium
2014/08/20 22:17:22
Goes first: http://google-styleguide.googlecode.co
jww
2014/08/22 00:54:17
Done.
| |
15 #include "chrome/browser/ssl/chrome_ssl_host_state_delegate_factory.h" | 15 #include "chrome/browser/ssl/chrome_ssl_host_state_delegate_factory.h" |
16 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
17 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 17 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
18 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
19 #include "chrome/test/base/in_process_browser_test.h" | 19 #include "chrome/test/base/in_process_browser_test.h" |
20 #include "content/public/browser/ssl_host_state_delegate.h" | 20 #include "content/public/browser/ssl_host_state_delegate.h" |
21 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
22 #include "content/public/test/browser_test_utils.h" | 22 #include "content/public/test/browser_test_utils.h" |
23 #include "net/base/test_data_directory.h" | 23 #include "net/base/test_data_directory.h" |
24 #include "net/test/cert_test_util.h" | 24 #include "net/test/cert_test_util.h" |
25 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
26 | 26 |
27 namespace { | 27 namespace { |
28 | 28 |
29 const char kGoogleCertFile[] = "google.single.der"; | 29 const char kGoogleCertFile[] = "google.single.der"; |
30 | 30 |
31 const char kWWWGoogleHost[] = "www.google.com"; | 31 const char kWWWGoogleHost[] = "www.google.com"; |
32 const char kGoogleHost[] = "google.com"; | 32 const char kGoogleHost[] = "google.com"; |
33 const char kExampleHost[] = "example.com"; | 33 const char kExampleHost[] = "example.com"; |
34 | 34 |
35 const char* kForgetAtSessionEnd = "-1"; | 35 const char* kForgetAtSessionEnd = "-1"; |
willchan no longer on Chromium
2014/08/20 22:17:22
These 3 aren't constants. They're non-const pointe
jww
2014/08/22 00:54:17
Done.
| |
36 const char* kForgetInstantly = "0"; | 36 const char* kForgetInstantly = "0"; |
37 const char* kDeltaSecondsString = "86400"; | 37 const char* kDeltaSecondsString = "86400"; |
38 const uint64_t kDeltaOneDayInSeconds = UINT64_C(86400); | 38 const uint64_t kDeltaOneDayInSeconds = UINT64_C(86400); |
39 | 39 |
40 scoped_refptr<net::X509Certificate> GetGoogleCert() { | 40 scoped_refptr<net::X509Certificate> GetGoogleCert() { |
41 return net::ImportCertFromFile(net::GetTestCertsDirectory(), kGoogleCertFile); | 41 return net::ImportCertFromFile(net::GetTestCertsDirectory(), kGoogleCertFile); |
42 } | 42 } |
43 | 43 |
44 } // namespace | 44 } // namespace |
45 | 45 |
46 class ChromeSSLHostStateDelegateTest : public InProcessBrowserTest {}; | 46 class ChromeSSLHostStateDelegateTest : public InProcessBrowserTest {}; |
47 | 47 |
48 // ChromeSSLHostStateDelegateTest tests basic unit test functionality of the | 48 // ChromeSSLHostStateDelegateTest tests basic unit test functionality of the |
49 // SSLHostStateDelegate class. For example, tests that if a certificate is | 49 // SSLHostStateDelegate class. For example, tests that if a certificate is |
50 // accepted, then it is added to queryable, and if it is revoked, it is not | 50 // accepted, then it is added to queryable, and if it is revoked, it is not |
51 // queryable. Even though it is effectively a unit test, in needs to be an | 51 // queryable. Even though it is effectively a unit test, in needs to be an |
52 // InProcessBrowserTest because the actual functionality is provided by | 52 // InProcessBrowserTest because the actual functionality is provided by |
willchan no longer on Chromium
2014/08/20 22:17:22
Not for readability, but would you be able to writ
jww
2014/08/22 00:54:17
Probably not because the implementation relies on
| |
53 // ChromeSSLHostStateDelegate which is provided per-profile. | 53 // ChromeSSLHostStateDelegate which is provided per-profile. |
54 // | 54 // |
55 // QueryPolicy unit tests the expected behavior of calling QueryPolicy on the | 55 // QueryPolicy unit tests the expected behavior of calling QueryPolicy on the |
56 // SSLHostStateDelegate class after various SSL cert decisions have been made. | 56 // SSLHostStateDelegate class after various SSL cert decisions have been made. |
57 IN_PROC_BROWSER_TEST_F(ChromeSSLHostStateDelegateTest, QueryPolicy) { | 57 IN_PROC_BROWSER_TEST_F(ChromeSSLHostStateDelegateTest, QueryPolicy) { |
58 scoped_refptr<net::X509Certificate> google_cert = GetGoogleCert(); | 58 scoped_refptr<net::X509Certificate> google_cert = GetGoogleCert(); |
59 content::WebContents* tab = | 59 content::WebContents* tab = |
60 browser()->tab_strip_model()->GetActiveWebContents(); | 60 browser()->tab_strip_model()->GetActiveWebContents(); |
61 Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext()); | 61 Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext()); |
62 content::SSLHostStateDelegate* state = profile->GetSSLHostStateDelegate(); | 62 content::SSLHostStateDelegate* state = profile->GetSSLHostStateDelegate(); |
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
575 // worth of browsing history and verify that the exception has been deleted. | 575 // worth of browsing history and verify that the exception has been deleted. |
576 state->AllowCert( | 576 state->AllowCert( |
577 kGoogleHost, google_cert.get(), net::CERT_STATUS_DATE_INVALID); | 577 kGoogleHost, google_cert.get(), net::CERT_STATUS_DATE_INVALID); |
578 RemoveAndWait(profile); | 578 RemoveAndWait(profile); |
579 EXPECT_EQ(net::CertPolicy::UNKNOWN, | 579 EXPECT_EQ(net::CertPolicy::UNKNOWN, |
580 state->QueryPolicy(kGoogleHost, | 580 state->QueryPolicy(kGoogleHost, |
581 google_cert.get(), | 581 google_cert.get(), |
582 net::CERT_STATUS_DATE_INVALID, | 582 net::CERT_STATUS_DATE_INVALID, |
583 &unused_value)); | 583 &unused_value)); |
584 } | 584 } |
585 | |
OLD | NEW |