OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/callback.h" | 5 #include "base/callback.h" |
6 #include "base/values.h" | 6 #include "base/values.h" |
7 #include "chrome/browser/browser_process.h" | 7 #include "chrome/browser/browser_process.h" |
8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
9 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 9 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
10 #include "chrome/browser/ui/webui/options/options_ui_browsertest.h" | 10 #include "chrome/browser/ui/webui/options/options_ui_browsertest.h" |
11 #include "components/policy/core/browser/browser_policy_connector.h" | 11 #include "components/policy/core/browser/browser_policy_connector.h" |
12 #include "components/policy/core/common/external_data_fetcher.h" | 12 #include "components/policy/core/common/external_data_fetcher.h" |
13 #include "components/policy/core/common/mock_configuration_policy_provider.h" | 13 #include "components/policy/core/common/mock_configuration_policy_provider.h" |
14 #include "components/policy/core/common/policy_map.h" | 14 #include "components/policy/core/common/policy_map.h" |
15 #include "components/policy/core/common/policy_types.h" | 15 #include "components/policy/core/common/policy_types.h" |
16 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
17 #include "content/public/test/browser_test_utils.h" | 17 #include "content/public/test/browser_test_utils.h" |
18 #include "content/public/test/test_utils.h" | 18 #include "content/public/test/test_utils.h" |
19 #include "policy/policy_constants.h" | 19 #include "policy/policy_constants.h" |
20 #include "testing/gmock/include/gmock/gmock.h" | 20 #include "testing/gmock/include/gmock/gmock.h" |
21 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
22 | 22 |
23 #if defined(OS_CHROMEOS) | 23 #if defined(OS_CHROMEOS) |
24 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" | 24 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" |
25 #include "chrome/browser/chromeos/policy/network_configuration_updater.h" | 25 #include "chrome/browser/chromeos/policy/user_network_configuration_updater.h" |
| 26 #include "chrome/browser/chromeos/policy/user_network_configuration_updater_fact
ory.h" |
| 27 #include "chrome/browser/net/nss_context.h" |
26 #include "chromeos/network/onc/onc_test_utils.h" | 28 #include "chromeos/network/onc/onc_test_utils.h" |
27 #include "crypto/nss_util.h" | 29 #include "crypto/nss_util.h" |
28 #endif | 30 #endif |
29 | 31 |
30 using testing::Return; | 32 using testing::Return; |
31 using testing::_; | 33 using testing::_; |
32 | 34 |
33 class CertificateManagerBrowserTest : public options::OptionsUIBrowserTest { | 35 class CertificateManagerBrowserTest : public options::OptionsUIBrowserTest { |
34 public: | 36 public: |
35 CertificateManagerBrowserTest() {} | 37 CertificateManagerBrowserTest() {} |
(...skipping 20 matching lines...) Expand all Loading... |
56 #if defined(OS_CHROMEOS) | 58 #if defined(OS_CHROMEOS) |
57 test_nssdb_.reset(); | 59 test_nssdb_.reset(); |
58 #endif | 60 #endif |
59 } | 61 } |
60 | 62 |
61 virtual void SetUpOnMainThread() OVERRIDE { | 63 virtual void SetUpOnMainThread() OVERRIDE { |
62 content::BrowserThread::PostTask( | 64 content::BrowserThread::PostTask( |
63 content::BrowserThread::IO, | 65 content::BrowserThread::IO, |
64 FROM_HERE, | 66 FROM_HERE, |
65 base::Bind(&CertificateManagerBrowserTest::SetUpOnIOThread, this)); | 67 base::Bind(&CertificateManagerBrowserTest::SetUpOnIOThread, this)); |
| 68 |
| 69 #if defined(OS_CHROMEOS) |
| 70 // Certificates will fail to be imported if the network configuration |
| 71 // updater does not have the cert database set. |
| 72 GetNSSCertDatabaseForProfile( |
| 73 browser()->profile(), |
| 74 base::Bind( |
| 75 &CertificateManagerBrowserTest::SetNetworkConfigurationUpdaterDB, |
| 76 base::Unretained(this))); |
| 77 #endif |
| 78 |
66 content::RunAllPendingInMessageLoop(content::BrowserThread::IO); | 79 content::RunAllPendingInMessageLoop(content::BrowserThread::IO); |
67 | 80 |
68 content::RunAllPendingInMessageLoop(); | 81 content::RunAllPendingInMessageLoop(); |
69 } | 82 } |
70 | 83 |
71 virtual void CleanUpOnMainThread() OVERRIDE { | 84 virtual void CleanUpOnMainThread() OVERRIDE { |
72 content::BrowserThread::PostTask( | 85 content::BrowserThread::PostTask( |
73 content::BrowserThread::IO, | 86 content::BrowserThread::IO, |
74 FROM_HERE, | 87 FROM_HERE, |
75 base::Bind(&CertificateManagerBrowserTest::TearDownOnIOThread, this)); | 88 base::Bind(&CertificateManagerBrowserTest::TearDownOnIOThread, this)); |
76 content::RunAllPendingInMessageLoop(content::BrowserThread::IO); | 89 content::RunAllPendingInMessageLoop(content::BrowserThread::IO); |
77 } | 90 } |
78 | 91 |
79 #if defined(OS_CHROMEOS) | 92 #if defined(OS_CHROMEOS) |
| 93 void SetNetworkConfigurationUpdaterDB(net::NSSCertDatabase* database) { |
| 94 policy::UserNetworkConfigurationUpdaterFactory::GetForProfile( |
| 95 browser()->profile())->SetCertDatabase(database); |
| 96 } |
| 97 |
80 void LoadONCPolicy(const std::string& filename) { | 98 void LoadONCPolicy(const std::string& filename) { |
81 const std::string& user_policy_blob = | 99 const std::string& user_policy_blob = |
82 chromeos::onc::test_utils::ReadTestData(filename); | 100 chromeos::onc::test_utils::ReadTestData(filename); |
83 policy::PolicyMap policy; | 101 policy::PolicyMap policy; |
84 policy.Set(policy::key::kOpenNetworkConfiguration, | 102 policy.Set(policy::key::kOpenNetworkConfiguration, |
85 policy::POLICY_LEVEL_MANDATORY, | 103 policy::POLICY_LEVEL_MANDATORY, |
86 policy::POLICY_SCOPE_USER, | 104 policy::POLICY_SCOPE_USER, |
87 base::Value::CreateStringValue(user_policy_blob), | 105 base::Value::CreateStringValue(user_policy_blob), |
88 NULL); | 106 NULL); |
89 provider_.UpdateChromePolicy(policy); | 107 provider_.UpdateChromePolicy(policy); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 #endif | 171 #endif |
154 IN_PROC_BROWSER_TEST_F(CertificateManagerBrowserTest, | 172 IN_PROC_BROWSER_TEST_F(CertificateManagerBrowserTest, |
155 MAYBE_PolicyCertificateWithWebTrustHasIndicator) { | 173 MAYBE_PolicyCertificateWithWebTrustHasIndicator) { |
156 LoadONCPolicy("certificate-web-authority.onc"); | 174 LoadONCPolicy("certificate-web-authority.onc"); |
157 NavigateToSettings(); | 175 NavigateToSettings(); |
158 ClickElement("#certificatesManageButton"); | 176 ClickElement("#certificatesManageButton"); |
159 ClickElement("#ca-certs-nav-tab"); | 177 ClickElement("#ca-certs-nav-tab"); |
160 EXPECT_TRUE(HasElement(".cert-policy")); | 178 EXPECT_TRUE(HasElement(".cert-policy")); |
161 } | 179 } |
162 #endif | 180 #endif |
OLD | NEW |