| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/login/owner_manager.h" | 5 #include "chrome/browser/chromeos/login/owner_manager.h" |
| 6 | 6 |
| 7 #include <cert.h> | 7 #include <cert.h> |
| 8 #include <keyhi.h> | 8 #include <keyhi.h> |
| 9 #include <keythi.h> // KeyType enum | 9 #include <keythi.h> // KeyType enum |
| 10 #include <pk11pub.h> | 10 #include <pk11pub.h> |
| 11 #include <stdlib.h> | 11 #include <stdlib.h> |
| 12 | 12 |
| 13 #include <string> | 13 #include <string> |
| 14 | 14 |
| 15 #include "base/crypto/rsa_private_key.h" | 15 #include "base/crypto/rsa_private_key.h" |
| 16 #include "base/file_path.h" | 16 #include "base/file_path.h" |
| 17 #include "base/file_util.h" | 17 #include "base/file_util.h" |
| 18 #include "base/logging.h" | 18 #include "base/logging.h" |
| 19 #include "base/nss_util_internal.h" | 19 #include "base/nss_util_internal.h" |
| 20 #include "base/nss_util.h" | 20 #include "base/nss_util.h" |
| 21 #include "base/scoped_temp_dir.h" | 21 #include "base/scoped_temp_dir.h" |
| 22 #include "chrome/browser/chrome_thread.h" | 22 #include "chrome/browser/chrome_thread.h" |
| 23 #include "chrome/common/notification_observer.h" |
| 23 #include "chrome/common/notification_registrar.h" | 24 #include "chrome/common/notification_registrar.h" |
| 24 #include "chrome/common/notification_service.h" | 25 #include "chrome/common/notification_service.h" |
| 25 #include "chrome/common/notification_type.h" | 26 #include "chrome/common/notification_type.h" |
| 26 #include "testing/gmock/include/gmock/gmock.h" | 27 #include "testing/gmock/include/gmock/gmock.h" |
| 27 #include "testing/gtest/include/gtest/gtest.h" | 28 #include "testing/gtest/include/gtest/gtest.h" |
| 28 | 29 |
| 29 using ::base::RSAPrivateKey; | 30 using ::base::RSAPrivateKey; |
| 30 using ::testing::DoAll; | 31 using ::testing::DoAll; |
| 31 using ::testing::Invoke; | 32 using ::testing::Invoke; |
| 32 using ::testing::Return; | 33 using ::testing::Return; |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 .RetiresOnSaturation(); | 233 .RetiresOnSaturation(); |
| 233 | 234 |
| 234 scoped_refptr<OwnerManager> manager(new OwnerManager); | 235 scoped_refptr<OwnerManager> manager(new OwnerManager); |
| 235 EXPECT_TRUE(manager->StartLoadOwnerKeyAttempt()); | 236 EXPECT_TRUE(manager->StartLoadOwnerKeyAttempt()); |
| 236 | 237 |
| 237 // Run remaining events, until ExportPublicKeyViaDbus(). | 238 // Run remaining events, until ExportPublicKeyViaDbus(). |
| 238 message_loop_.Run(); | 239 message_loop_.Run(); |
| 239 } | 240 } |
| 240 | 241 |
| 241 TEST_F(OwnerManagerTest, TakeOwnershipAlreadyOwned) { | 242 TEST_F(OwnerManagerTest, TakeOwnershipAlreadyOwned) { |
| 242 | |
| 243 EXPECT_CALL(*mock_, GetOwnerKeyFilePath()) | 243 EXPECT_CALL(*mock_, GetOwnerKeyFilePath()) |
| 244 .WillRepeatedly(Return(tmpfile_)); | 244 .WillRepeatedly(Return(tmpfile_)); |
| 245 | 245 |
| 246 scoped_refptr<OwnerManager> manager(new OwnerManager); | 246 scoped_refptr<OwnerManager> manager(new OwnerManager); |
| 247 EXPECT_FALSE(manager->StartTakeOwnershipAttempt()); | 247 EXPECT_FALSE(manager->StartTakeOwnershipAttempt()); |
| 248 } | 248 } |
| 249 | 249 |
| 250 TEST_F(OwnerManagerTest, KeyGenerationFail) { | 250 TEST_F(OwnerManagerTest, KeyGenerationFail) { |
| 251 StartUnowned(); | 251 StartUnowned(); |
| 252 | 252 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 .RetiresOnSaturation(); | 353 .RetiresOnSaturation(); |
| 354 | 354 |
| 355 scoped_refptr<OwnerManager> manager(new OwnerManager); | 355 scoped_refptr<OwnerManager> manager(new OwnerManager); |
| 356 KeyUser delegate(OwnerManager::SUCCESS); | 356 KeyUser delegate(OwnerManager::SUCCESS); |
| 357 EXPECT_TRUE(manager->StartVerifyAttempt("", "", &delegate)); | 357 EXPECT_TRUE(manager->StartVerifyAttempt("", "", &delegate)); |
| 358 | 358 |
| 359 message_loop_.Run(); | 359 message_loop_.Run(); |
| 360 } | 360 } |
| 361 | 361 |
| 362 } // namespace chromeos | 362 } // namespace chromeos |
| OLD | NEW |