OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/strings/stringprintf.h" | 5 #include "base/strings/stringprintf.h" |
6 #include "chrome/browser/browser_process.h" | 6 #include "chrome/browser/browser_process.h" |
7 #include "chrome/browser/chromeos/policy/affiliation_test_helper.h" | 7 #include "chrome/browser/chromeos/policy/affiliation_test_helper.h" |
8 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 8 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
9 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" | 9 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" |
10 #include "chrome/browser/chromeos/policy/stub_enterprise_install_attributes.h" | 10 #include "chrome/browser/chromeos/policy/stub_enterprise_install_attributes.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 policy::affiliation_test_helper:: | 68 policy::affiliation_test_helper:: |
69 AppendCommandLineSwitchesForLoginManager(command_line); | 69 AppendCommandLineSwitchesForLoginManager(command_line); |
70 } | 70 } |
71 | 71 |
72 void SetUpInProcessBrowserTestFixture() override { | 72 void SetUpInProcessBrowserTestFixture() override { |
73 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); | 73 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); |
74 | 74 |
75 chromeos::FakeSessionManagerClient* fake_session_manager_client = | 75 chromeos::FakeSessionManagerClient* fake_session_manager_client = |
76 new chromeos::FakeSessionManagerClient; | 76 new chromeos::FakeSessionManagerClient; |
77 chromeos::DBusThreadManager::GetSetterForTesting()->SetSessionManagerClient( | 77 chromeos::DBusThreadManager::GetSetterForTesting()->SetSessionManagerClient( |
78 scoped_ptr<chromeos::SessionManagerClient>( | 78 std::unique_ptr<chromeos::SessionManagerClient>( |
79 fake_session_manager_client)); | 79 fake_session_manager_client)); |
80 | 80 |
81 std::set<std::string> device_affiliation_ids; | 81 std::set<std::string> device_affiliation_ids; |
82 device_affiliation_ids.insert(kAffiliationID); | 82 device_affiliation_ids.insert(kAffiliationID); |
83 policy::affiliation_test_helper::SetDeviceAffiliationID( | 83 policy::affiliation_test_helper::SetDeviceAffiliationID( |
84 &test_helper_, fake_session_manager_client, device_affiliation_ids); | 84 &test_helper_, fake_session_manager_client, device_affiliation_ids); |
85 | 85 |
86 std::set<std::string> user_affiliation_ids; | 86 std::set<std::string> user_affiliation_ids; |
87 if (GetParam().affiliated_) { | 87 if (GetParam().affiliated_) { |
88 user_affiliation_ids.insert(kAffiliationID); | 88 user_affiliation_ids.insert(kAffiliationID); |
89 } else { | 89 } else { |
90 user_affiliation_ids.insert(kAnotherAffiliationID); | 90 user_affiliation_ids.insert(kAnotherAffiliationID); |
91 } | 91 } |
92 policy::UserPolicyBuilder user_policy; | 92 policy::UserPolicyBuilder user_policy; |
93 policy::affiliation_test_helper::SetUserAffiliationIDs( | 93 policy::affiliation_test_helper::SetUserAffiliationIDs( |
94 &user_policy, fake_session_manager_client, | 94 &user_policy, fake_session_manager_client, |
95 affiliated_account_id_.GetUserEmail(), user_affiliation_ids); | 95 affiliated_account_id_.GetUserEmail(), user_affiliation_ids); |
96 | 96 |
97 // Set up fake install attributes. | 97 // Set up fake install attributes. |
98 scoped_ptr<policy::StubEnterpriseInstallAttributes> attributes( | 98 std::unique_ptr<policy::StubEnterpriseInstallAttributes> attributes( |
99 new policy::StubEnterpriseInstallAttributes()); | 99 new policy::StubEnterpriseInstallAttributes()); |
100 | 100 |
101 attributes->SetRegistrationUser(affiliated_account_id_.GetUserEmail()); | 101 attributes->SetRegistrationUser(affiliated_account_id_.GetUserEmail()); |
102 policy::BrowserPolicyConnectorChromeOS::SetInstallAttributesForTesting( | 102 policy::BrowserPolicyConnectorChromeOS::SetInstallAttributesForTesting( |
103 attributes.release()); | 103 attributes.release()); |
104 | 104 |
105 test_helper_.InstallOwnerKey(); | 105 test_helper_.InstallOwnerKey(); |
106 // Init the device policy. | 106 // Init the device policy. |
107 policy::DevicePolicyBuilder* device_policy = test_helper_.device_policy(); | 107 policy::DevicePolicyBuilder* device_policy = test_helper_.device_policy(); |
108 device_policy->SetDefaultSigningKey(); | 108 device_policy->SetDefaultSigningKey(); |
(...skipping 24 matching lines...) Expand all Loading... |
133 | 133 |
134 void SetPolicy() { | 134 void SetPolicy() { |
135 // Extensions that are force-installed come from an update URL, which | 135 // Extensions that are force-installed come from an update URL, which |
136 // defaults to the webstore. Use a mock URL for this test with an update | 136 // defaults to the webstore. Use a mock URL for this test with an update |
137 // manifest that includes the crx file of the test extension. | 137 // manifest that includes the crx file of the test extension. |
138 base::FilePath update_manifest_path = | 138 base::FilePath update_manifest_path = |
139 base::FilePath(kTestExtensionDir).Append(kUpdateManifestFileName); | 139 base::FilePath(kTestExtensionDir).Append(kUpdateManifestFileName); |
140 GURL update_manifest_url(net::URLRequestMockHTTPJob::GetMockUrl( | 140 GURL update_manifest_url(net::URLRequestMockHTTPJob::GetMockUrl( |
141 update_manifest_path.MaybeAsASCII())); | 141 update_manifest_path.MaybeAsASCII())); |
142 | 142 |
143 scoped_ptr<base::ListValue> forcelist(new base::ListValue); | 143 std::unique_ptr<base::ListValue> forcelist(new base::ListValue); |
144 forcelist->AppendString(base::StringPrintf( | 144 forcelist->AppendString(base::StringPrintf( |
145 "%s;%s", kTestExtensionID, update_manifest_url.spec().c_str())); | 145 "%s;%s", kTestExtensionID, update_manifest_url.spec().c_str())); |
146 | 146 |
147 policy::PolicyMap policy; | 147 policy::PolicyMap policy; |
148 policy.Set(policy::key::kExtensionInstallForcelist, | 148 policy.Set(policy::key::kExtensionInstallForcelist, |
149 policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_MACHINE, | 149 policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_MACHINE, |
150 policy::POLICY_SOURCE_CLOUD, forcelist.release(), nullptr); | 150 policy::POLICY_SOURCE_CLOUD, forcelist.release(), nullptr); |
151 | 151 |
152 // Set the policy and wait until the extension is installed. | 152 // Set the policy and wait until the extension is installed. |
153 extensions::TestExtensionRegistryObserver observer( | 153 extensions::TestExtensionRegistryObserver observer( |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 "'enterprise.deviceAttributes' is not allowed for specified install " | 234 "'enterprise.deviceAttributes' is not allowed for specified install " |
235 "location.", | 235 "location.", |
236 extension->install_warnings()[0].message); | 236 extension->install_warnings()[0].message); |
237 } | 237 } |
238 | 238 |
239 // Both cases of affiliated and non-affiliated on the device user are tested. | 239 // Both cases of affiliated and non-affiliated on the device user are tested. |
240 INSTANTIATE_TEST_CASE_P(AffiliationCheck, | 240 INSTANTIATE_TEST_CASE_P(AffiliationCheck, |
241 EnterpriseDeviceAttributesTest, | 241 EnterpriseDeviceAttributesTest, |
242 ::testing::Values(Params(true), Params(false))); | 242 ::testing::Values(Params(true), Params(false))); |
243 } // namespace extensions | 243 } // namespace extensions |
OLD | NEW |