| OLD | NEW |
| 1 // Copyright (c) 2012 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/mock_keychain_mac.h" | |
| 6 #include "chrome/browser/password_manager/encryptor_password_mac.h" | 5 #include "chrome/browser/password_manager/encryptor_password_mac.h" |
| 6 #include "crypto/mock_keychain_mac.h" |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 | 8 |
| 9 namespace { | 9 namespace { |
| 10 | 10 |
| 11 using crypto::MockKeychain; |
| 12 |
| 11 // Test that if we have an existing password in the Keychain and we are | 13 // Test that if we have an existing password in the Keychain and we are |
| 12 // authorized by the user to read it then we get it back correctly. | 14 // authorized by the user to read it then we get it back correctly. |
| 13 TEST(EncryptorPasswordTest, FindPasswordSuccess) { | 15 TEST(EncryptorPasswordTest, FindPasswordSuccess) { |
| 14 MockKeychain keychain; | 16 MockKeychain keychain; |
| 15 keychain.set_find_generic_result(noErr); | 17 keychain.set_find_generic_result(noErr); |
| 16 EncryptorPassword password(keychain); | 18 EncryptorPassword password(keychain); |
| 17 EXPECT_FALSE(password.GetEncryptorPassword().empty()); | 19 EXPECT_FALSE(password.GetEncryptorPassword().empty()); |
| 18 EXPECT_FALSE(keychain.called_add_generic()); | 20 EXPECT_FALSE(keychain.called_add_generic()); |
| 19 EXPECT_EQ(0, keychain.password_data_count()); | 21 EXPECT_EQ(0, keychain.password_data_count()); |
| 20 } | 22 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 std::string password2 = encryptor_password2.GetEncryptorPassword(); | 70 std::string password2 = encryptor_password2.GetEncryptorPassword(); |
| 69 EXPECT_FALSE(password2.empty()); | 71 EXPECT_FALSE(password2.empty()); |
| 70 EXPECT_TRUE(keychain2.called_add_generic()); | 72 EXPECT_TRUE(keychain2.called_add_generic()); |
| 71 EXPECT_EQ(0, keychain2.password_data_count()); | 73 EXPECT_EQ(0, keychain2.password_data_count()); |
| 72 | 74 |
| 73 // And finally check that the passwords are different. | 75 // And finally check that the passwords are different. |
| 74 EXPECT_NE(password1, password2); | 76 EXPECT_NE(password1, password2); |
| 75 } | 77 } |
| 76 | 78 |
| 77 } // namespace | 79 } // namespace |
| OLD | NEW |