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

Side by Side Diff: chrome/browser/chromeos/policy/enterprise_install_attributes_unittest.cc

Issue 24637004: cryptohome: Merge FakeCryptohomeClient and CryptohomeClinentStubImpl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix the build Created 7 years, 2 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
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/policy/enterprise_install_attributes.h" 5 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_util.h" 8 #include "base/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"
11 #include "base/run_loop.h" 11 #include "base/run_loop.h"
12 #include "chrome/browser/policy/proto/chromeos/install_attributes.pb.h" 12 #include "chrome/browser/policy/proto/chromeos/install_attributes.pb.h"
13 #include "chromeos/cryptohome/cryptohome_library.h" 13 #include "chromeos/cryptohome/cryptohome_library.h"
14 #include "chromeos/dbus/cryptohome_client_stub.h" 14 #include "chromeos/dbus/fake_cryptohome_client.h"
15 #include "google_apis/gaia/gaia_auth_util.h" 15 #include "google_apis/gaia/gaia_auth_util.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 17
18 namespace policy { 18 namespace policy {
19 19
20 namespace { 20 namespace {
21 21
22 void CopyLockResult(base::RunLoop* loop, 22 void CopyLockResult(base::RunLoop* loop,
23 EnterpriseInstallAttributes::LockResult* out, 23 EnterpriseInstallAttributes::LockResult* out,
24 EnterpriseInstallAttributes::LockResult result) { 24 EnterpriseInstallAttributes::LockResult result) {
25 *out = result; 25 *out = result;
26 loop->Quit(); 26 loop->Quit();
27 } 27 }
28 28
29 } // namespace 29 } // namespace
30 30
31 static const char kTestUser[] = "test@example.com"; 31 static const char kTestUser[] = "test@example.com";
32 static const char kTestUserCanonicalize[] = "UPPER.CASE@example.com"; 32 static const char kTestUserCanonicalize[] = "UPPER.CASE@example.com";
33 static const char kTestDomain[] = "example.com"; 33 static const char kTestDomain[] = "example.com";
34 static const char kTestDeviceId[] = "133750519"; 34 static const char kTestDeviceId[] = "133750519";
35 35
36 class EnterpriseInstallAttributesTest : public testing::Test { 36 class EnterpriseInstallAttributesTest : public testing::Test {
37 protected: 37 protected:
38 EnterpriseInstallAttributesTest() 38 EnterpriseInstallAttributesTest()
39 : cryptohome_(chromeos::CryptohomeLibrary::GetTestImpl()), 39 : cryptohome_(chromeos::CryptohomeLibrary::GetTestImpl()),
40 stub_cryptohome_client_(new chromeos::CryptohomeClientStubImpl()), 40 fake_cryptohome_client_(new chromeos::FakeCryptohomeClient()),
41 install_attributes_(cryptohome_.get(), stub_cryptohome_client_.get()) { 41 install_attributes_(cryptohome_.get(), fake_cryptohome_client_.get()) {
42 stub_cryptohome_client_->Init(NULL /* no dbus::Bus */); 42 fake_cryptohome_client_->Init(NULL /* no dbus::Bus */);
43 } 43 }
44 44
45 virtual void SetUp() OVERRIDE { 45 virtual void SetUp() OVERRIDE {
46 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 46 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
47 } 47 }
48 48
49 base::FilePath GetTempPath() const { 49 base::FilePath GetTempPath() const {
50 return temp_dir_.path().Append("install_attrs_test"); 50 return temp_dir_.path().Append("install_attrs_test");
51 } 51 }
52 52
53 void SetAttribute( 53 void SetAttribute(
54 cryptohome::SerializedInstallAttributes* install_attrs_proto, 54 cryptohome::SerializedInstallAttributes* install_attrs_proto,
55 const std::string& name, 55 const std::string& name,
56 const std::string& value) { 56 const std::string& value) {
57 cryptohome::SerializedInstallAttributes::Attribute* attribute; 57 cryptohome::SerializedInstallAttributes::Attribute* attribute;
58 attribute = install_attrs_proto->add_attributes(); 58 attribute = install_attrs_proto->add_attributes();
59 attribute->set_name(name); 59 attribute->set_name(name);
60 attribute->set_value(value); 60 attribute->set_value(value);
61 } 61 }
62 62
63 base::MessageLoopForUI message_loop_; 63 base::MessageLoopForUI message_loop_;
64 base::ScopedTempDir temp_dir_; 64 base::ScopedTempDir temp_dir_;
65 scoped_ptr<chromeos::CryptohomeLibrary> cryptohome_; 65 scoped_ptr<chromeos::CryptohomeLibrary> cryptohome_;
66 scoped_ptr<chromeos::CryptohomeClientStubImpl> stub_cryptohome_client_; 66 scoped_ptr<chromeos::FakeCryptohomeClient> fake_cryptohome_client_;
67 EnterpriseInstallAttributes install_attributes_; 67 EnterpriseInstallAttributes install_attributes_;
68 68
69 EnterpriseInstallAttributes::LockResult LockDeviceAndWaitForResult( 69 EnterpriseInstallAttributes::LockResult LockDeviceAndWaitForResult(
70 const std::string& user, 70 const std::string& user,
71 DeviceMode device_mode, 71 DeviceMode device_mode,
72 const std::string& device_id) { 72 const std::string& device_id) {
73 base::RunLoop loop; 73 base::RunLoop loop;
74 EnterpriseInstallAttributes::LockResult result; 74 EnterpriseInstallAttributes::LockResult result;
75 install_attributes_.LockDevice(user, device_mode, device_id, 75 install_attributes_.LockDevice(user, device_mode, device_id,
76 base::Bind(&CopyLockResult, &loop, &result)); 76 base::Bind(&CopyLockResult, &loop, &result));
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 ASSERT_EQ(static_cast<int>(blob.size()), 243 ASSERT_EQ(static_cast<int>(blob.size()),
244 file_util::WriteFile(GetTempPath(), blob.c_str(), blob.size())); 244 file_util::WriteFile(GetTempPath(), blob.c_str(), blob.size()));
245 install_attributes_.ReadCacheFile(GetTempPath()); 245 install_attributes_.ReadCacheFile(GetTempPath());
246 EXPECT_EQ(DEVICE_MODE_CONSUMER_KIOSK, install_attributes_.GetMode()); 246 EXPECT_EQ(DEVICE_MODE_CONSUMER_KIOSK, install_attributes_.GetMode());
247 EXPECT_EQ("", install_attributes_.GetDomain()); 247 EXPECT_EQ("", install_attributes_.GetDomain());
248 EXPECT_EQ("", install_attributes_.GetRegistrationUser()); 248 EXPECT_EQ("", install_attributes_.GetRegistrationUser());
249 EXPECT_EQ("", install_attributes_.GetDeviceId()); 249 EXPECT_EQ("", install_attributes_.GetDeviceId());
250 } 250 }
251 251
252 } // namespace policy 252 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698