]>
git.saurik.com Git - apple/security.git/blob - SecurityTests/regressions/kc/kc-11-unlock-referral.c
2 #include <Security/SecKeychain.h>
7 int main(int argc
, char *const *argv
)
9 int dont_skip
= argc
> 1 && !strcmp(argv
[1], "-s");
13 ok_status(SecKeychainSetUserInteractionAllowed(FALSE
), "disable ui");
14 if (!tests_begin(argc
, argv
))
15 BAIL_OUT("tests_begin failed");
17 char *home
= getenv("HOME");
18 char source
[256], dest
[256];
19 if (!home
|| strlen(home
) > 200)
20 plan_skip_all("home too big");
22 sprintf(source
, "%s/source", home
);
23 sprintf(dest
, "%s/dest", home
);
24 SecKeychainRef sourcekc
= NULL
, destkc
= NULL
;
25 ok_status(SecKeychainCreate(source
, 4, "test", FALSE
, NULL
, &sourcekc
),
26 "SecKeychainCreate source");
27 ok_status(SecKeychainCreate(dest
, 4, "test", FALSE
, NULL
, &destkc
),
28 "SecKeychainCreate dest");
30 ok_unix(sprintf(cmdbuf
, "systemkeychain -k '%s' -s '%s'", dest
, source
),
33 skip("systemkeychain brings up UI", 1, dont_skip
);
35 ok_unix(system(cmdbuf
), "systemkeychain");
37 ok_status(SecKeychainLock(sourcekc
), "SecKeychainLock source");
39 skip("unlocking a source keychain w/ referal before reopen brings "
40 "up ui", 1, dont_skip
);
42 todo("<rdar://problem/4066169> Unlocking a source "
43 "keychain w/ referal before reopen fails");
45 ok_status(SecKeychainUnlock(sourcekc
, 0, NULL
, FALSE
),
46 "SecKeychainUnlock source");
52 sprintf(source2
, "%s/source2", home
);
53 ok_unix(rename(source
, source2
), "rename source -> source2");
54 ok_status(SecKeychainOpen(source2
, &sourcekc
), "SecKeychainOpen source2");
56 skip("systemkeychain brings up UI", 1, dont_skip
);
58 ok_status(SecKeychainUnlock(sourcekc
, 0, NULL
, FALSE
),
59 "SecKeychainUnlock source2");