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

Unified Diff: chrome/browser/policy/enterprise_install_attributes_unittest.cc

Issue 12189011: Split up chrome/browser/policy subdirectory (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase, add chrome/browser/chromeos/policy/OWNERS Created 7 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/policy/enterprise_install_attributes.cc ('k') | chrome/browser/policy/enterprise_metrics.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
deleted file mode 100644
index 4ca8a688dcd621357ffd638ae81ed2b6f142b567..0000000000000000000000000000000000000000
--- a/chrome/browser/policy/enterprise_install_attributes_unittest.cc
+++ /dev/null
@@ -1,174 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/policy/enterprise_install_attributes.h"
-
-#include "base/file_util.h"
-#include "base/files/scoped_temp_dir.h"
-#include "base/memory/scoped_ptr.h"
-#include "chrome/browser/chromeos/cros/cryptohome_library.h"
-#include "chrome/browser/policy/proto/install_attributes.pb.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace policy {
-
-static const char kTestUser[] = "test@example.com";
-static const char kTestDomain[] = "example.com";
-static const char kTestDeviceId[] = "133750519";
-
-class EnterpriseInstallAttributesTest : public testing::Test {
- protected:
- EnterpriseInstallAttributesTest()
- : cryptohome_(chromeos::CryptohomeLibrary::GetImpl(true)),
- install_attributes_(cryptohome_.get()) {}
-
- virtual void SetUp() OVERRIDE {
- ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
- }
-
- base::FilePath GetTempPath() const {
- return temp_dir_.path().Append("install_attrs_test");
- }
-
- void SetAttribute(
- cryptohome::SerializedInstallAttributes* install_attrs_proto,
- const std::string& name,
- const std::string& value) {
- cryptohome::SerializedInstallAttributes::Attribute* attribute;
- attribute = install_attrs_proto->add_attributes();
- attribute->set_name(name);
- attribute->set_value(value);
- }
-
- base::ScopedTempDir temp_dir_;
- scoped_ptr<chromeos::CryptohomeLibrary> cryptohome_;
- EnterpriseInstallAttributes install_attributes_;
-};
-
-TEST_F(EnterpriseInstallAttributesTest, Lock) {
- EXPECT_EQ(EnterpriseInstallAttributes::LOCK_SUCCESS,
- install_attributes_.LockDevice(
- kTestUser,
- DEVICE_MODE_ENTERPRISE,
- kTestDeviceId));
-
- EXPECT_EQ(EnterpriseInstallAttributes::LOCK_SUCCESS,
- install_attributes_.LockDevice(
- kTestUser,
- DEVICE_MODE_ENTERPRISE,
- kTestDeviceId));
- // Another user from the4 same domain should also succeed.
- EXPECT_EQ(EnterpriseInstallAttributes::LOCK_SUCCESS,
- install_attributes_.LockDevice(
- "test1@example.com",
- DEVICE_MODE_ENTERPRISE,
- kTestDeviceId));
- // But another domain should fail.
- EXPECT_EQ(EnterpriseInstallAttributes::LOCK_WRONG_USER,
- install_attributes_.LockDevice(
- "test@bluebears.com",
- DEVICE_MODE_ENTERPRISE,
- kTestDeviceId));
-}
-
-TEST_F(EnterpriseInstallAttributesTest, IsEnterpriseDevice) {
- install_attributes_.ReadCacheFile(GetTempPath());
- EXPECT_FALSE(install_attributes_.IsEnterpriseDevice());
- ASSERT_EQ(EnterpriseInstallAttributes::LOCK_SUCCESS,
- install_attributes_.LockDevice(
- kTestUser,
- DEVICE_MODE_ENTERPRISE,
- kTestDeviceId));
- EXPECT_TRUE(install_attributes_.IsEnterpriseDevice());
-}
-
-TEST_F(EnterpriseInstallAttributesTest, GetDomain) {
- install_attributes_.ReadCacheFile(GetTempPath());
- EXPECT_EQ(std::string(), install_attributes_.GetDomain());
- ASSERT_EQ(EnterpriseInstallAttributes::LOCK_SUCCESS,
- install_attributes_.LockDevice(
- kTestUser,
- DEVICE_MODE_ENTERPRISE,
- kTestDeviceId));
- EXPECT_EQ(kTestDomain, install_attributes_.GetDomain());
-}
-
-TEST_F(EnterpriseInstallAttributesTest, GetRegistrationUser) {
- install_attributes_.ReadCacheFile(GetTempPath());
- EXPECT_EQ(std::string(), install_attributes_.GetRegistrationUser());
- ASSERT_EQ(EnterpriseInstallAttributes::LOCK_SUCCESS,
- install_attributes_.LockDevice(
- kTestUser,
- DEVICE_MODE_ENTERPRISE,
- kTestDeviceId));
- EXPECT_EQ(kTestUser, install_attributes_.GetRegistrationUser());
-}
-
-TEST_F(EnterpriseInstallAttributesTest, GetDeviceId) {
- install_attributes_.ReadCacheFile(GetTempPath());
- 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) {
- install_attributes_.ReadCacheFile(GetTempPath());
- EXPECT_EQ(DEVICE_MODE_PENDING, 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) {
- install_attributes_.ReadCacheFile(GetTempPath());
- EXPECT_EQ(DEVICE_MODE_PENDING, install_attributes_.GetMode());
- // Lock the attributes empty.
- ASSERT_TRUE(cryptohome_->InstallAttributesFinalize());
- install_attributes_.ReadImmutableAttributes();
- ASSERT_FALSE(cryptohome_->InstallAttributesIsFirstInstall());
- EXPECT_EQ(DEVICE_MODE_CONSUMER, install_attributes_.GetMode());
-}
-
-TEST_F(EnterpriseInstallAttributesTest, DeviceLockedFromOlderVersion) {
- install_attributes_.ReadCacheFile(GetTempPath());
- EXPECT_EQ(DEVICE_MODE_PENDING, install_attributes_.GetMode());
- // Lock the attributes as if it was done from older Chrome version.
- ASSERT_TRUE(cryptohome_->InstallAttributesSet(
- EnterpriseInstallAttributes::kAttrEnterpriseOwned, "true"));
- ASSERT_TRUE(cryptohome_->InstallAttributesSet(
- EnterpriseInstallAttributes::kAttrEnterpriseUser, kTestUser));
- ASSERT_TRUE(cryptohome_->InstallAttributesFinalize());
- install_attributes_.ReadImmutableAttributes();
- 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());
-}
-
-TEST_F(EnterpriseInstallAttributesTest, ReadCacheFile) {
- cryptohome::SerializedInstallAttributes install_attrs_proto;
- SetAttribute(&install_attrs_proto,
- EnterpriseInstallAttributes::kAttrEnterpriseOwned, "true");
- SetAttribute(&install_attrs_proto,
- EnterpriseInstallAttributes::kAttrEnterpriseUser, kTestUser);
- const std::string blob(install_attrs_proto.SerializeAsString());
- ASSERT_EQ(static_cast<int>(blob.size()),
- file_util::WriteFile(GetTempPath(), blob.c_str(), blob.size()));
- install_attributes_.ReadCacheFile(GetTempPath());
- 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
« no previous file with comments | « chrome/browser/policy/enterprise_install_attributes.cc ('k') | chrome/browser/policy/enterprise_metrics.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698