| Index: chrome/browser/policy/enterprise_install_attributes_unittest.cc
|
| diff --git a/chrome/browser/policy/enterprise_install_attributes_unittest.cc b/chrome/browser/policy/enterprise_install_attributes_unittest.cc
|
| index 748c765d39efed79e97be6b3516831fcc0cfb0b5..6c54ac41a4ee1fe8f818d76457e0f59718094691 100644
|
| --- a/chrome/browser/policy/enterprise_install_attributes_unittest.cc
|
| +++ b/chrome/browser/policy/enterprise_install_attributes_unittest.cc
|
| @@ -11,6 +11,11 @@
|
| namespace policy {
|
|
|
| static const char kTestUser[] = "test@example.com";
|
| +static const char kTestDomain[] = "example.com";
|
| +static const char kTestDeviceId[] = "133750519";
|
| +
|
| +static const char kAttrEnterpriseOwned[] = "enterprise.owned";
|
| +static const char kAttrEnterpriseUser[] = "enterprise.user";
|
|
|
| class EnterpriseInstallAttributesTest : public testing::Test {
|
| protected:
|
| @@ -24,33 +29,99 @@ class EnterpriseInstallAttributesTest : public testing::Test {
|
|
|
| TEST_F(EnterpriseInstallAttributesTest, Lock) {
|
| EXPECT_EQ(EnterpriseInstallAttributes::LOCK_SUCCESS,
|
| - install_attributes_.LockDevice(kTestUser));
|
| + install_attributes_.LockDevice(
|
| + kTestUser,
|
| + DEVICE_MODE_ENTERPRISE,
|
| + kTestDeviceId));
|
|
|
| EXPECT_EQ(EnterpriseInstallAttributes::LOCK_SUCCESS,
|
| - install_attributes_.LockDevice(kTestUser));
|
| + install_attributes_.LockDevice(
|
| + kTestUser,
|
| + DEVICE_MODE_ENTERPRISE,
|
| + kTestDeviceId));
|
| EXPECT_EQ(EnterpriseInstallAttributes::LOCK_WRONG_USER,
|
| - install_attributes_.LockDevice("test1@example.com"));
|
| + install_attributes_.LockDevice(
|
| + "test1@example.com",
|
| + DEVICE_MODE_ENTERPRISE,
|
| + kTestDeviceId));
|
| }
|
|
|
| TEST_F(EnterpriseInstallAttributesTest, IsEnterpriseDevice) {
|
| EXPECT_FALSE(install_attributes_.IsEnterpriseDevice());
|
| ASSERT_EQ(EnterpriseInstallAttributes::LOCK_SUCCESS,
|
| - install_attributes_.LockDevice(kTestUser));
|
| + install_attributes_.LockDevice(
|
| + kTestUser,
|
| + DEVICE_MODE_ENTERPRISE,
|
| + kTestDeviceId));
|
| EXPECT_TRUE(install_attributes_.IsEnterpriseDevice());
|
| }
|
|
|
| TEST_F(EnterpriseInstallAttributesTest, GetDomain) {
|
| EXPECT_EQ(std::string(), install_attributes_.GetDomain());
|
| ASSERT_EQ(EnterpriseInstallAttributes::LOCK_SUCCESS,
|
| - install_attributes_.LockDevice(kTestUser));
|
| - EXPECT_EQ("example.com", install_attributes_.GetDomain());
|
| + install_attributes_.LockDevice(
|
| + kTestUser,
|
| + DEVICE_MODE_ENTERPRISE,
|
| + kTestDeviceId));
|
| + EXPECT_EQ(kTestDomain, install_attributes_.GetDomain());
|
| }
|
|
|
| TEST_F(EnterpriseInstallAttributesTest, GetRegistrationUser) {
|
| EXPECT_EQ(std::string(), install_attributes_.GetRegistrationUser());
|
| ASSERT_EQ(EnterpriseInstallAttributes::LOCK_SUCCESS,
|
| - install_attributes_.LockDevice(kTestUser));
|
| + install_attributes_.LockDevice(
|
| + kTestUser,
|
| + DEVICE_MODE_ENTERPRISE,
|
| + kTestDeviceId));
|
| + EXPECT_EQ(kTestUser, install_attributes_.GetRegistrationUser());
|
| +}
|
| +
|
| +TEST_F(EnterpriseInstallAttributesTest, GetDeviceId) {
|
| + EXPECT_EQ(std::string(), install_attributes_.GetDeviceId());
|
| + ASSERT_EQ(EnterpriseInstallAttributes::LOCK_SUCCESS,
|
| + install_attributes_.LockDevice(
|
| + kTestUser,
|
| + DEVICE_MODE_ENTERPRISE,
|
| + kTestDeviceId));
|
| + EXPECT_EQ(kTestDeviceId, install_attributes_.GetDeviceId());
|
| +}
|
| +
|
| +TEST_F(EnterpriseInstallAttributesTest, GetMode) {
|
| + EXPECT_EQ(DEVICE_MODE_UNKNOWN,
|
| + install_attributes_.GetMode());
|
| + ASSERT_EQ(EnterpriseInstallAttributes::LOCK_SUCCESS,
|
| + install_attributes_.LockDevice(
|
| + kTestUser,
|
| + DEVICE_MODE_KIOSK,
|
| + kTestDeviceId));
|
| + EXPECT_EQ(DEVICE_MODE_KIOSK,
|
| + install_attributes_.GetMode());
|
| +}
|
| +
|
| +TEST_F(EnterpriseInstallAttributesTest, ConsumerDevice) {
|
| + EXPECT_EQ(DEVICE_MODE_UNKNOWN,
|
| + install_attributes_.GetMode());
|
| + // Lock the attributes empty.
|
| + ASSERT_TRUE(cryptohome_->InstallAttributesFinalize());
|
| + ASSERT_FALSE(cryptohome_->InstallAttributesIsFirstInstall());
|
| + EXPECT_EQ(DEVICE_MODE_CONSUMER,
|
| + install_attributes_.GetMode());
|
| +}
|
| +
|
| +TEST_F(EnterpriseInstallAttributesTest, DeviceLockedFromOlderVersion) {
|
| + EXPECT_EQ(DEVICE_MODE_UNKNOWN,
|
| + install_attributes_.GetMode());
|
| + // Lock the attributes as if it was done from older Chrome version.
|
| + ASSERT_TRUE(cryptohome_->InstallAttributesSet(kAttrEnterpriseOwned, "true"));
|
| + ASSERT_TRUE(cryptohome_->InstallAttributesSet(kAttrEnterpriseUser,
|
| + kTestUser));
|
| + ASSERT_TRUE(cryptohome_->InstallAttributesFinalize());
|
| + ASSERT_FALSE(cryptohome_->InstallAttributesIsFirstInstall());
|
| + EXPECT_EQ(DEVICE_MODE_ENTERPRISE,
|
| + install_attributes_.GetMode());
|
| + EXPECT_EQ(kTestDomain, install_attributes_.GetDomain());
|
| EXPECT_EQ(kTestUser, install_attributes_.GetRegistrationUser());
|
| + EXPECT_EQ("", install_attributes_.GetDeviceId());
|
| }
|
|
|
| } // namespace policy
|
|
|