kc-01-keychain-creation.c
1 #include <stdlib.h> 2 #include <Security/SecKeychain.h> 3 4 #include "keychain_regressions.h" 5 #include "kc-helpers.h" 6 7 int kc_01_keychain_creation(int argc, char *const *argv) 8 { 9 plan_tests(9); 10 11 ok_status(SecKeychainSetUserInteractionAllowed(FALSE), "disable ui"); 12 SecKeychainRef keychain = createNewKeychain("test", "test"); 13 SKIP: { 14 skip("can't continue without keychain", 2, ok(keychain, "keychain not NULL")); 15 16 is(CFGetRetainCount(keychain), 1, "retaincount of created keychain is 1"); 17 } 18 19 SecKeychainRef keychain2 = NULL; 20 ok_status(SecKeychainOpen("test", &keychain2), "SecKeychainOpen"); 21 SKIP: { 22 skip("can't continue without keychain", 2, ok(keychain, "keychain not NULL")); 23 CFIndex retCount = CFGetRetainCount(keychain2); 24 is(retCount, 2, "retaincount of created+opened keychain is 2"); // 2, because we opened and created the same keychain. 25 } 26 27 is(keychain, keychain2, "SecKeychainCreate and SecKeychainOpen returned a different handle for the same keychain"); 28 29 ok_status(SecKeychainDelete(keychain), "SecKeychainDelete"); 30 31 CFRelease(keychain); 32 CFRelease(keychain2); 33 34 return 0; 35 }