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

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: Add cryptohome::Identification() . Created 4 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 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 const AccountId& account_id = testUsers_[user_number]; 242 const AccountId& account_id = testUsers_[user_number];
242 policy::UserPolicyBuilder* builder = 243 policy::UserPolicyBuilder* builder =
243 user_policy_builders_[user_number].get(); 244 user_policy_builders_[user_number].get();
244 if (!filename.empty()) { 245 if (!filename.empty()) {
245 builder->payload(). 246 builder->payload().
246 mutable_wallpaperimage()->set_value(ConstructPolicy(filename)); 247 mutable_wallpaperimage()->set_value(ConstructPolicy(filename));
247 } else { 248 } else {
248 builder->payload().Clear(); 249 builder->payload().Clear();
249 } 250 }
250 builder->Build(); 251 builder->Build();
251 fake_session_manager_client_->set_user_policy(account_id.GetUserEmail(), 252 fake_session_manager_client_->set_user_policy(
252 builder->GetBlob()); 253 cryptohome::Identification(account_id), builder->GetBlob());
253 const user_manager::User* user = 254 const user_manager::User* user =
254 user_manager::UserManager::Get()->FindUser(account_id); 255 user_manager::UserManager::Get()->FindUser(account_id);
255 ASSERT_TRUE(user); 256 ASSERT_TRUE(user);
256 policy::CloudPolicyStore* store = GetStoreForUser(user); 257 policy::CloudPolicyStore* store = GetStoreForUser(user);
257 ASSERT_TRUE(store); 258 ASSERT_TRUE(store);
258 store->Load(); 259 store->Load();
259 ASSERT_EQ(policy::CloudPolicyStore::STATUS_OK, store->status()); 260 ASSERT_EQ(policy::CloudPolicyStore::STATUS_OK, store->status());
260 ASSERT_EQ(policy::CloudPolicyValidatorBase::VALIDATION_OK, 261 ASSERT_EQ(policy::CloudPolicyValidatorBase::VALIDATION_OK,
261 store->validation_status()); 262 store->validation_status());
262 } 263 }
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 404
404 IN_PROC_BROWSER_TEST_F(WallpaperManagerPolicyTest, PersistOverLogout) { 405 IN_PROC_BROWSER_TEST_F(WallpaperManagerPolicyTest, PersistOverLogout) {
405 LoginUser(testUsers_[0].GetUserEmail()); 406 LoginUser(testUsers_[0].GetUserEmail());
406 407
407 // Wait until wallpaper has been loaded. 408 // Wait until wallpaper has been loaded.
408 RunUntilWallpaperChangeCount(1); 409 RunUntilWallpaperChangeCount(1);
409 ASSERT_EQ(kRedImageColor, GetAverageBackgroundColor()); 410 ASSERT_EQ(kRedImageColor, GetAverageBackgroundColor());
410 } 411 }
411 412
412 } // namespace chromeos 413 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698