OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/device_policy_cros_browser_test.h" | 5 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "base/files/scoped_temp_dir.h" | 11 #include "base/files/scoped_temp_dir.h" |
12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
13 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
14 #include "chrome/browser/chromeos/policy/device_policy_builder.h" | 14 #include "chrome/browser/chromeos/policy/device_policy_builder.h" |
15 #include "chrome/common/chrome_paths.h" | 15 #include "chromeos/chromeos_paths.h" |
16 #include "chromeos/dbus/mock_dbus_thread_manager.h" | 16 #include "chromeos/dbus/mock_dbus_thread_manager.h" |
17 #include "chromeos/dbus/mock_image_burner_client.h" | 17 #include "chromeos/dbus/mock_image_burner_client.h" |
18 #include "crypto/rsa_private_key.h" | 18 #include "crypto/rsa_private_key.h" |
19 #include "testing/gmock/include/gmock/gmock.h" | 19 #include "testing/gmock/include/gmock/gmock.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
21 | 21 |
22 using ::testing::_; | 22 using ::testing::_; |
23 using ::testing::AnyNumber; | 23 using ::testing::AnyNumber; |
24 using ::testing::Return; | 24 using ::testing::Return; |
25 | 25 |
(...skipping 29 matching lines...) Expand all Loading... |
55 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 55 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
56 base::FilePath owner_key_file = temp_dir_.path().AppendASCII("owner.key"); | 56 base::FilePath owner_key_file = temp_dir_.path().AppendASCII("owner.key"); |
57 std::vector<uint8> owner_key_bits; | 57 std::vector<uint8> owner_key_bits; |
58 ASSERT_TRUE(device_policy()->signing_key()->ExportPublicKey(&owner_key_bits)); | 58 ASSERT_TRUE(device_policy()->signing_key()->ExportPublicKey(&owner_key_bits)); |
59 ASSERT_EQ( | 59 ASSERT_EQ( |
60 file_util::WriteFile( | 60 file_util::WriteFile( |
61 owner_key_file, | 61 owner_key_file, |
62 reinterpret_cast<const char*>(vector_as_array(&owner_key_bits)), | 62 reinterpret_cast<const char*>(vector_as_array(&owner_key_bits)), |
63 owner_key_bits.size()), | 63 owner_key_bits.size()), |
64 static_cast<int>(owner_key_bits.size())); | 64 static_cast<int>(owner_key_bits.size())); |
65 ASSERT_TRUE(PathService::Override(chrome::FILE_OWNER_KEY, owner_key_file)); | 65 ASSERT_TRUE(PathService::Override(chromeos::FILE_OWNER_KEY, owner_key_file)); |
66 } | 66 } |
67 | 67 |
68 void DevicePolicyCrosBrowserTest::RefreshDevicePolicy() { | 68 void DevicePolicyCrosBrowserTest::RefreshDevicePolicy() { |
69 // Reset the key to its original state. | 69 // Reset the key to its original state. |
70 device_policy_.set_signing_key(PolicyBuilder::CreateTestSigningKey()); | 70 device_policy_.set_signing_key(PolicyBuilder::CreateTestSigningKey()); |
71 device_policy_.Build(); | 71 device_policy_.Build(); |
72 // The local instance of the private half of the owner key must be dropped | 72 // The local instance of the private half of the owner key must be dropped |
73 // as otherwise the NSS library will tell Chrome that the key is available - | 73 // as otherwise the NSS library will tell Chrome that the key is available - |
74 // which is incorrect and leads to Chrome behaving as if a local owner were | 74 // which is incorrect and leads to Chrome behaving as if a local owner were |
75 // logged in. | 75 // logged in. |
76 device_policy_.set_signing_key( | 76 device_policy_.set_signing_key( |
77 make_scoped_ptr<crypto::RSAPrivateKey>(NULL)); | 77 make_scoped_ptr<crypto::RSAPrivateKey>(NULL)); |
78 device_policy_.set_new_signing_key( | 78 device_policy_.set_new_signing_key( |
79 make_scoped_ptr<crypto::RSAPrivateKey>(NULL)); | 79 make_scoped_ptr<crypto::RSAPrivateKey>(NULL)); |
80 session_manager_client_.set_device_policy(device_policy_.GetBlob()); | 80 session_manager_client_.set_device_policy(device_policy_.GetBlob()); |
81 session_manager_client_.OnPropertyChangeComplete(true); | 81 session_manager_client_.OnPropertyChangeComplete(true); |
82 } | 82 } |
83 | 83 |
84 void DevicePolicyCrosBrowserTest::TearDownInProcessBrowserTestFixture() { | 84 void DevicePolicyCrosBrowserTest::TearDownInProcessBrowserTestFixture() { |
85 CrosInProcessBrowserTest::TearDownInProcessBrowserTestFixture(); | 85 CrosInProcessBrowserTest::TearDownInProcessBrowserTestFixture(); |
86 chromeos::DBusThreadManager::Shutdown(); | 86 chromeos::DBusThreadManager::Shutdown(); |
87 } | 87 } |
88 | 88 |
89 } // namespace policy | 89 } // namespace policy |
OLD | NEW |