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

Side by Side Diff: chrome/browser/policy/enterprise_install_attributes_unittest.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: " 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
OLDNEW
1 // Copyright (c) 2011 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/policy/enterprise_install_attributes.h" 5 #include "chrome/browser/policy/enterprise_install_attributes.h"
6 6
7 #include "chrome/browser/chromeos/cros/cryptohome_library.h" 7 #include "chrome/browser/chromeos/cros/cryptohome_library.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 namespace em = enterprise_management;
11
10 namespace policy { 12 namespace policy {
11 13
12 static const char kTestUser[] = "test@example.com"; 14 static const char kTestUser[] = "test@example.com";
15 static const char kTestDomain[] = "example.com";
16 static const char kTestDeviceId[] = "133750519";
13 17
14 class EnterpriseInstallAttributesTest : public testing::Test { 18 class EnterpriseInstallAttributesTest : public testing::Test {
15 protected: 19 protected:
16 EnterpriseInstallAttributesTest() 20 EnterpriseInstallAttributesTest()
17 : cryptohome_(chromeos::CryptohomeLibrary::GetImpl(true)), 21 : cryptohome_(chromeos::CryptohomeLibrary::GetImpl(true)),
18 install_attributes_(cryptohome_.get()) {} 22 install_attributes_(cryptohome_.get()) {}
19 23
20 scoped_ptr<chromeos::CryptohomeLibrary> cryptohome_; 24 scoped_ptr<chromeos::CryptohomeLibrary> cryptohome_;
21 EnterpriseInstallAttributes install_attributes_; 25 EnterpriseInstallAttributes install_attributes_;
22 }; 26 };
23 27
24 TEST_F(EnterpriseInstallAttributesTest, Lock) { 28 TEST_F(EnterpriseInstallAttributesTest, Lock) {
25 EXPECT_EQ(EnterpriseInstallAttributes::LOCK_SUCCESS, 29 EXPECT_EQ(EnterpriseInstallAttributes::LOCK_SUCCESS,
26 install_attributes_.LockDevice(kTestUser)); 30 install_attributes_.LockDevice(
31 kTestUser,
32 em::DeviceRegisterResponse::ENTERPRISE,
33 kTestDeviceId));
27 34
28 EXPECT_EQ(EnterpriseInstallAttributes::LOCK_SUCCESS, 35 EXPECT_EQ(EnterpriseInstallAttributes::LOCK_SUCCESS,
29 install_attributes_.LockDevice(kTestUser)); 36 install_attributes_.LockDevice(
37 kTestUser,
38 em::DeviceRegisterResponse::ENTERPRISE,
39 kTestDeviceId));
30 EXPECT_EQ(EnterpriseInstallAttributes::LOCK_WRONG_USER, 40 EXPECT_EQ(EnterpriseInstallAttributes::LOCK_WRONG_USER,
31 install_attributes_.LockDevice("test1@example.com")); 41 install_attributes_.LockDevice(
42 "test1@example.com",
43 em::DeviceRegisterResponse::ENTERPRISE,
44 kTestDeviceId));
32 } 45 }
33 46
34 TEST_F(EnterpriseInstallAttributesTest, IsEnterpriseDevice) { 47 TEST_F(EnterpriseInstallAttributesTest, IsEnterpriseDevice) {
35 EXPECT_FALSE(install_attributes_.IsEnterpriseDevice()); 48 EXPECT_FALSE(install_attributes_.IsEnterpriseDevice());
36 ASSERT_EQ(EnterpriseInstallAttributes::LOCK_SUCCESS, 49 ASSERT_EQ(EnterpriseInstallAttributes::LOCK_SUCCESS,
37 install_attributes_.LockDevice(kTestUser)); 50 install_attributes_.LockDevice(
51 kTestUser,
52 em::DeviceRegisterResponse::ENTERPRISE,
53 kTestDeviceId));
38 EXPECT_TRUE(install_attributes_.IsEnterpriseDevice()); 54 EXPECT_TRUE(install_attributes_.IsEnterpriseDevice());
39 } 55 }
40 56
41 TEST_F(EnterpriseInstallAttributesTest, GetDomain) { 57 TEST_F(EnterpriseInstallAttributesTest, GetDomain) {
42 EXPECT_EQ(std::string(), install_attributes_.GetDomain()); 58 EXPECT_EQ(std::string(), install_attributes_.GetDomain());
43 ASSERT_EQ(EnterpriseInstallAttributes::LOCK_SUCCESS, 59 ASSERT_EQ(EnterpriseInstallAttributes::LOCK_SUCCESS,
44 install_attributes_.LockDevice(kTestUser)); 60 install_attributes_.LockDevice(
45 EXPECT_EQ("example.com", install_attributes_.GetDomain()); 61 kTestUser,
62 em::DeviceRegisterResponse::ENTERPRISE,
63 kTestDeviceId));
64 EXPECT_EQ(kTestDomain, install_attributes_.GetDomain());
46 } 65 }
47 66
48 TEST_F(EnterpriseInstallAttributesTest, GetRegistrationUser) { 67 TEST_F(EnterpriseInstallAttributesTest, GetRegistrationUser) {
49 EXPECT_EQ(std::string(), install_attributes_.GetRegistrationUser()); 68 EXPECT_EQ(std::string(), install_attributes_.GetRegistrationUser());
50 ASSERT_EQ(EnterpriseInstallAttributes::LOCK_SUCCESS, 69 ASSERT_EQ(EnterpriseInstallAttributes::LOCK_SUCCESS,
51 install_attributes_.LockDevice(kTestUser)); 70 install_attributes_.LockDevice(
71 kTestUser,
72 em::DeviceRegisterResponse::ENTERPRISE,
73 kTestDeviceId));
52 EXPECT_EQ(kTestUser, install_attributes_.GetRegistrationUser()); 74 EXPECT_EQ(kTestUser, install_attributes_.GetRegistrationUser());
53 } 75 }
54 76
77 TEST_F(EnterpriseInstallAttributesTest, GetDeviceId) {
78 EXPECT_EQ(std::string(), install_attributes_.GetDeviceId());
79 ASSERT_EQ(EnterpriseInstallAttributes::LOCK_SUCCESS,
80 install_attributes_.LockDevice(
81 kTestUser,
82 em::DeviceRegisterResponse::ENTERPRISE,
83 kTestDeviceId));
84 EXPECT_EQ(kTestDeviceId, install_attributes_.GetDeviceId());
85 }
86
87 TEST_F(EnterpriseInstallAttributesTest, GetMode) {
88 EXPECT_EQ(em::DeviceRegisterResponse::ENTERPRISE,
89 install_attributes_.GetMode());
90 ASSERT_EQ(EnterpriseInstallAttributes::LOCK_SUCCESS,
91 install_attributes_.LockDevice(
92 kTestUser,
93 em::DeviceRegisterResponse::KIOSK,
94 kTestDeviceId));
95 EXPECT_EQ(em::DeviceRegisterResponse::KIOSK, install_attributes_.GetMode());
96 }
97
55 } // namespace policy 98 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698