]>
git.saurik.com Git - apple/security.git/blob - SecurityTests/regressions/kc/kc-26-is-valid.c
1 #include <Security/SecKeychain.h>
2 #include <Security/SecKeychainPriv.h>
11 #include "testleaks.h"
13 static void tests(void)
15 char *home
= getenv("HOME");
16 char kcname1
[256], kcname2
[256];
18 if (!home
|| strlen(home
) > 200)
19 plan_skip_all("home too big");
21 sprintf(kcname1
, "%s/kc1", home
);
22 SecKeychainRef kc1
= NULL
, kc2
= NULL
;
23 Boolean kc1valid
, kc2valid
;
24 ok_status(SecKeychainCreate(kcname1
, 4, "test", FALSE
, NULL
, &kc1
),
25 "SecKeychainCreate kc1");
26 ok_status(SecKeychainIsValid(kc1
, &kc1valid
), "SecKeychainIsValid kc1");
27 is(kc1valid
, TRUE
, "is kc1 valid");
31 sprintf(kcname2
, "%s/kc2", home
);
32 ok_unix(fd
= open(kcname2
, O_CREAT
|O_WRONLY
|O_TRUNC
, 0600),
33 "create invalid kc2 file");
34 ok_unix(close(fd
), "close the kc2 file");
35 ok_status(SecKeychainOpen(kcname2
, &kc2
), "SecKeychainOpen kc2");
37 ok_status(SecKeychainIsValid(kc2
, &kc2valid
), "SecKeychainIsValid kc2");
39 todo("<rdar://problem/3795566> SecKeychainIsValid always returns "
41 is(kc2valid
, FALSE
, "is kc2 not valid");
48 int main(int argc
, char *const *argv
)
51 if (!tests_begin(argc
, argv
))
52 BAIL_OUT("tests_begin failed");