| 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/memory/ptr_util.h" |
| 5 #include "base/strings/stringprintf.h" | 6 #include "base/strings/stringprintf.h" |
| 6 #include "chrome/browser/browser_process.h" | 7 #include "chrome/browser/browser_process.h" |
| 7 #include "chrome/browser/chromeos/policy/affiliation_test_helper.h" | 8 #include "chrome/browser/chromeos/policy/affiliation_test_helper.h" |
| 8 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 9 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
| 9 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" | 10 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" |
| 10 #include "chrome/browser/chromeos/policy/stub_enterprise_install_attributes.h" | 11 #include "chrome/browser/chromeos/settings/stub_install_attributes.h" |
| 11 #include "chrome/browser/extensions/extension_apitest.h" | 12 #include "chrome/browser/extensions/extension_apitest.h" |
| 12 #include "chrome/browser/net/url_request_mock_util.h" | 13 #include "chrome/browser/net/url_request_mock_util.h" |
| 13 #include "chrome/test/base/ui_test_utils.h" | 14 #include "chrome/test/base/ui_test_utils.h" |
| 14 #include "chromeos/dbus/fake_session_manager_client.h" | 15 #include "chromeos/dbus/fake_session_manager_client.h" |
| 15 #include "chromeos/login/user_names.h" | 16 #include "chromeos/login/user_names.h" |
| 16 #include "components/policy/core/common/cloud/device_management_service.h" | 17 #include "components/policy/core/common/cloud/device_management_service.h" |
| 17 #include "components/policy/core/common/mock_configuration_policy_provider.h" | 18 #include "components/policy/core/common/mock_configuration_policy_provider.h" |
| 18 #include "components/policy/policy_constants.h" | 19 #include "components/policy/policy_constants.h" |
| 19 #include "components/prefs/pref_service.h" | 20 #include "components/prefs/pref_service.h" |
| 20 #include "components/signin/core/account_id/account_id.h" | 21 #include "components/signin/core/account_id/account_id.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 user_affiliation_ids.insert(kAffiliationID); | 90 user_affiliation_ids.insert(kAffiliationID); |
| 90 } else { | 91 } else { |
| 91 user_affiliation_ids.insert(kAnotherAffiliationID); | 92 user_affiliation_ids.insert(kAnotherAffiliationID); |
| 92 } | 93 } |
| 93 policy::UserPolicyBuilder user_policy; | 94 policy::UserPolicyBuilder user_policy; |
| 94 policy::affiliation_test_helper::SetUserAffiliationIDs( | 95 policy::affiliation_test_helper::SetUserAffiliationIDs( |
| 95 &user_policy, fake_session_manager_client, | 96 &user_policy, fake_session_manager_client, |
| 96 affiliated_account_id_.GetUserEmail(), user_affiliation_ids); | 97 affiliated_account_id_.GetUserEmail(), user_affiliation_ids); |
| 97 | 98 |
| 98 // Set up fake install attributes. | 99 // Set up fake install attributes. |
| 99 std::unique_ptr<policy::StubEnterpriseInstallAttributes> attributes( | 100 std::unique_ptr<chromeos::StubInstallAttributes> attributes = |
| 100 new policy::StubEnterpriseInstallAttributes()); | 101 base::MakeUnique<chromeos::StubInstallAttributes>(); |
| 101 | 102 |
| 102 attributes->SetRegistrationUser(affiliated_account_id_.GetUserEmail()); | 103 attributes->SetRegistrationUser(affiliated_account_id_.GetUserEmail()); |
| 103 policy::BrowserPolicyConnectorChromeOS::SetInstallAttributesForTesting( | 104 policy::BrowserPolicyConnectorChromeOS::SetInstallAttributesForTesting( |
| 104 attributes.release()); | 105 attributes.release()); |
| 105 | 106 |
| 106 test_helper_.InstallOwnerKey(); | 107 test_helper_.InstallOwnerKey(); |
| 107 // Init the device policy. | 108 // Init the device policy. |
| 108 policy::DevicePolicyBuilder* device_policy = test_helper_.device_policy(); | 109 policy::DevicePolicyBuilder* device_policy = test_helper_.device_policy(); |
| 109 device_policy->SetDefaultSigningKey(); | 110 device_policy->SetDefaultSigningKey(); |
| 110 device_policy->policy_data().set_directory_api_id(kDeviceId); | 111 device_policy->policy_data().set_directory_api_id(kDeviceId); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 "'enterprise.deviceAttributes' is not allowed for specified install " | 239 "'enterprise.deviceAttributes' is not allowed for specified install " |
| 239 "location.", | 240 "location.", |
| 240 extension->install_warnings()[0].message); | 241 extension->install_warnings()[0].message); |
| 241 } | 242 } |
| 242 | 243 |
| 243 // Both cases of affiliated and non-affiliated on the device user are tested. | 244 // Both cases of affiliated and non-affiliated on the device user are tested. |
| 244 INSTANTIATE_TEST_CASE_P(AffiliationCheck, | 245 INSTANTIATE_TEST_CASE_P(AffiliationCheck, |
| 245 EnterpriseDeviceAttributesTest, | 246 EnterpriseDeviceAttributesTest, |
| 246 ::testing::Values(Params(true), Params(false))); | 247 ::testing::Values(Params(true), Params(false))); |
| 247 } // namespace extensions | 248 } // namespace extensions |
| OLD | NEW |