Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(68)

Side by Side Diff: chrome/browser/chromeos/arc/arc_auth_service_unittest.cc

Issue 1922143002: Disabled ARC for ephemeral users. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed comments Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <memory> 5 #include <memory>
6 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/files/file_util.h" 11 #include "base/files/file_util.h"
12 #include "base/files/scoped_temp_dir.h" 12 #include "base/files/scoped_temp_dir.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/run_loop.h" 14 #include "base/run_loop.h"
15 #include "chrome/browser/chromeos/arc/arc_auth_service.h" 15 #include "chrome/browser/chromeos/arc/arc_auth_service.h"
16 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" 16 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h"
17 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" 17 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h"
18 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h"
18 #include "chrome/browser/chromeos/profiles/profile_helper.h" 19 #include "chrome/browser/chromeos/profiles/profile_helper.h"
19 #include "chrome/browser/prefs/pref_service_syncable_util.h" 20 #include "chrome/browser/prefs/pref_service_syncable_util.h"
20 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
21 #include "chrome/common/pref_names.h" 22 #include "chrome/common/pref_names.h"
22 #include "chrome/test/base/testing_profile.h" 23 #include "chrome/test/base/testing_profile.h"
24 #include "chromeos/login/user_names.h"
23 #include "components/arc/arc_bridge_service.h" 25 #include "components/arc/arc_bridge_service.h"
24 #include "components/arc/test/fake_arc_bridge_service.h" 26 #include "components/arc/test/fake_arc_bridge_service.h"
25 #include "components/prefs/pref_service.h" 27 #include "components/prefs/pref_service.h"
26 #include "components/signin/core/account_id/account_id.h" 28 #include "components/signin/core/account_id/account_id.h"
27 #include "components/syncable_prefs/testing_pref_service_syncable.h" 29 #include "components/syncable_prefs/testing_pref_service_syncable.h"
28 #include "components/user_manager/user_manager.h" 30 #include "components/user_manager/user_manager.h"
29 #include "content/public/browser/browser_thread.h" 31 #include "content/public/browser/browser_thread.h"
30 #include "content/public/test/test_browser_thread_bundle.h" 32 #include "content/public/test/test_browser_thread_bundle.h"
31 #include "google_apis/gaia/gaia_constants.h" 33 #include "google_apis/gaia/gaia_constants.h"
32 #include "google_apis/gaia/gaia_urls.h" 34 #include "google_apis/gaia/gaia_urls.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 // Check initial conditions. 69 // Check initial conditions.
68 EXPECT_EQ(bridge_service_.get(), ArcBridgeService::Get()); 70 EXPECT_EQ(bridge_service_.get(), ArcBridgeService::Get());
69 EXPECT_EQ(true, !ArcBridgeService::Get()->available()); 71 EXPECT_EQ(true, !ArcBridgeService::Get()->available());
70 EXPECT_EQ(ArcBridgeService::State::STOPPED, 72 EXPECT_EQ(ArcBridgeService::State::STOPPED,
71 ArcBridgeService::Get()->state()); 73 ArcBridgeService::Get()->state());
72 74
73 const AccountId account_id( 75 const AccountId account_id(
74 AccountId::FromUserEmailGaiaId("user@gmail.com", "1234567890")); 76 AccountId::FromUserEmailGaiaId("user@gmail.com", "1234567890"));
75 GetFakeUserManager()->AddUser(account_id); 77 GetFakeUserManager()->AddUser(account_id);
76 GetFakeUserManager()->LoginUser(account_id); 78 GetFakeUserManager()->LoginUser(account_id);
79
80 chromeos::WallpaperManager::Initialize();
77 } 81 }
78 82
79 void TearDown() override {} 83 void TearDown() override {}
80 84
81 chromeos::FakeChromeUserManager* GetFakeUserManager() const { 85 chromeos::FakeChromeUserManager* GetFakeUserManager() const {
82 return static_cast<chromeos::FakeChromeUserManager*>( 86 return static_cast<chromeos::FakeChromeUserManager*>(
83 user_manager::UserManager::Get()); 87 user_manager::UserManager::Get());
84 } 88 }
85 89
86 protected: 90 protected:
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 pref->SetBoolean(prefs::kArcEnabled, true); 125 pref->SetBoolean(prefs::kArcEnabled, true);
122 ASSERT_EQ(ArcAuthService::State::FETCHING_CODE, auth_service()->state()); 126 ASSERT_EQ(ArcAuthService::State::FETCHING_CODE, auth_service()->state());
123 127
124 pref->SetBoolean(prefs::kArcEnabled, false); 128 pref->SetBoolean(prefs::kArcEnabled, false);
125 ASSERT_EQ(ArcAuthService::State::STOPPED, auth_service()->state()); 129 ASSERT_EQ(ArcAuthService::State::STOPPED, auth_service()->state());
126 130
127 // Correctly stop service. 131 // Correctly stop service.
128 auth_service()->Shutdown(); 132 auth_service()->Shutdown();
129 } 133 }
130 134
135 TEST_F(ArcAuthServiceTest, DisabledForEphemeralDataUsers) {
136 PrefService* const prefs = profile()->GetPrefs();
137 EXPECT_FALSE(prefs->GetBoolean(prefs::kArcSignedIn));
138 prefs->SetBoolean(prefs::kArcEnabled, true);
139
140 chromeos::FakeChromeUserManager* const fake_user_manager =
141 GetFakeUserManager();
142
143 fake_user_manager->AddUser(fake_user_manager->GetGuestAccountId());
144 fake_user_manager->SwitchActiveUser(fake_user_manager->GetGuestAccountId());
145 auth_service()->OnPrimaryUserProfilePrepared(profile());
146 ASSERT_EQ(ArcAuthService::State::STOPPED, auth_service()->state());
147
148 fake_user_manager->AddUser(chromeos::login::DemoAccountId());
149 fake_user_manager->SwitchActiveUser(chromeos::login::DemoAccountId());
150 auth_service()->OnPrimaryUserProfilePrepared(profile());
151 ASSERT_EQ(ArcAuthService::State::STOPPED, auth_service()->state());
152
153 const AccountId public_account_id(
154 AccountId::FromUserEmail("public_user@gmail.com"));
155 fake_user_manager->AddPublicAccountUser(public_account_id);
156 fake_user_manager->SwitchActiveUser(public_account_id);
157 auth_service()->OnPrimaryUserProfilePrepared(profile());
158 ASSERT_EQ(ArcAuthService::State::STOPPED, auth_service()->state());
159
160 const AccountId not_in_list_account_id(
161 AccountId::FromUserEmail("not_in_list_user@gmail.com"));
162 fake_user_manager->AddUser(not_in_list_account_id);
163 fake_user_manager->SwitchActiveUser(not_in_list_account_id);
164 fake_user_manager->RemoveUserFromList(not_in_list_account_id);
165 auth_service()->OnPrimaryUserProfilePrepared(profile());
166 ASSERT_EQ(ArcAuthService::State::STOPPED, auth_service()->state());
167
168 // Correctly stop service.
169 auth_service()->Shutdown();
170 }
171
131 TEST_F(ArcAuthServiceTest, BaseWorkflow) { 172 TEST_F(ArcAuthServiceTest, BaseWorkflow) {
132 ASSERT_EQ(ArcBridgeService::State::STOPPED, bridge_service()->state()); 173 ASSERT_EQ(ArcBridgeService::State::STOPPED, bridge_service()->state());
133 ASSERT_EQ(ArcAuthService::State::STOPPED, auth_service()->state()); 174 ASSERT_EQ(ArcAuthService::State::STOPPED, auth_service()->state());
134 ASSERT_EQ(std::string(), auth_service()->GetAndResetAuthCode()); 175 ASSERT_EQ(std::string(), auth_service()->GetAndResetAuthCode());
135 176
136 auth_service()->OnPrimaryUserProfilePrepared(profile()); 177 auth_service()->OnPrimaryUserProfilePrepared(profile());
137 178
138 // By default ARC is not enabled. 179 // By default ARC is not enabled.
139 ASSERT_EQ(ArcAuthService::State::STOPPED, auth_service()->state()); 180 ASSERT_EQ(ArcAuthService::State::STOPPED, auth_service()->state());
140 181
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 313
273 // Check that user without GAIA account can't use ARC. 314 // Check that user without GAIA account can't use ARC.
274 auth_service()->OnPrimaryUserProfilePrepared(device_local_profile.get()); 315 auth_service()->OnPrimaryUserProfilePrepared(device_local_profile.get());
275 EXPECT_EQ(ArcAuthService::State::STOPPED, auth_service()->state()); 316 EXPECT_EQ(ArcAuthService::State::STOPPED, auth_service()->state());
276 317
277 // Correctly stop service. 318 // Correctly stop service.
278 auth_service()->Shutdown(); 319 auth_service()->Shutdown();
279 } 320 }
280 321
281 } // namespace arc 322 } // namespace arc
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/arc/arc_auth_service.cc ('k') | chrome/browser/chromeos/login/users/fake_chrome_user_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698