Run $IPHONE_SIMULATOR_ROOT/libexec/securityd during tests #83

Merged
merged 2 commits into from Jul 11, 2012

Conversation

Projects
None yet
8 participants

For tests that use the keychain to work from the command line, $IPHONE_SIMULATOR_ROOT/libexec/securityd must be running. I ran securityd using a launchd task so I could kill it easily without interfering with the host system securityd.

hborders added some commits Mar 30, 2012

hborders
Defaulted CFFIXED_USER_HOME to same as google-toolbox-for-mac.
When running tests that use the keychain with GHUNIT_CLI, the following warning occurs:
	Warning: CFFIXED_USER_HOME is not set!  It should be set to the simulated home directory.

This should stop that warning.

What's the CFFIXED_USER_HOME all about? Is it necessary for the security daemon fix?

Can you please make 2 separate pull requests? One for the security daemon fix (we'll pull it for sure) and one for CFFIXED_USER_HOME (and make a case for it separately).

Thanks for your help. Great fix on the security daemon issue.

This line is seemed to be a typo, this should be like this:

if [ -d "$CFFIXED_USER_HOME" ]; then

akisute commented Jul 5, 2012

Manually patched this pull request by myself and it worked perfectly for my test cases with Security.framework.
I suppose you'd better merge this request to fix the issue.

For CFFIXED_USER_HOME, I have no idea what this env var is as well as Google. Perhaps it's the env var used internally in iOS Simulator and it's no harm to us except scattering warnings out. If you care though, you can cherry-pick commit 56312fc and remove line 17 to negate the CFFIXED_USER_HOME fix.

gabriel added a commit that referenced this pull request Jul 11, 2012

Merge pull request #83 from hborders/master
Run $IPHONE_SIMULATOR_ROOT/libexec/securityd during tests

@gabriel gabriel merged commit 92bf766 into gh-unit:master Jul 11, 2012

cmoskalo commented Aug 3, 2012

With the latest Xcode 4.4 I'm not able to use the RunTests.sh script that ghunit comes with. The reason being is the the resulting .octest no longer contains the application binary so the script fails. As a result, this fix for https requests cannot be used as I have to use target settings "Test after build" and a different command line. Additionally, in Lion there is no /usr/libexec/securityd anymore.

I've tried a variety of solutions, adding certificates to the iOS simulator, adding certs to the keychain, and so far nothing has worked. Can anyone confirm using ghunit with Xcode 4.4 and running tests via the CLI, following the set-up steps described on ghunit's wiki (and nowhere else)?

netbe commented Feb 27, 2013

I also have a problem with this, I don't know how much it is related to @cmoskalo problem but anyway. I am trying to test a method in my code that store password and email of a user to the keychain. The test passes fine in simulator but when running in command line, I got this error:

Error Domain=STKeychainErrorDomain Code=-25291 "The operation couldn’t be completed.

ErrorCode from Apple Doc. shows errSecNotAvailable: No trust results are available.

I have both scripts set up in my project's folder : RunIPhoneSecurityd.sh and RunTests.sh

Thanks in advance for your help.

BTW: why is the two script files not merged to master?

vdaubry commented Aug 28, 2013

Same problem here i'm unable to run tests using the keychain in CLI

Tests runs fine when ran through the simulator.

Starting UserServiceTests/test_getUser_Returns401AndSignInWithCredentialsFails_should_DestroyUserAndClearKeyChain
SecItemCopyMatching failed for key com.youboox.YoubooxUnitTests.LOGIN_CREDENTIALS_KEY: -25291
SecItemCopyMatching failed for key com.youboox.YoubooxUnitTests.PASSWORD_CREDENTIALS_KEY: -25291
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]'

For info i tried the following solutions without success :

  • Run tests with simulator running
  • Uncomment lines 11-16 in RunTests.sh

Has anyone been able to use the keychain in CLI with GHUnit ?

scouten commented Aug 28, 2013

We are also unable to use the keychain APIs from command-line / simulator test environment. We wound up writing special-case code in our application framework that avoids using the keychain APIs in this case. Unfortunately, it's too tied to our internal app framework to be useful generally, but the general idea is we use a transient NSMutableDictionary to mimic the behaviors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment