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

Side by Side Diff: chrome/browser/policy/cloud/cloud_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 (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 "base/callback.h" 5 #include "base/callback.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 #include "policy/proto/cloud_policy.pb.h" 47 #include "policy/proto/cloud_policy.pb.h"
48 #include "policy/proto/device_management_backend.pb.h" 48 #include "policy/proto/device_management_backend.pb.h"
49 #include "testing/gmock/include/gmock/gmock.h" 49 #include "testing/gmock/include/gmock/gmock.h"
50 #include "testing/gtest/include/gtest/gtest.h" 50 #include "testing/gtest/include/gtest/gtest.h"
51 #include "url/gurl.h" 51 #include "url/gurl.h"
52 52
53 #if defined(OS_CHROMEOS) 53 #if defined(OS_CHROMEOS)
54 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" 54 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h"
55 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chrom eos.h" 55 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chrom eos.h"
56 #include "chromeos/chromeos_paths.h" 56 #include "chromeos/chromeos_paths.h"
57 #include "chromeos/cryptohome/cryptohome_parameters.h"
57 #include "chromeos/dbus/cryptohome_client.h" 58 #include "chromeos/dbus/cryptohome_client.h"
58 #include "chromeos/login/user_names.h" 59 #include "chromeos/login/user_names.h"
60 #include "components/signin/core/account_id/account_id.h"
59 #else 61 #else
60 #include "chrome/browser/policy/cloud/user_cloud_policy_manager_factory.h" 62 #include "chrome/browser/policy/cloud/user_cloud_policy_manager_factory.h"
61 #include "chrome/browser/signin/signin_manager_factory.h" 63 #include "chrome/browser/signin/signin_manager_factory.h"
62 #include "components/policy/core/common/cloud/user_cloud_policy_manager.h" 64 #include "components/policy/core/common/cloud/user_cloud_policy_manager.h"
63 #include "components/signin/core/browser/signin_manager.h" 65 #include "components/signin/core/browser/signin_manager.h"
64 #endif 66 #endif
65 67
66 using testing::AnyNumber; 68 using testing::AnyNumber;
67 using testing::InvokeWithoutArgs; 69 using testing::InvokeWithoutArgs;
68 using testing::Mock; 70 using testing::Mock;
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 Mock::VerifyAndClearExpectations(&observer); 317 Mock::VerifyAndClearExpectations(&observer);
316 policy_manager->core()->client()->RemoveObserver(&observer); 318 policy_manager->core()->client()->RemoveObserver(&observer);
317 EXPECT_TRUE(policy_manager->core()->client()->is_registered()); 319 EXPECT_TRUE(policy_manager->core()->client()->is_registered());
318 320
319 #if defined(OS_CHROMEOS) 321 #if defined(OS_CHROMEOS)
320 // Get the path to the user policy key file. 322 // Get the path to the user policy key file.
321 base::FilePath user_policy_key_dir; 323 base::FilePath user_policy_key_dir;
322 ASSERT_TRUE( 324 ASSERT_TRUE(
323 PathService::Get(chromeos::DIR_USER_POLICY_KEYS, &user_policy_key_dir)); 325 PathService::Get(chromeos::DIR_USER_POLICY_KEYS, &user_policy_key_dir));
324 std::string sanitized_username = 326 std::string sanitized_username =
325 chromeos::CryptohomeClient::GetStubSanitizedUsername(GetTestUser()); 327 chromeos::CryptohomeClient::GetStubSanitizedUsername(
328 cryptohome::Identification(
329 AccountId::FromUserEmail(GetTestUser())));
326 user_policy_key_file_ = user_policy_key_dir.AppendASCII(sanitized_username) 330 user_policy_key_file_ = user_policy_key_dir.AppendASCII(sanitized_username)
327 .AppendASCII("policy.pub"); 331 .AppendASCII("policy.pub");
328 #endif 332 #endif
329 } 333 }
330 334
331 PolicyService* GetPolicyService() { 335 PolicyService* GetPolicyService() {
332 ProfilePolicyConnector* profile_connector = 336 ProfilePolicyConnector* profile_connector =
333 ProfilePolicyConnectorFactory::GetForBrowserContext( 337 ProfilePolicyConnectorFactory::GetForBrowserContext(
334 browser()->profile()); 338 browser()->profile());
335 return profile_connector->policy_service(); 339 return profile_connector->policy_service();
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 530
527 // They should now serialize to the same bytes. 531 // They should now serialize to the same bytes.
528 std::string chrome_settings_serialized; 532 std::string chrome_settings_serialized;
529 std::string cloud_policy_serialized; 533 std::string cloud_policy_serialized;
530 ASSERT_TRUE(chrome_settings.SerializeToString(&chrome_settings_serialized)); 534 ASSERT_TRUE(chrome_settings.SerializeToString(&chrome_settings_serialized));
531 ASSERT_TRUE(cloud_policy.SerializeToString(&cloud_policy_serialized)); 535 ASSERT_TRUE(cloud_policy.SerializeToString(&cloud_policy_serialized));
532 EXPECT_EQ(chrome_settings_serialized, cloud_policy_serialized); 536 EXPECT_EQ(chrome_settings_serialized, cloud_policy_serialized);
533 } 537 }
534 538
535 } // namespace policy 539 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698