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

Side by Side Diff: chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager_policy_browsertest.cc

Issue 1693383003: ChromeOS cryptohome should be able to use gaia id as user identifier. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed unit tests. Created 4 years, 9 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 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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/desktop_background/desktop_background_controller.h" 10 #include "ash/desktop_background/desktop_background_controller.h"
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 AccountId::FromUserEmail(LoginManagerTest::kEnterpriseUser2)); 143 AccountId::FromUserEmail(LoginManagerTest::kEnterpriseUser2));
144 } 144 }
145 145
146 scoped_ptr<policy::UserPolicyBuilder> GetUserPolicyBuilder( 146 scoped_ptr<policy::UserPolicyBuilder> GetUserPolicyBuilder(
147 const AccountId& account_id) { 147 const AccountId& account_id) {
148 scoped_ptr<policy::UserPolicyBuilder> 148 scoped_ptr<policy::UserPolicyBuilder>
149 user_policy_builder(new policy::UserPolicyBuilder()); 149 user_policy_builder(new policy::UserPolicyBuilder());
150 base::FilePath user_keys_dir; 150 base::FilePath user_keys_dir;
151 EXPECT_TRUE(PathService::Get(DIR_USER_POLICY_KEYS, &user_keys_dir)); 151 EXPECT_TRUE(PathService::Get(DIR_USER_POLICY_KEYS, &user_keys_dir));
152 const std::string sanitized_user_id = 152 const std::string sanitized_user_id =
153 CryptohomeClient::GetStubSanitizedUsername(account_id.GetUserEmail()); 153 CryptohomeClient::GetStubSanitizedUsername(
154 cryptohome::Identification(account_id));
154 const base::FilePath user_key_file = 155 const base::FilePath user_key_file =
155 user_keys_dir.AppendASCII(sanitized_user_id) 156 user_keys_dir.AppendASCII(sanitized_user_id)
156 .AppendASCII("policy.pub"); 157 .AppendASCII("policy.pub");
157 std::vector<uint8_t> user_key_bits; 158 std::vector<uint8_t> user_key_bits;
158 EXPECT_TRUE(user_policy_builder->GetSigningKey()-> 159 EXPECT_TRUE(user_policy_builder->GetSigningKey()->
159 ExportPublicKey(&user_key_bits)); 160 ExportPublicKey(&user_key_bits));
160 EXPECT_TRUE(base::CreateDirectory(user_key_file.DirName())); 161 EXPECT_TRUE(base::CreateDirectory(user_key_file.DirName()));
161 EXPECT_EQ(base::WriteFile( 162 EXPECT_EQ(base::WriteFile(
162 user_key_file, 163 user_key_file,
163 reinterpret_cast<const char*>(user_key_bits.data()), 164 reinterpret_cast<const char*>(user_key_bits.data()),
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 const AccountId& account_id = testUsers_[user_number]; 246 const AccountId& account_id = testUsers_[user_number];
246 policy::UserPolicyBuilder* builder = 247 policy::UserPolicyBuilder* builder =
247 user_policy_builders_[user_number].get(); 248 user_policy_builders_[user_number].get();
248 if (!filename.empty()) { 249 if (!filename.empty()) {
249 builder->payload(). 250 builder->payload().
250 mutable_wallpaperimage()->set_value(ConstructPolicy(filename)); 251 mutable_wallpaperimage()->set_value(ConstructPolicy(filename));
251 } else { 252 } else {
252 builder->payload().Clear(); 253 builder->payload().Clear();
253 } 254 }
254 builder->Build(); 255 builder->Build();
255 fake_session_manager_client_->set_user_policy(account_id.GetUserEmail(), 256 fake_session_manager_client_->set_user_policy(
256 builder->GetBlob()); 257 cryptohome::Identification(account_id), builder->GetBlob());
257 const user_manager::User* user = 258 const user_manager::User* user =
258 user_manager::UserManager::Get()->FindUser(account_id); 259 user_manager::UserManager::Get()->FindUser(account_id);
259 ASSERT_TRUE(user); 260 ASSERT_TRUE(user);
260 policy::CloudPolicyStore* store = GetStoreForUser(user); 261 policy::CloudPolicyStore* store = GetStoreForUser(user);
261 ASSERT_TRUE(store); 262 ASSERT_TRUE(store);
262 store->Load(); 263 store->Load();
263 ASSERT_EQ(policy::CloudPolicyStore::STATUS_OK, store->status()); 264 ASSERT_EQ(policy::CloudPolicyStore::STATUS_OK, store->status());
264 ASSERT_EQ(policy::CloudPolicyValidatorBase::VALIDATION_OK, 265 ASSERT_EQ(policy::CloudPolicyValidatorBase::VALIDATION_OK,
265 store->validation_status()); 266 store->validation_status());
266 } 267 }
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 408
408 IN_PROC_BROWSER_TEST_F(WallpaperManagerPolicyTest, PersistOverLogout) { 409 IN_PROC_BROWSER_TEST_F(WallpaperManagerPolicyTest, PersistOverLogout) {
409 LoginUser(testUsers_[0].GetUserEmail()); 410 LoginUser(testUsers_[0].GetUserEmail());
410 411
411 // Wait until wallpaper has been loaded. 412 // Wait until wallpaper has been loaded.
412 RunUntilWallpaperChangeCount(1); 413 RunUntilWallpaperChangeCount(1);
413 ASSERT_EQ(kRedImageColor, GetAverageBackgroundColor()); 414 ASSERT_EQ(kRedImageColor, GetAverageBackgroundColor());
414 } 415 }
415 416
416 } // namespace chromeos 417 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698