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

Side by Side Diff: chrome/browser/chromeos/login/login_utils_browsertest.cc

Issue 9403010: Add support for kiosk mode on the client. Make sure the settings are written in the lockbox. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed nitty nit. Created 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/policy/browser_policy_connector.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/login_utils.h" 5 #include "chrome/browser/chromeos/login/login_utils.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
11 #include "base/scoped_temp_dir.h" 11 #include "base/scoped_temp_dir.h"
12 #include "base/string_util.h" 12 #include "base/string_util.h"
13 #include "chrome/browser/chromeos/cros/cros_library.h" 13 #include "chrome/browser/chromeos/cros/cros_library.h"
14 #include "chrome/browser/chromeos/cros/mock_cryptohome_library.h" 14 #include "chrome/browser/chromeos/cros/mock_cryptohome_library.h"
15 #include "chrome/browser/chromeos/cros/mock_library_loader.h" 15 #include "chrome/browser/chromeos/cros/mock_library_loader.h"
16 #include "chrome/browser/chromeos/dbus/mock_dbus_thread_manager.h" 16 #include "chrome/browser/chromeos/dbus/mock_dbus_thread_manager.h"
17 #include "chrome/browser/chromeos/dbus/mock_session_manager_client.h" 17 #include "chrome/browser/chromeos/dbus/mock_session_manager_client.h"
18 #include "chrome/browser/chromeos/login/authenticator.h" 18 #include "chrome/browser/chromeos/login/authenticator.h"
19 #include "chrome/browser/chromeos/login/login_status_consumer.h" 19 #include "chrome/browser/chromeos/login/login_status_consumer.h"
20 #include "chrome/browser/chromeos/login/user_manager.h" 20 #include "chrome/browser/chromeos/login/user_manager.h"
21 #include "chrome/browser/io_thread.h" 21 #include "chrome/browser/io_thread.h"
22 #include "chrome/browser/net/predictor.h" 22 #include "chrome/browser/net/predictor.h"
23 #include "chrome/browser/policy/browser_policy_connector.h" 23 #include "chrome/browser/policy/browser_policy_connector.h"
24 #include "chrome/browser/policy/cloud_policy_data_store.h"
24 #include "chrome/browser/policy/proto/device_management_backend.pb.h" 25 #include "chrome/browser/policy/proto/device_management_backend.pb.h"
25 #include "chrome/browser/profiles/profile_manager.h" 26 #include "chrome/browser/profiles/profile_manager.h"
26 #include "chrome/common/chrome_paths.h" 27 #include "chrome/common/chrome_paths.h"
27 #include "chrome/common/chrome_switches.h" 28 #include "chrome/common/chrome_switches.h"
28 #include "chrome/common/net/gaia/gaia_urls.h" 29 #include "chrome/common/net/gaia/gaia_urls.h"
29 #include "chrome/common/pref_names.h" 30 #include "chrome/common/pref_names.h"
30 #include "chrome/common/net/gaia/gaia_auth_consumer.h" 31 #include "chrome/common/net/gaia/gaia_auth_consumer.h"
31 #include "chrome/test/base/testing_browser_process.h" 32 #include "chrome/test/base/testing_browser_process.h"
32 #include "chrome/test/base/testing_pref_service.h" 33 #include "chrome/test/base/testing_pref_service.h"
33 #include "content/public/browser/browser_thread.h" 34 #include "content/public/browser/browser_thread.h"
(...skipping 13 matching lines...) Expand all
47 48
48 using ::testing::DoAll; 49 using ::testing::DoAll;
49 using ::testing::Return; 50 using ::testing::Return;
50 using ::testing::SetArgPointee; 51 using ::testing::SetArgPointee;
51 using ::testing::_; 52 using ::testing::_;
52 using content::BrowserThread; 53 using content::BrowserThread;
53 54
54 const char kTrue[] = "true"; 55 const char kTrue[] = "true";
55 const char kDomain[] = "domain.com"; 56 const char kDomain[] = "domain.com";
56 const char kUsername[] = "user@domain.com"; 57 const char kUsername[] = "user@domain.com";
58 const char kMode[] = "enterprise";
59 const char kDeviceId[] = "100200300";
57 const char kUsernameOtherDomain[] = "user@other.com"; 60 const char kUsernameOtherDomain[] = "user@other.com";
58 const char kAttributeOwned[] = "enterprise.owned"; 61 const char kAttributeOwned[] = "enterprise.owned";
59 const char kAttributeOwner[] = "enterprise.user"; 62 const char kAttributeOwner[] = "enterprise.user";
63 const char kAttrEnterpriseDomain[] = "enterprise.domain";
64 const char kAttrEnterpriseMode[] = "enterprise.mode";
65 const char kAttrEnterpriseDeviceId[] = "enterprise.device_id";
60 66
61 const char kOAuthTokenCookie[] = "oauth_token=1234"; 67 const char kOAuthTokenCookie[] = "oauth_token=1234";
62 const char kOAuthGetAccessTokenData[] = 68 const char kOAuthGetAccessTokenData[] =
63 "oauth_token=1234&oauth_token_secret=1234"; 69 "oauth_token=1234&oauth_token_secret=1234";
64 const char kOAuthServiceTokenData[] = 70 const char kOAuthServiceTokenData[] =
65 "wrap_access_token=1234&wrap_access_token_expires_in=123456789"; 71 "wrap_access_token=1234&wrap_access_token_expires_in=123456789";
66 72
67 const char kDMServer[] = "http://server/device_management"; 73 const char kDMServer[] = "http://server/device_management";
68 const char kDMRegisterRequest[] = 74 const char kDMRegisterRequest[] =
69 "http://server/device_management?request=register"; 75 "http://server/device_management?request=register";
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 .WillRepeatedly(Return(true)); 149 .WillRepeatedly(Return(true));
144 EXPECT_CALL(*cryptohome_, TpmIsEnabled()) 150 EXPECT_CALL(*cryptohome_, TpmIsEnabled())
145 .WillRepeatedly(Return(false)); 151 .WillRepeatedly(Return(false));
146 EXPECT_CALL(*cryptohome_, IsMounted()) 152 EXPECT_CALL(*cryptohome_, IsMounted())
147 .WillRepeatedly(Return(true)); 153 .WillRepeatedly(Return(true));
148 EXPECT_CALL(*cryptohome_, InstallAttributesSet(kAttributeOwned, kTrue)) 154 EXPECT_CALL(*cryptohome_, InstallAttributesSet(kAttributeOwned, kTrue))
149 .WillRepeatedly(Return(true)); 155 .WillRepeatedly(Return(true));
150 EXPECT_CALL(*cryptohome_, InstallAttributesSet(kAttributeOwner, 156 EXPECT_CALL(*cryptohome_, InstallAttributesSet(kAttributeOwner,
151 kUsername)) 157 kUsername))
152 .WillRepeatedly(Return(true)); 158 .WillRepeatedly(Return(true));
159 EXPECT_CALL(*cryptohome_, InstallAttributesSet(kAttrEnterpriseDomain,
160 kDomain))
161 .WillRepeatedly(Return(true));
162 EXPECT_CALL(*cryptohome_, InstallAttributesSet(kAttrEnterpriseMode,
163 kMode))
164 .WillRepeatedly(Return(true));
165 EXPECT_CALL(*cryptohome_, InstallAttributesSet(kAttrEnterpriseDeviceId,
166 kDeviceId))
167 .WillRepeatedly(Return(true));
153 EXPECT_CALL(*cryptohome_, InstallAttributesFinalize()) 168 EXPECT_CALL(*cryptohome_, InstallAttributesFinalize())
154 .WillRepeatedly(Return(true)); 169 .WillRepeatedly(Return(true));
155 EXPECT_CALL(*cryptohome_, InstallAttributesGet(kAttributeOwned, _)) 170 EXPECT_CALL(*cryptohome_, InstallAttributesGet(kAttributeOwned, _))
156 .WillRepeatedly(DoAll(SetArgPointee<1>(kTrue), 171 .WillRepeatedly(DoAll(SetArgPointee<1>(kTrue),
157 Return(true))); 172 Return(true)));
158 EXPECT_CALL(*cryptohome_, InstallAttributesGet(kAttributeOwner, _)) 173 EXPECT_CALL(*cryptohome_, InstallAttributesGet(kAttributeOwner, _))
159 .WillRepeatedly(DoAll(SetArgPointee<1>(kUsername), 174 .WillRepeatedly(DoAll(SetArgPointee<1>(kUsername),
160 Return(true))); 175 Return(true)));
176 EXPECT_CALL(*cryptohome_, InstallAttributesGet(kAttrEnterpriseDomain, _))
177 .WillRepeatedly(DoAll(SetArgPointee<1>(kDomain),
178 Return(true)));
179 EXPECT_CALL(*cryptohome_, InstallAttributesGet(kAttrEnterpriseMode, _))
180 .WillRepeatedly(DoAll(SetArgPointee<1>(kMode),
181 Return(true)));
182 EXPECT_CALL(*cryptohome_, InstallAttributesGet(kAttrEnterpriseDeviceId, _))
183 .WillRepeatedly(DoAll(SetArgPointee<1>(kDeviceId),
184 Return(true)));
161 test_api->SetCryptohomeLibrary(cryptohome_, true); 185 test_api->SetCryptohomeLibrary(cryptohome_, true);
162 186
163 browser_process_->SetProfileManager( 187 browser_process_->SetProfileManager(
164 new ProfileManagerWithoutInit(scoped_temp_dir_.path())); 188 new ProfileManagerWithoutInit(scoped_temp_dir_.path()));
165 connector_ = browser_process_->browser_policy_connector(); 189 connector_ = browser_process_->browser_policy_connector();
166 connector_->Init(); 190 connector_->Init();
167 191
168 loop_.RunAllPending(); 192 loop_.RunAllPending();
169 } 193 }
170 194
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 const std::string& password, 246 const std::string& password,
223 bool pending_requests, 247 bool pending_requests,
224 bool using_oauth) OVERRIDE { 248 bool using_oauth) OVERRIDE {
225 FAIL() << "OnLoginSuccess not expected"; 249 FAIL() << "OnLoginSuccess not expected";
226 } 250 }
227 251
228 void LockDevice(const std::string& username) { 252 void LockDevice(const std::string& username) {
229 EXPECT_CALL(*cryptohome_, InstallAttributesIsFirstInstall()) 253 EXPECT_CALL(*cryptohome_, InstallAttributesIsFirstInstall())
230 .WillOnce(Return(true)) 254 .WillOnce(Return(true))
231 .WillRepeatedly(Return(false)); 255 .WillRepeatedly(Return(false));
256 policy::CloudPolicyDataStore* device_data_store =
257 connector_->GetDeviceCloudPolicyDataStore();
258 device_data_store->set_device_mode(policy::DEVICE_MODE_ENTERPRISE);
259 device_data_store->set_device_id(kDeviceId);
232 EXPECT_EQ(policy::EnterpriseInstallAttributes::LOCK_SUCCESS, 260 EXPECT_EQ(policy::EnterpriseInstallAttributes::LOCK_SUCCESS,
233 connector_->LockDevice(username)); 261 connector_->LockDevice(username));
234 loop_.RunAllPending(); 262 loop_.RunAllPending();
235 } 263 }
236 264
237 void PrepareProfile(const std::string& username) { 265 void PrepareProfile(const std::string& username) {
238 MockSessionManagerClient* session_managed_client = 266 MockSessionManagerClient* session_managed_client =
239 mock_dbus_thread_manager_.mock_session_manager_client(); 267 mock_dbus_thread_manager_.mock_session_manager_client();
240 EXPECT_CALL(*session_managed_client, StartSession(_)); 268 EXPECT_CALL(*session_managed_client, StartSession(_));
241 EXPECT_CALL(*cryptohome_, GetSystemSalt()) 269 EXPECT_CALL(*cryptohome_, GetSystemSalt())
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 EXPECT_TRUE(response.SerializeToString(&data)); 311 EXPECT_TRUE(response.SerializeToString(&data));
284 fetcher->SetResponseString(data); 312 fetcher->SetResponseString(data);
285 return fetcher; 313 return fetcher;
286 } 314 }
287 315
288 TestURLFetcher* PrepareDMRegisterFetcher() { 316 TestURLFetcher* PrepareDMRegisterFetcher() {
289 em::DeviceManagementResponse response; 317 em::DeviceManagementResponse response;
290 em::DeviceRegisterResponse* register_response = 318 em::DeviceRegisterResponse* register_response =
291 response.mutable_register_response(); 319 response.mutable_register_response();
292 register_response->set_device_management_token(kDMToken); 320 register_response->set_device_management_token(kDMToken);
321 register_response->set_enrollment_type(
322 em::DeviceRegisterResponse::ENTERPRISE);
293 return PrepareDMServiceFetcher(kDMRegisterRequest, response); 323 return PrepareDMServiceFetcher(kDMRegisterRequest, response);
294 } 324 }
295 325
296 TestURLFetcher* PrepareDMPolicyFetcher() { 326 TestURLFetcher* PrepareDMPolicyFetcher() {
297 em::DeviceManagementResponse response; 327 em::DeviceManagementResponse response;
298 response.mutable_policy_response()->add_response(); 328 response.mutable_policy_response()->add_response();
299 return PrepareDMServiceFetcher(kDMPolicyRequest, response); 329 return PrepareDMServiceFetcher(kDMPolicyRequest, response);
300 } 330 }
301 331
302 protected: 332 protected:
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 } 483 }
454 484
455 INSTANTIATE_TEST_CASE_P( 485 INSTANTIATE_TEST_CASE_P(
456 LoginUtilsBlockingLoginTestInstance, 486 LoginUtilsBlockingLoginTestInstance,
457 LoginUtilsBlockingLoginTest, 487 LoginUtilsBlockingLoginTest,
458 testing::Values(0, 1, 2, 3, 4, 5)); 488 testing::Values(0, 1, 2, 3, 4, 5));
459 489
460 } // namespace 490 } // namespace
461 491
462 } 492 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/policy/browser_policy_connector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698