Lockbox icon indicating copy to clipboard operation
Lockbox copied to clipboard

overwriting keys

Open core-code opened this issue 12 years ago • 9 comments
trafficstars

this fails for me on the mac on line 3 that tries to set the new key @"1". only the first setting for a key ever succeeds

assert([Lockbox setString:@"1" forKey:@"test"]);
assert([[Lockbox stringForKey:@"test"] isEqualToString:@"1"]);
assert([Lockbox setString:@"2" forKey:@"test"]);
assert([[Lockbox stringForKey:@"test"] isEqualToString:@"2"]);

core-code avatar Jan 23 '13 09:01 core-code

...new key @"2"

core-code avatar Jan 23 '13 09:01 core-code

Thanks for reporting this. Unfortunately, I cannot reproduce this, and my unit tests (newly added to this project) confirm that the class is working as expected.

It'd be interesting if you wouldn't mind grabbing the latest code from my master branch and running the unit tests on your machine. (Open the LockBox project and go to Product -> Test). Do they all pass?

granoff avatar Jan 26 '13 22:01 granoff

did you test on Mac OS X? i couldn't even get it to compile on Mac OS X without some changes...

yes i had the latest code, obtaining old code isn't even easy with github ;)

core-code avatar Jan 26 '13 22:01 core-code

The tests (which I just pushed to this repo) run on Mac OS X.

granoff avatar Jan 26 '13 22:01 granoff

thanks i'll have a look tomorrow.

core-code avatar Jan 26 '13 22:01 core-code

i couldn't find a way to run the tests on Mac OS X directly from the provided xcode project as it is iOS only and chaning it didn't really work. additionally the main Lockbox.m still didn't compile on Mac OS X without minor changes.

i've creates a new project "test", imported Lockbox master and still get the same behaviour.

https://dl.dropbox.com/u/7221986/lockbox.zip

just run test/test.xcodeproj and see it hanging in the assertion

core-code avatar Jan 27 '13 13:01 core-code

Hmm. Ok, it doesn't work under Cocoa, just Cocoa Touch.

I ran your code and stepped through it and saw the same issues you saw. The project provided with this repo is an iOS project. I think the issue is that the keychain under Mac OS works slightly differently than under iOS, which is unfortunate to be sure.

I don't have the time right now to figure this out for Cocoa; sorry. The issue has something to do with the dictionary provided to SecItemDelete() because it is returning a status indicating it cannot find the key in question to remove, before we set the new value. But I would be happy to accept a pull request that makes the class work for both Cocoa and Cocoa Touch. :-)

granoff avatar Jan 27 '13 16:01 granoff

no problem. i've switched to another keychain wrapper which works fine out-of-box, just wanted to let you know about the issues.

core-code avatar Jan 27 '13 16:01 core-code

I appreciate it; thanks. Truth be told, I am an iOS developer and I developed the class for an iOS project. I don't do Mac OS work, but I suppose I might someday. So I'll leave this issue open as a reminder that there's an issue for Cocoa use.

granoff avatar Jan 27 '13 16:01 granoff