Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_MOCK_KEYCHAIN_MAC_H_ | 5 #ifndef CRYPTO_MOCK_KEYCHAIN_MAC_H_ |
| 6 #define CHROME_BROWSER_MOCK_KEYCHAIN_MAC_H_ | 6 #define CRYPTO_MOCK_KEYCHAIN_MAC_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
| 15 #include "chrome/browser/keychain_mac.h" | 15 #include "crypto/keychain_mac.h" |
| 16 | |
| 17 namespace crypto { | |
| 16 | 18 |
| 17 // Mock Keychain wrapper for testing code that interacts with the OS Keychain. | 19 // Mock Keychain wrapper for testing code that interacts with the OS Keychain. |
|
Ryan Sleevi
2012/03/16 20:58:37
nit: OS X Keychain?
akalin
2012/03/17 07:19:44
Done.
| |
| 18 // Implemented by storing SecKeychainAttributeList and KeychainPasswordData | 20 // Implemented by storing SecKeychainAttributeList and KeychainPasswordData |
| 19 // values in separate mutable containers and mapping them to integer keys. | 21 // values in separate mutable containers and mapping them to integer keys. |
| 20 // | 22 // |
| 21 // Note that "const" is pretty much meaningless for this class; the const-ness | 23 // Note that "const" is pretty much meaningless for this class; the const-ness |
| 22 // of MacKeychain doesn't apply to the actual keychain data, so all of the Mock | 24 // of MacKeychain doesn't apply to the actual keychain data, so all of the Mock |
| 23 // data is mutable; don't assume that it won't change over the life of tests. | 25 // data is mutable; don't assume that it won't change over the life of tests. |
| 24 class MockKeychain : public MacKeychain { | 26 class MockKeychain : public MacKeychain { |
| 25 public: | 27 public: |
| 26 MockKeychain(); | 28 MockKeychain(); |
| 27 virtual ~MockKeychain(); | 29 virtual ~MockKeychain(); |
| 28 virtual OSStatus ItemCopyAttributesAndData( | 30 virtual OSStatus ItemCopyAttributesAndData( |
|
Ryan Sleevi
2012/03/16 20:58:37
Per http://www.chromium.org/developers/coding-styl
akalin
2012/03/17 07:19:44
Done.
| |
| 29 SecKeychainItemRef itemRef, SecKeychainAttributeInfo *info, | 31 SecKeychainItemRef itemRef, SecKeychainAttributeInfo *info, |
| 30 SecItemClass *itemClass, SecKeychainAttributeList **attrList, | 32 SecItemClass *itemClass, SecKeychainAttributeList **attrList, |
| 31 UInt32 *length, void **outData) const OVERRIDE; | 33 UInt32 *length, void **outData) const OVERRIDE; |
| 32 // Pass "fail_me" as the data to get errSecAuthFailed. | 34 // Pass "fail_me" as the data to get errSecAuthFailed. |
| 33 virtual OSStatus ItemModifyAttributesAndData( | 35 virtual OSStatus ItemModifyAttributesAndData( |
| 34 SecKeychainItemRef itemRef, const SecKeychainAttributeList *attrList, | 36 SecKeychainItemRef itemRef, const SecKeychainAttributeList *attrList, |
| 35 UInt32 length, const void *data) const OVERRIDE; | 37 UInt32 length, const void *data) const OVERRIDE; |
| 36 virtual OSStatus ItemFreeAttributesAndData(SecKeychainAttributeList *attrList, | 38 virtual OSStatus ItemFreeAttributesAndData(SecKeychainAttributeList *attrList, |
| 37 void *data) const OVERRIDE; | 39 void *data) const OVERRIDE; |
| 38 virtual OSStatus ItemDelete(SecKeychainItemRef itemRef) const OVERRIDE; | 40 virtual OSStatus ItemDelete(SecKeychainItemRef itemRef) const OVERRIDE; |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 197 mutable bool called_add_generic_; | 199 mutable bool called_add_generic_; |
| 198 | 200 |
| 199 // Tracks the allocations and frees of password data in |FindGenericPassword| | 201 // Tracks the allocations and frees of password data in |FindGenericPassword| |
| 200 // and |ItemFreeContent|. | 202 // and |ItemFreeContent|. |
| 201 mutable unsigned int password_data_count_; | 203 mutable unsigned int password_data_count_; |
| 202 | 204 |
| 203 // Records the password being set when |AddGenericPassword()| gets called. | 205 // Records the password being set when |AddGenericPassword()| gets called. |
| 204 mutable std::string add_generic_password_; | 206 mutable std::string add_generic_password_; |
| 205 }; | 207 }; |
| 206 | 208 |
| 207 #endif // CHROME_BROWSER_MOCK_KEYCHAIN_MAC_H_ | 209 } // namespace crypto |
| 210 | |
| 211 #endif // CRYPTO_MOCK_KEYCHAIN_MAC_H_ | |
| OLD | NEW |