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/policy/browser_policy_connector.h" | 8 #include "chrome/browser/policy/browser_policy_connector.h" |
9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
10 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 10 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 39 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
40 #if defined(OS_CHROMEOS) | 40 #if defined(OS_CHROMEOS) |
41 device_policy_test_helper_.MarkAsEnterpriseOwned(); | 41 device_policy_test_helper_.MarkAsEnterpriseOwned(); |
42 #endif | 42 #endif |
43 // Setup the policy provider for injecting certs through ONC policy. | 43 // Setup the policy provider for injecting certs through ONC policy. |
44 EXPECT_CALL(provider_, IsInitializationComplete(_)) | 44 EXPECT_CALL(provider_, IsInitializationComplete(_)) |
45 .WillRepeatedly(Return(true)); | 45 .WillRepeatedly(Return(true)); |
46 policy::BrowserPolicyConnector::SetPolicyProviderForTesting(&provider_); | 46 policy::BrowserPolicyConnector::SetPolicyProviderForTesting(&provider_); |
47 } | 47 } |
48 | 48 |
| 49 void SetUpOnIOThread() { |
| 50 #if defined(OS_CHROMEOS) |
| 51 test_nssdb_.reset(new crypto::ScopedTestNSSDB()); |
| 52 #endif |
| 53 } |
| 54 |
| 55 void TearDownOnIOThread() { |
| 56 #if defined(OS_CHROMEOS) |
| 57 test_nssdb_.reset(); |
| 58 #endif |
| 59 } |
| 60 |
49 virtual void SetUpOnMainThread() OVERRIDE { | 61 virtual void SetUpOnMainThread() OVERRIDE { |
| 62 content::BrowserThread::PostTask( |
| 63 content::BrowserThread::IO, |
| 64 FROM_HERE, |
| 65 base::Bind(&CertificateManagerBrowserTest::SetUpOnIOThread, this)); |
| 66 content::RunAllPendingInMessageLoop(content::BrowserThread::IO); |
| 67 |
50 content::RunAllPendingInMessageLoop(); | 68 content::RunAllPendingInMessageLoop(); |
51 } | 69 } |
52 | 70 |
| 71 virtual void CleanUpOnMainThread() OVERRIDE { |
| 72 content::BrowserThread::PostTask( |
| 73 content::BrowserThread::IO, |
| 74 FROM_HERE, |
| 75 base::Bind(&CertificateManagerBrowserTest::TearDownOnIOThread, this)); |
| 76 content::RunAllPendingInMessageLoop(content::BrowserThread::IO); |
| 77 } |
| 78 |
53 #if defined(OS_CHROMEOS) | 79 #if defined(OS_CHROMEOS) |
54 void LoadONCPolicy(const std::string& filename) { | 80 void LoadONCPolicy(const std::string& filename) { |
55 const std::string& user_policy_blob = | 81 const std::string& user_policy_blob = |
56 chromeos::onc::test_utils::ReadTestData(filename); | 82 chromeos::onc::test_utils::ReadTestData(filename); |
57 policy::PolicyMap policy; | 83 policy::PolicyMap policy; |
58 policy.Set(policy::key::kOpenNetworkConfiguration, | 84 policy.Set(policy::key::kOpenNetworkConfiguration, |
59 policy::POLICY_LEVEL_MANDATORY, | 85 policy::POLICY_LEVEL_MANDATORY, |
60 policy::POLICY_SCOPE_USER, | 86 policy::POLICY_SCOPE_USER, |
61 Value::CreateStringValue(user_policy_blob), | 87 Value::CreateStringValue(user_policy_blob), |
62 NULL); | 88 NULL); |
(...skipping 16 matching lines...) Expand all Loading... |
79 "//div[@id='settings']/iframe", | 105 "//div[@id='settings']/iframe", |
80 "window.domAutomationController.send(" | 106 "window.domAutomationController.send(" |
81 " !!document.querySelector('" + selector + "'));", | 107 " !!document.querySelector('" + selector + "'));", |
82 &result)); | 108 &result)); |
83 return result; | 109 return result; |
84 } | 110 } |
85 | 111 |
86 policy::MockConfigurationPolicyProvider provider_; | 112 policy::MockConfigurationPolicyProvider provider_; |
87 #if defined(OS_CHROMEOS) | 113 #if defined(OS_CHROMEOS) |
88 policy::DevicePolicyCrosTestHelper device_policy_test_helper_; | 114 policy::DevicePolicyCrosTestHelper device_policy_test_helper_; |
89 crypto::ScopedTestNSSDB test_nssdb_; | 115 scoped_ptr<crypto::ScopedTestNSSDB> test_nssdb_; |
90 #endif | 116 #endif |
91 }; | 117 }; |
92 | 118 |
93 #if defined(OS_CHROMEOS) | 119 #if defined(OS_CHROMEOS) |
94 // Ensure policy-installed certificates without web trust do not display | 120 // Ensure policy-installed certificates without web trust do not display |
95 // the managed setting indicator (only on Chrome OS). | 121 // the managed setting indicator (only on Chrome OS). |
96 IN_PROC_BROWSER_TEST_F(CertificateManagerBrowserTest, | 122 IN_PROC_BROWSER_TEST_F(CertificateManagerBrowserTest, |
97 PolicyCertificateWithoutWebTrustHasNoIndicator) { | 123 PolicyCertificateWithoutWebTrustHasNoIndicator) { |
98 LoadONCPolicy("certificate-authority.onc"); | 124 LoadONCPolicy("certificate-authority.onc"); |
99 NavigateToSettings(); | 125 NavigateToSettings(); |
100 ClickElement("#certificatesManageButton"); | 126 ClickElement("#certificatesManageButton"); |
101 ClickElement("#ca-certs-nav-tab"); | 127 ClickElement("#ca-certs-nav-tab"); |
102 EXPECT_FALSE(HasElement(".cert-policy")); | 128 EXPECT_FALSE(HasElement(".cert-policy")); |
103 } | 129 } |
104 #endif | 130 #endif |
105 | 131 |
106 #if defined(OS_CHROMEOS) | 132 #if defined(OS_CHROMEOS) |
107 // Ensure policy-installed certificates with web trust display the | 133 // Ensure policy-installed certificates with web trust display the |
108 // managed setting indicator (only on Chrome OS). | 134 // managed setting indicator (only on Chrome OS). |
109 IN_PROC_BROWSER_TEST_F(CertificateManagerBrowserTest, | 135 IN_PROC_BROWSER_TEST_F(CertificateManagerBrowserTest, |
110 PolicyCertificateWithWebTrustHasIndicator) { | 136 PolicyCertificateWithWebTrustHasIndicator) { |
111 LoadONCPolicy("certificate-web-authority.onc"); | 137 LoadONCPolicy("certificate-web-authority.onc"); |
112 NavigateToSettings(); | 138 NavigateToSettings(); |
113 ClickElement("#certificatesManageButton"); | 139 ClickElement("#certificatesManageButton"); |
114 ClickElement("#ca-certs-nav-tab"); | 140 ClickElement("#ca-certs-nav-tab"); |
115 EXPECT_TRUE(HasElement(".cert-policy")); | 141 EXPECT_TRUE(HasElement(".cert-policy")); |
116 } | 142 } |
117 #endif | 143 #endif |
OLD | NEW |