Index: crypto/mock_apple_keychain_mac.cc |
diff --git a/crypto/mock_apple_keychain_mac.cc b/crypto/mock_apple_keychain_mac.cc |
index d586f70b3633f8db9150a54a03cefe1622f76363..3181c973fefaee7fd3d76d7f0003c9c8241aacd3 100644 |
--- a/crypto/mock_apple_keychain_mac.cc |
+++ b/crypto/mock_apple_keychain_mac.cc |
@@ -12,6 +12,8 @@ namespace crypto { |
const SecKeychainSearchRef MockAppleKeychain::kDummySearchRef = |
reinterpret_cast<SecKeychainSearchRef>(1000); |
+bool MockAppleKeychain::locked_ = false; |
+ |
MockAppleKeychain::MockAppleKeychain() |
: next_item_key_(0), |
search_copy_count_(0), |
@@ -195,6 +197,9 @@ OSStatus MockAppleKeychain::ItemCopyAttributesAndData( |
return errSecInvalidItemRef; |
DCHECK(!itemClass); // itemClass not implemented in the Mock. |
+ if (locked_) |
+ return errSecAuthFailed; |
+ |
if (attrList) |
*attrList = &(keychain_attr_list_[key]); |
if (outData) { |
@@ -213,6 +218,8 @@ OSStatus MockAppleKeychain::ItemModifyAttributesAndData( |
UInt32 length, |
const void* data) const { |
DCHECK(itemRef); |
+ if (locked_) |
+ return errSecAuthFailed; |
const char* fail_trigger = "fail_me"; |
if (length == strlen(fail_trigger) && |
memcmp(data, fail_trigger, length) == 0) { |
@@ -248,6 +255,8 @@ OSStatus MockAppleKeychain::ItemFreeAttributesAndData( |
} |
OSStatus MockAppleKeychain::ItemDelete(SecKeychainItemRef itemRef) const { |
+ if (locked_) |
+ return errSecAuthFailed; |
MockKeychainItemType key = |
reinterpret_cast<MockKeychainItemType>(itemRef) - 1; |
@@ -390,6 +399,8 @@ OSStatus MockAppleKeychain::AddInternetPassword( |
UInt32 passwordLength, |
const void* passwordData, |
SecKeychainItemRef* itemRef) const { |
+ if (locked_) |
+ return errSecAuthFailed; |
// Check for the magic duplicate item trigger. |
if (strcmp(serverName, "some.domain.com") == 0) |