]> git.saurik.com Git - apple/security.git/blob - OSX/libsecurity_keychain/regressions/kc-02-unlock-noui.c
Security-58286.200.222.tar.gz
[apple/security.git] / OSX / libsecurity_keychain / regressions / kc-02-unlock-noui.c
1 #include <Security/SecKeychain.h>
2 #include <Security/SecKeychainPriv.h>
3
4 #include "keychain_regressions.h"
5 #include "kc-helpers.h"
6
7 int kc_02_unlock_noui(int argc, char *const *argv)
8 {
9 plan_tests(12);
10
11 initializeKeychainTests(__FUNCTION__);
12
13 ok_status(SecKeychainSetUserInteractionAllowed(FALSE), "SecKeychainSetUserInteractionAllowed(FALSE)");
14
15 SecKeychainRef keychain = createNewKeychain("test", "test");
16 ok_status(SecKeychainLock(keychain), "SecKeychainLock");
17
18 is_status(SecKeychainUnlock(keychain, 0, NULL, FALSE), errSecAuthFailed, "SecKeychainUnlock");
19
20 checkPrompts(0, "Unexpected keychain access prompt unlocking after SecKeychainCreate");
21
22 ok_status(SecKeychainLock(keychain), "SecKeychainLock");
23 CFRelease(keychain);
24
25 ok_status(SecKeychainOpen("test", &keychain), "SecKeychainOpen locked kc");
26
27 is_status(SecKeychainUnlock(keychain, 0, NULL, FALSE), errSecAuthFailed, "SecKeychainUnlock");
28
29 checkPrompts(0, "Unexpected keychain access prompt unlocking after SecKeychainCreate");
30
31 ok_status(SecKeychainDelete(keychain), "%s: SecKeychainDelete", testName);
32 CFRelease(keychain);
33
34 deleteTestFiles();
35 return 0;
36 }