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 "chrome/browser/chromeos/login/users/multi_profile_user_controller.h" | 5 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/chromeos/login/users/fake_user_manager.h" | 10 #include "chrome/browser/chromeos/login/users/fake_user_manager.h" |
11 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller_dele
gate.h" | 11 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller_dele
gate.h" |
12 #include "chrome/browser/chromeos/login/users/user_manager.h" | 12 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" |
13 #include "chrome/browser/chromeos/policy/policy_cert_service.h" | 13 #include "chrome/browser/chromeos/policy/policy_cert_service.h" |
14 #include "chrome/browser/chromeos/policy/policy_cert_service_factory.h" | 14 #include "chrome/browser/chromeos/policy/policy_cert_service_factory.h" |
15 #include "chrome/browser/chromeos/policy/policy_cert_verifier.h" | 15 #include "chrome/browser/chromeos/policy/policy_cert_verifier.h" |
16 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 16 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
17 #include "chrome/browser/prefs/browser_prefs.h" | 17 #include "chrome/browser/prefs/browser_prefs.h" |
18 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
19 #include "chrome/test/base/scoped_testing_local_state.h" | 19 #include "chrome/test/base/scoped_testing_local_state.h" |
20 #include "chrome/test/base/testing_browser_process.h" | 20 #include "chrome/test/base/testing_browser_process.h" |
21 #include "chrome/test/base/testing_pref_service_syncable.h" | 21 #include "chrome/test/base/testing_pref_service_syncable.h" |
22 #include "chrome/test/base/testing_profile.h" | 22 #include "chrome/test/base/testing_profile.h" |
23 #include "chrome/test/base/testing_profile_manager.h" | 23 #include "chrome/test/base/testing_profile_manager.h" |
| 24 #include "components/user_manager/user_manager.h" |
24 #include "content/public/test/test_browser_thread_bundle.h" | 25 #include "content/public/test/test_browser_thread_bundle.h" |
25 #include "net/cert/x509_certificate.h" | 26 #include "net/cert/x509_certificate.h" |
26 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
27 | 28 |
28 namespace chromeos { | 29 namespace chromeos { |
29 | 30 |
30 namespace { | 31 namespace { |
31 | 32 |
32 const char* kUsers[] = {"a@gmail.com", "b@gmail.com" }; | 33 const char* kUsers[] = {"a@gmail.com", "b@gmail.com" }; |
33 | 34 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 MultiProfileUserController::NOT_ALLOWED_PRIMARY_USER_POLICY_FORBIDS, | 85 MultiProfileUserController::NOT_ALLOWED_PRIMARY_USER_POLICY_FORBIDS, |
85 }, | 86 }, |
86 }; | 87 }; |
87 | 88 |
88 // Weak ptr to PolicyCertVerifier - object is freed in test destructor once | 89 // Weak ptr to PolicyCertVerifier - object is freed in test destructor once |
89 // we've ensured the profile has been shut down. | 90 // we've ensured the profile has been shut down. |
90 policy::PolicyCertVerifier* g_policy_cert_verifier_for_factory = NULL; | 91 policy::PolicyCertVerifier* g_policy_cert_verifier_for_factory = NULL; |
91 | 92 |
92 KeyedService* TestPolicyCertServiceFactory(content::BrowserContext* context) { | 93 KeyedService* TestPolicyCertServiceFactory(content::BrowserContext* context) { |
93 return policy::PolicyCertService::CreateForTesting( | 94 return policy::PolicyCertService::CreateForTesting( |
94 kUsers[0], g_policy_cert_verifier_for_factory, UserManager::Get()) | 95 kUsers[0], |
95 .release(); | 96 g_policy_cert_verifier_for_factory, |
| 97 user_manager::UserManager::Get()).release(); |
96 } | 98 } |
97 | 99 |
98 } // namespace | 100 } // namespace |
99 | 101 |
100 class MultiProfileUserControllerTest | 102 class MultiProfileUserControllerTest |
101 : public testing::Test, | 103 : public testing::Test, |
102 public MultiProfileUserControllerDelegate { | 104 public MultiProfileUserControllerDelegate { |
103 public: | 105 public: |
104 MultiProfileUserControllerTest() | 106 MultiProfileUserControllerTest() |
105 : fake_user_manager_(new FakeUserManager), | 107 : fake_user_manager_(new FakeUserManager), |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 EXPECT_TRUE(service->has_policy_certificates()); | 405 EXPECT_TRUE(service->has_policy_certificates()); |
404 EXPECT_FALSE(controller()->IsUserAllowedInSession(kUsers[1], &reason)); | 406 EXPECT_FALSE(controller()->IsUserAllowedInSession(kUsers[1], &reason)); |
405 EXPECT_EQ(MultiProfileUserController::NOT_ALLOWED_PRIMARY_POLICY_CERT_TAINTED, | 407 EXPECT_EQ(MultiProfileUserController::NOT_ALLOWED_PRIMARY_POLICY_CERT_TAINTED, |
406 reason); | 408 reason); |
407 | 409 |
408 // Flush tasks posted to IO. | 410 // Flush tasks posted to IO. |
409 base::RunLoop().RunUntilIdle(); | 411 base::RunLoop().RunUntilIdle(); |
410 } | 412 } |
411 | 413 |
412 } // namespace chromeos | 414 } // namespace chromeos |
OLD | NEW |