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

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

Issue 2655873002: Get enrollment token from DMServer when an Active Directory user uses ARC (Closed)
Patch Set: Fix Luis's comments Created 3 years, 10 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/arc/arc_util.h" 5 #include "chrome/browser/chromeos/arc/arc_util.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 20 matching lines...) Expand all
31 constexpr char kTestGaiaId[] = "1234567890"; 31 constexpr char kTestGaiaId[] = "1234567890";
32 32
33 class ScopedLogIn { 33 class ScopedLogIn {
34 public: 34 public:
35 ScopedLogIn( 35 ScopedLogIn(
36 chromeos::FakeChromeUserManager* fake_user_manager, 36 chromeos::FakeChromeUserManager* fake_user_manager,
37 const AccountId& account_id, 37 const AccountId& account_id,
38 user_manager::UserType user_type = user_manager::USER_TYPE_REGULAR) 38 user_manager::UserType user_type = user_manager::USER_TYPE_REGULAR)
39 : fake_user_manager_(fake_user_manager), account_id_(account_id) { 39 : fake_user_manager_(fake_user_manager), account_id_(account_id) {
40 switch (user_type) { 40 switch (user_type) {
41 case user_manager::USER_TYPE_REGULAR: 41 case user_manager::USER_TYPE_REGULAR: // fallthrough
42 case user_manager::USER_TYPE_ACTIVE_DIRECTORY:
42 LogIn(); 43 LogIn();
43 break; 44 break;
44 case user_manager::USER_TYPE_ARC_KIOSK_APP: 45 case user_manager::USER_TYPE_ARC_KIOSK_APP:
45 LogInArcKioskApp(); 46 LogInArcKioskApp();
46 break; 47 break;
47 default: 48 default:
48 NOTREACHED(); 49 NOTREACHED();
49 } 50 }
50 } 51 }
51 52
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 TEST_F(ChromeArcUtilTest, IsArcAllowedForProfile_NonPrimaryProfile) { 148 TEST_F(ChromeArcUtilTest, IsArcAllowedForProfile_NonPrimaryProfile) {
148 ScopedLogIn login2( 149 ScopedLogIn login2(
149 GetFakeUserManager(), 150 GetFakeUserManager(),
150 AccountId::FromUserEmailGaiaId("user2@gmail.com", "0123456789")); 151 AccountId::FromUserEmailGaiaId("user2@gmail.com", "0123456789"));
151 ScopedLogIn login(GetFakeUserManager(), 152 ScopedLogIn login(GetFakeUserManager(),
152 AccountId::FromUserEmailGaiaId( 153 AccountId::FromUserEmailGaiaId(
153 profile()->GetProfileUserName(), kTestGaiaId)); 154 profile()->GetProfileUserName(), kTestGaiaId));
154 EXPECT_FALSE(IsArcAllowedForProfile(profile())); 155 EXPECT_FALSE(IsArcAllowedForProfile(profile()));
155 } 156 }
156 157
158 TEST_F(ChromeArcUtilTest, IsArcAllowedForProfile_ActiveDirectoryEnabled) {
159 base::CommandLine::ForCurrentProcess()->InitFromArgv(
160 {"", "--arc-availability=officially-supported-with-active-directory"});
161 ScopedLogIn login(
162 GetFakeUserManager(),
163 AccountId::AdFromObjGuid("f04557de-5da2-40ce-ae9d-b8874d8da96e"),
164 user_manager::USER_TYPE_ACTIVE_DIRECTORY);
165 EXPECT_FALSE(chromeos::ProfileHelper::Get()
166 ->GetUserByProfile(profile())
167 ->HasGaiaAccount());
168 EXPECT_TRUE(IsArcAllowedForProfile(profile()));
169 }
170
171 TEST_F(ChromeArcUtilTest, IsArcAllowedForProfile_ActiveDirectoryDisabled) {
172 ScopedLogIn login(
173 GetFakeUserManager(),
174 AccountId::AdFromObjGuid("f04557de-5da2-40ce-ae9d-b8874d8da96e"),
175 user_manager::USER_TYPE_ACTIVE_DIRECTORY);
176 EXPECT_FALSE(chromeos::ProfileHelper::Get()
177 ->GetUserByProfile(profile())
178 ->HasGaiaAccount());
179 EXPECT_FALSE(IsArcAllowedForProfile(profile()));
180 }
181
157 TEST_F(ChromeArcUtilTest, IsArcAllowedForProfile_Kiosk) { 182 TEST_F(ChromeArcUtilTest, IsArcAllowedForProfile_Kiosk) {
158 ScopedLogIn login(GetFakeUserManager(), 183 ScopedLogIn login(GetFakeUserManager(),
159 AccountId::FromUserEmail(profile()->GetProfileUserName()), 184 AccountId::FromUserEmail(profile()->GetProfileUserName()),
160 user_manager::USER_TYPE_ARC_KIOSK_APP); 185 user_manager::USER_TYPE_ARC_KIOSK_APP);
161 EXPECT_FALSE(chromeos::ProfileHelper::Get() 186 EXPECT_FALSE(chromeos::ProfileHelper::Get()
162 ->GetUserByProfile(profile()) 187 ->GetUserByProfile(profile())
163 ->HasGaiaAccount()); 188 ->HasGaiaAccount());
164 EXPECT_TRUE(IsArcAllowedForProfile(profile())); 189 EXPECT_TRUE(IsArcAllowedForProfile(profile()));
165 } 190 }
166 191
167 TEST_F(ChromeArcUtilTest, IsArcAllowedForProfile_SupervisedUserFlow) { 192 TEST_F(ChromeArcUtilTest, IsArcAllowedForProfile_SupervisedUserFlow) {
168 auto manager_id = AccountId::FromUserEmailGaiaId( 193 auto manager_id = AccountId::FromUserEmailGaiaId(
169 profile()->GetProfileUserName(), kTestGaiaId); 194 profile()->GetProfileUserName(), kTestGaiaId);
170 ScopedLogIn login(GetFakeUserManager(), manager_id); 195 ScopedLogIn login(GetFakeUserManager(), manager_id);
171 GetFakeUserManager()->SetUserFlow( 196 GetFakeUserManager()->SetUserFlow(
172 manager_id, new chromeos::SupervisedUserCreationFlow(manager_id)); 197 manager_id, new chromeos::SupervisedUserCreationFlow(manager_id));
173 EXPECT_FALSE(IsArcAllowedForProfile(profile())); 198 EXPECT_FALSE(IsArcAllowedForProfile(profile()));
174 GetFakeUserManager()->ResetUserFlow(manager_id); 199 GetFakeUserManager()->ResetUserFlow(manager_id);
175 } 200 }
176 201
177 // TODO(hidehiko): Add test for Ephemeral users. There seems no way to easily 202 // TODO(hidehiko): Add test for Ephemeral users. There seems no way to easily
178 // simulate ephemeral user. 203 // simulate ephemeral user.
179 204
180 } // namespace util 205 } // namespace util
181 } // namespace arc 206 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698