]> git.saurik.com Git - apple/security.git/blob - OSX/sec/securityd/Regressions/secd-83-item-match-trusted.m
Security-59306.11.20.tar.gz
[apple/security.git] / OSX / sec / securityd / Regressions / secd-83-item-match-trusted.m
1 //
2 // secd-83-item-match-trusted.m
3 // sec
4
5
6 /*
7 * This is to fool os services to not provide the Keychain manager
8 * interface tht doens't work since we don't have unified headers
9 * between iOS and OS X. rdar://23405418/
10 */
11 #define __KEYCHAINCORE__ 1
12
13 #import <Foundation/Foundation.h>
14 #import <Security/SecItem.h>
15 #import <Security/SecBase.h>
16 #import <utilities/SecCFWrappers.h>
17
18
19 #import "secd_regressions.h"
20 #import "SecdTestKeychainUtilities.h"
21 #import "secd-83-item-match.h"
22
23 static void test(id returnKeyName) {
24 CFTypeRef result = NULL;
25 ok_status(SecItemCopyMatching( (__bridge CFDictionaryRef)@{ (id)kSecClass : (id)kSecClassCertificate,
26 (id)kSecMatchLimit : (id)kSecMatchLimitAll,
27 returnKeyName : @YES }, &result));
28 ok(result && CFArrayGetCount(result) == 6);
29 CFReleaseNull(result);
30
31 is_status(SecItemCopyMatching( (__bridge CFDictionaryRef)@{ (id)kSecClass : (id)kSecClassCertificate,
32 (id)kSecMatchLimit : (id)kSecMatchLimitAll,
33 (id)kSecMatchTrustedOnly : @YES,
34 returnKeyName : @YES }, &result), errSecItemNotFound);
35 CFReleaseNull(result);
36 }
37
38 int secd_83_item_match_trusted(int argc, char *const *argv)
39 {
40 secd_test_setup_temp_keychain(__FUNCTION__, NULL);
41 plan_tests(19);
42
43 @autoreleasepool {
44 addTestCertificates();
45 NSArray *returnKeyNames = @[(id)kSecReturnAttributes, (id)kSecReturnData, (id)kSecReturnRef, (id)kSecReturnPersistentRef];
46 for (id returnKeyName in returnKeyNames)
47 test(returnKeyName);
48 }
49
50 return 0;
51 }