| 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 <cryptohi.h> | 5 #include <cryptohi.h> |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 13 #include "chrome/browser/chromeos/platform_keys/platform_keys_service.h" | 13 #include "chrome/browser/chromeos/platform_keys/platform_keys_service.h" |
| 14 #include "chrome/browser/chromeos/platform_keys/platform_keys_service_factory.h" | 14 #include "chrome/browser/chromeos/platform_keys/platform_keys_service_factory.h" |
| 15 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" | 15 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" |
| 16 #include "chrome/browser/chromeos/policy/user_policy_test_helper.h" | 16 #include "chrome/browser/chromeos/policy/user_policy_test_helper.h" |
| 17 #include "chrome/browser/extensions/extension_apitest.h" | 17 #include "chrome/browser/extensions/extension_apitest.h" |
| 18 #include "chrome/browser/net/nss_context.h" | 18 #include "chrome/browser/net/nss_context.h" |
| 19 #include "chrome/browser/policy/profile_policy_connector.h" | 19 #include "chrome/browser/policy/profile_policy_connector.h" |
| 20 #include "chrome/browser/policy/profile_policy_connector_factory.h" | 20 #include "chrome/browser/policy/profile_policy_connector_factory.h" |
| 21 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
| 22 #include "chromeos/chromeos_switches.h" | 22 #include "chromeos/chromeos_switches.h" |
| 23 #include "chromeos/login/user_names.h" | |
| 24 #include "components/policy/policy_constants.h" | 23 #include "components/policy/policy_constants.h" |
| 25 #include "components/signin/core/account_id/account_id.h" | 24 #include "components/signin/core/account_id/account_id.h" |
| 25 #include "components/user_manager/user_names.h" |
| 26 #include "content/public/browser/notification_service.h" | 26 #include "content/public/browser/notification_service.h" |
| 27 #include "content/public/test/test_utils.h" | 27 #include "content/public/test/test_utils.h" |
| 28 #include "crypto/nss_util_internal.h" | 28 #include "crypto/nss_util_internal.h" |
| 29 #include "crypto/scoped_test_system_nss_key_slot.h" | 29 #include "crypto/scoped_test_system_nss_key_slot.h" |
| 30 #include "extensions/browser/extension_registry.h" | 30 #include "extensions/browser/extension_registry.h" |
| 31 #include "extensions/browser/notification_types.h" | 31 #include "extensions/browser/notification_types.h" |
| 32 #include "net/base/net_errors.h" | 32 #include "net/base/net_errors.h" |
| 33 #include "net/cert/nss_cert_database.h" | 33 #include "net/cert/nss_cert_database.h" |
| 34 #include "net/cert/test_root_certs.h" | 34 #include "net/cert/test_root_certs.h" |
| 35 #include "net/test/cert_test_util.h" | 35 #include "net/test/cert_test_util.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 58 } | 58 } |
| 59 | 59 |
| 60 void SetUpCommandLine(base::CommandLine* command_line) override { | 60 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 61 ExtensionApiTest::SetUpCommandLine(command_line); | 61 ExtensionApiTest::SetUpCommandLine(command_line); |
| 62 | 62 |
| 63 if (policy_helper_) | 63 if (policy_helper_) |
| 64 policy_helper_->UpdateCommandLine(command_line); | 64 policy_helper_->UpdateCommandLine(command_line); |
| 65 | 65 |
| 66 command_line->AppendSwitchASCII( | 66 command_line->AppendSwitchASCII( |
| 67 chromeos::switches::kLoginUser, | 67 chromeos::switches::kLoginUser, |
| 68 chromeos::login::StubAccountId().GetUserEmail()); | 68 user_manager::StubAccountId().GetUserEmail()); |
| 69 } | 69 } |
| 70 | 70 |
| 71 void SetUpInProcessBrowserTestFixture() override { | 71 void SetUpInProcessBrowserTestFixture() override { |
| 72 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); | 72 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); |
| 73 | 73 |
| 74 if (device_status_ == DEVICE_STATUS_ENROLLED) { | 74 if (device_status_ == DEVICE_STATUS_ENROLLED) { |
| 75 device_policy_test_helper_.device_policy()->policy_data().set_username( | 75 device_policy_test_helper_.device_policy()->policy_data().set_username( |
| 76 user_status_ == USER_STATUS_MANAGED_AFFILIATED_DOMAIN | 76 user_status_ == USER_STATUS_MANAGED_AFFILIATED_DOMAIN |
| 77 ? chromeos::login::StubAccountId().GetUserEmail() | 77 ? user_manager::StubAccountId().GetUserEmail() |
| 78 : "someuser@anydomain.com"); | 78 : "someuser@anydomain.com"); |
| 79 | 79 |
| 80 device_policy_test_helper_.device_policy()->Build(); | 80 device_policy_test_helper_.device_policy()->Build(); |
| 81 device_policy_test_helper_.MarkAsEnterpriseOwned(); | 81 device_policy_test_helper_.MarkAsEnterpriseOwned(); |
| 82 } | 82 } |
| 83 } | 83 } |
| 84 | 84 |
| 85 void SetUpOnMainThread() override { | 85 void SetUpOnMainThread() override { |
| 86 if (policy_helper_) | 86 if (policy_helper_) |
| 87 policy_helper_->WaitForInitialPolicy(browser()->profile()); | 87 policy_helper_->WaitForInitialPolicy(browser()->profile()); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 const DeviceStatus device_status_; | 174 const DeviceStatus device_status_; |
| 175 const UserStatus user_status_; | 175 const UserStatus user_status_; |
| 176 | 176 |
| 177 scoped_refptr<net::X509Certificate> client_cert1_; | 177 scoped_refptr<net::X509Certificate> client_cert1_; |
| 178 scoped_refptr<net::X509Certificate> client_cert2_; | 178 scoped_refptr<net::X509Certificate> client_cert2_; |
| 179 const extensions::Extension* extension_; | 179 const extensions::Extension* extension_; |
| 180 | 180 |
| 181 private: | 181 private: |
| 182 void SetupInitialEmptyPolicy() { | 182 void SetupInitialEmptyPolicy() { |
| 183 policy_helper_.reset(new policy::UserPolicyTestHelper( | 183 policy_helper_.reset(new policy::UserPolicyTestHelper( |
| 184 chromeos::login::StubAccountId().GetUserEmail())); | 184 user_manager::StubAccountId().GetUserEmail())); |
| 185 policy_helper_->Init( | 185 policy_helper_->Init( |
| 186 base::DictionaryValue() /* empty mandatory policy */, | 186 base::DictionaryValue() /* empty mandatory policy */, |
| 187 base::DictionaryValue() /* empty recommended policy */); | 187 base::DictionaryValue() /* empty recommended policy */); |
| 188 } | 188 } |
| 189 | 189 |
| 190 void SetupKeyPermissionPolicy() { | 190 void SetupKeyPermissionPolicy() { |
| 191 // Set up the test policy that gives |extension_| the permission to access | 191 // Set up the test policy that gives |extension_| the permission to access |
| 192 // corporate keys. | 192 // corporate keys. |
| 193 base::DictionaryValue key_permissions_policy; | 193 base::DictionaryValue key_permissions_policy; |
| 194 { | 194 { |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 << message_; | 450 << message_; |
| 451 } | 451 } |
| 452 | 452 |
| 453 INSTANTIATE_TEST_CASE_P( | 453 INSTANTIATE_TEST_CASE_P( |
| 454 ManagedWithPermission, | 454 ManagedWithPermission, |
| 455 ManagedWithPermissionPlatformKeysTest, | 455 ManagedWithPermissionPlatformKeysTest, |
| 456 ::testing::Values( | 456 ::testing::Values( |
| 457 Params(DEVICE_STATUS_ENROLLED, USER_STATUS_MANAGED_AFFILIATED_DOMAIN), | 457 Params(DEVICE_STATUS_ENROLLED, USER_STATUS_MANAGED_AFFILIATED_DOMAIN), |
| 458 Params(DEVICE_STATUS_ENROLLED, USER_STATUS_MANAGED_OTHER_DOMAIN), | 458 Params(DEVICE_STATUS_ENROLLED, USER_STATUS_MANAGED_OTHER_DOMAIN), |
| 459 Params(DEVICE_STATUS_NOT_ENROLLED, USER_STATUS_MANAGED_OTHER_DOMAIN))); | 459 Params(DEVICE_STATUS_NOT_ENROLLED, USER_STATUS_MANAGED_OTHER_DOMAIN))); |
| OLD | NEW |