Lines Matching refs:context

48 test_default_name(krb5_context context)  in test_default_name()  argument
54 p = krb5_cc_default_name(context); in test_default_name()
56 krb5_errx (context, 1, "krb5_cc_default_name 1 failed"); in test_default_name()
59 ret = krb5_cc_set_default_name(context, NULL); in test_default_name()
61 krb5_errx (context, 1, "krb5_cc_set_default_name failed"); in test_default_name()
63 p = krb5_cc_default_name(context); in test_default_name()
65 krb5_errx (context, 1, "krb5_cc_default_name 2 failed"); in test_default_name()
69 krb5_errx (context, 1, "krb5_cc_default_name no longer same"); in test_default_name()
71 ret = krb5_cc_set_default_name(context, test_cc_name); in test_default_name()
73 krb5_errx (context, 1, "krb5_cc_set_default_name 1 failed"); in test_default_name()
75 p = krb5_cc_default_name(context); in test_default_name()
77 krb5_errx (context, 1, "krb5_cc_default_name 2 failed"); in test_default_name()
85 krb5_errx (context, 1, "krb5_cc_set_default_name 1 failed"); in test_default_name()
99 test_mcache(krb5_context context) in test_mcache() argument
107 ret = krb5_parse_name(context, "lha@SU.SE", &p); in test_mcache()
109 krb5_err(context, 1, ret, "krb5_parse_name"); in test_mcache()
111 ret = krb5_cc_new_unique(context, krb5_cc_type_memory, NULL, &id); in test_mcache()
113 krb5_err(context, 1, ret, "krb5_cc_new_unique"); in test_mcache()
115 ret = krb5_cc_initialize(context, id, p); in test_mcache()
117 krb5_err(context, 1, ret, "krb5_cc_initialize"); in test_mcache()
119 nc = krb5_cc_get_name(context, id); in test_mcache()
121 krb5_errx(context, 1, "krb5_cc_get_name"); in test_mcache()
123 tc = krb5_cc_get_type(context, id); in test_mcache()
125 krb5_errx(context, 1, "krb5_cc_get_name"); in test_mcache()
130 krb5_cc_close(context, id); in test_mcache()
132 ret = krb5_cc_resolve(context, c, &id2); in test_mcache()
134 krb5_err(context, 1, ret, "krb5_cc_resolve"); in test_mcache()
136 ret = krb5_cc_get_principal(context, id2, &p2); in test_mcache()
138 krb5_err(context, 1, ret, "krb5_cc_get_principal"); in test_mcache()
140 if (krb5_principal_compare(context, p, p2) == FALSE) in test_mcache()
141 krb5_errx(context, 1, "p != p2"); in test_mcache()
143 krb5_cc_destroy(context, id2); in test_mcache()
144 krb5_free_principal(context, p); in test_mcache()
145 krb5_free_principal(context, p2); in test_mcache()
147 ret = krb5_cc_resolve(context, c, &id2); in test_mcache()
149 krb5_err(context, 1, ret, "krb5_cc_resolve"); in test_mcache()
151 ret = krb5_cc_get_principal(context, id2, &p2); in test_mcache()
153 krb5_errx(context, 1, "krb5_cc_get_principal"); in test_mcache()
155 krb5_cc_destroy(context, id2); in test_mcache()
164 test_init_vs_destroy(krb5_context context, const char *type) in test_init_vs_destroy() argument
171 ret = krb5_parse_name(context, "lha@SU.SE", &p); in test_init_vs_destroy()
173 krb5_err(context, 1, ret, "krb5_parse_name"); in test_init_vs_destroy()
175 ret = krb5_cc_new_unique(context, type, NULL, &id); in test_init_vs_destroy()
177 krb5_err(context, 1, ret, "krb5_cc_new_unique: %s", type); in test_init_vs_destroy()
180 krb5_cc_get_type(context, id), in test_init_vs_destroy()
181 krb5_cc_get_name(context, id)) < 0 || n == NULL) in test_init_vs_destroy()
185 ret = krb5_cc_resolve(context, n, &id2); in test_init_vs_destroy()
188 krb5_err(context, 1, ret, "krb5_cc_resolve"); in test_init_vs_destroy()
190 krb5_cc_destroy(context, id); in test_init_vs_destroy()
192 ret = krb5_cc_initialize(context, id2, p); in test_init_vs_destroy()
194 krb5_err(context, 1, ret, "krb5_cc_initialize"); in test_init_vs_destroy()
196 ret = krb5_cc_get_principal(context, id2, &p2); in test_init_vs_destroy()
198 krb5_err(context, 1, ret, "krb5_cc_get_principal"); in test_init_vs_destroy()
200 krb5_cc_destroy(context, id2); in test_init_vs_destroy()
201 krb5_free_principal(context, p); in test_init_vs_destroy()
202 krb5_free_principal(context, p2); in test_init_vs_destroy()
206 test_cache_remove(krb5_context context, const char *type) in test_cache_remove() argument
213 ret = krb5_parse_name(context, "lha@SU.SE", &p); in test_cache_remove()
215 krb5_err(context, 1, ret, "krb5_parse_name"); in test_cache_remove()
217 ret = krb5_cc_new_unique(context, type, NULL, &id); in test_cache_remove()
219 krb5_err(context, 1, ret, "krb5_cc_gen_new: %s", type); in test_cache_remove()
221 ret = krb5_cc_initialize(context, id, p); in test_cache_remove()
223 krb5_err(context, 1, ret, "krb5_cc_initialize"); in test_cache_remove()
227 ret = krb5_parse_name(context, "krbtgt/SU.SE@SU.SE", &cred.server); in test_cache_remove()
229 krb5_err(context, 1, ret, "krb5_parse_name"); in test_cache_remove()
230 ret = krb5_parse_name(context, "lha@SU.SE", &cred.client); in test_cache_remove()
232 krb5_err(context, 1, ret, "krb5_parse_name"); in test_cache_remove()
234 ret = krb5_cc_store_cred(context, id, &cred); in test_cache_remove()
236 krb5_err(context, 1, ret, "krb5_cc_store_cred"); in test_cache_remove()
238 ret = krb5_cc_remove_cred(context, id, 0, &cred); in test_cache_remove()
240 krb5_err(context, 1, ret, "krb5_cc_remove_cred"); in test_cache_remove()
242 ret = krb5_cc_destroy(context, id); in test_cache_remove()
244 krb5_err(context, 1, ret, "krb5_cc_destroy"); in test_cache_remove()
246 krb5_free_principal(context, p); in test_cache_remove()
247 krb5_free_principal(context, cred.server); in test_cache_remove()
248 krb5_free_principal(context, cred.client); in test_cache_remove()
254 krb5_context context; in test_mcc_default() local
261 ret = krb5_init_context(&context); in test_mcc_default()
263 krb5_err(context, 1, ret, "krb5_init_context"); in test_mcc_default()
265 ret = krb5_cc_set_default_name(context, "MEMORY:foo"); in test_mcc_default()
267 krb5_err(context, 1, ret, "krb5_cc_set_default_name"); in test_mcc_default()
269 ret = krb5_cc_default(context, &id); in test_mcc_default()
271 krb5_err(context, 1, ret, "krb5_cc_default"); in test_mcc_default()
273 ret = krb5_cc_default(context, &id2); in test_mcc_default()
275 krb5_err(context, 1, ret, "krb5_cc_default"); in test_mcc_default()
277 ret = krb5_cc_close(context, id); in test_mcc_default()
279 krb5_err(context, 1, ret, "krb5_cc_close"); in test_mcc_default()
281 ret = krb5_cc_close(context, id2); in test_mcc_default()
283 krb5_err(context, 1, ret, "krb5_cc_close"); in test_mcc_default()
285 krb5_free_context(context); in test_mcc_default()
325 test_def_cc_name(krb5_context context) in test_def_cc_name() argument
332 ret = _krb5_expand_default_cc_name(context, cc_names[i].str, &str); in test_def_cc_name()
335 krb5_errx(context, 1, "test %d \"%s\" failed", in test_def_cc_name()
339 krb5_errx(context, 1, "test %d \"%s\" was successful", in test_def_cc_name()
342 krb5_errx(context, 1, "test %d %s != %s", in test_def_cc_name()
352 test_cache_find(krb5_context context, const char *principal, int find) in test_cache_find() argument
358 ret = krb5_parse_name(context, principal, &client); in test_cache_find()
360 krb5_err(context, 1, ret, "parse_name for %s failed", principal); in test_cache_find()
362 ret = krb5_cc_cache_match(context, client, &id); in test_cache_find()
364 krb5_err(context, 1, ret, "cc_cache_match for %s failed", principal); in test_cache_find()
366 krb5_err(context, 1, ret, "cc_cache_match for %s found", principal); in test_cache_find()
369 krb5_cc_close(context, id); in test_cache_find()
370 krb5_free_principal(context, client); in test_cache_find()
375 test_cache_iter(krb5_context context, const char *type, int destroy) in test_cache_iter() argument
381 ret = krb5_cc_cache_get_first (context, type, &cursor); in test_cache_iter()
385 krb5_err(context, 1, ret, "krb5_cc_cache_get_first(%s)", type); in test_cache_iter()
388 while ((ret = krb5_cc_cache_next (context, cursor, &id)) == 0) { in test_cache_iter()
393 printf("name: %s\n", krb5_cc_get_name(context, id)); in test_cache_iter()
394 ret = krb5_cc_get_principal(context, id, &principal); in test_cache_iter()
396 ret = krb5_unparse_name(context, principal, &name); in test_cache_iter()
402 krb5_free_principal(context, principal); in test_cache_iter()
405 krb5_cc_destroy(context, id); in test_cache_iter()
407 krb5_cc_close(context, id); in test_cache_iter()
410 krb5_cc_cache_end_seq_get(context, cursor); in test_cache_iter()
414 test_cache_iter_all(krb5_context context) in test_cache_iter_all() argument
420 ret = krb5_cccol_cursor_new (context, &cursor); in test_cache_iter_all()
422 krb5_err(context, 1, ret, "krb5_cccol_cursor_new"); in test_cache_iter_all()
425 while ((ret = krb5_cccol_cursor_next (context, cursor, &id)) == 0 && id != NULL) { in test_cache_iter_all()
430 printf("name: %s\n", krb5_cc_get_name(context, id)); in test_cache_iter_all()
431 ret = krb5_cc_get_principal(context, id, &principal); in test_cache_iter_all()
433 ret = krb5_unparse_name(context, principal, &name); in test_cache_iter_all()
439 krb5_free_principal(context, principal); in test_cache_iter_all()
441 krb5_cc_close(context, id); in test_cache_iter_all()
444 krb5_cccol_cursor_free(context, &cursor); in test_cache_iter_all()
449 test_copy(krb5_context context, const char *from, const char *to) in test_copy() argument
455 ret = krb5_parse_name(context, "lha@SU.SE", &p); in test_copy()
457 krb5_err(context, 1, ret, "krb5_parse_name"); in test_copy()
459 ret = krb5_cc_new_unique(context, from, NULL, &fromid); in test_copy()
461 krb5_err(context, 1, ret, "krb5_cc_new_unique: %s", from); in test_copy()
463 ret = krb5_cc_initialize(context, fromid, p); in test_copy()
465 krb5_err(context, 1, ret, "krb5_cc_initialize"); in test_copy()
467 ret = krb5_cc_new_unique(context, to, NULL, &toid); in test_copy()
469 krb5_err(context, 1, ret, "krb5_cc_gen_new: %s", to); in test_copy()
471 ret = krb5_cc_copy_cache(context, fromid, toid); in test_copy()
473 krb5_err(context, 1, ret, "krb5_cc_copy_cache"); in test_copy()
475 ret = krb5_cc_get_principal(context, toid, &p2); in test_copy()
477 krb5_err(context, 1, ret, "krb5_cc_get_principal"); in test_copy()
479 if (krb5_principal_compare(context, p, p2) == FALSE) in test_copy()
480 krb5_errx(context, 1, "p != p2"); in test_copy()
482 krb5_free_principal(context, p); in test_copy()
483 krb5_free_principal(context, p2); in test_copy()
485 krb5_cc_destroy(context, fromid); in test_copy()
486 krb5_cc_destroy(context, toid); in test_copy()
490 test_move(krb5_context context, const char *type) in test_move() argument
497 ops = krb5_cc_get_prefix_ops(context, type); in test_move()
501 ret = krb5_cc_new_unique(context, type, NULL, &fromid); in test_move()
505 krb5_err(context, 1, ret, "krb5_cc_new_unique: %s", type); in test_move()
507 ret = krb5_parse_name(context, "lha@SU.SE", &p); in test_move()
509 krb5_err(context, 1, ret, "krb5_parse_name"); in test_move()
511 ret = krb5_cc_initialize(context, fromid, p); in test_move()
513 krb5_err(context, 1, ret, "krb5_cc_initialize"); in test_move()
515 ret = krb5_cc_new_unique(context, type, NULL, &toid); in test_move()
517 krb5_err(context, 1, ret, "krb5_cc_new_unique"); in test_move()
519 ret = krb5_cc_initialize(context, toid, p); in test_move()
521 krb5_err(context, 1, ret, "krb5_cc_initialize"); in test_move()
523 ret = krb5_cc_get_principal(context, toid, &p2); in test_move()
525 krb5_err(context, 1, ret, "krb5_cc_get_principal"); in test_move()
527 if (krb5_principal_compare(context, p, p2) == FALSE) in test_move()
528 krb5_errx(context, 1, "p != p2"); in test_move()
530 krb5_free_principal(context, p); in test_move()
531 krb5_free_principal(context, p2); in test_move()
533 krb5_cc_destroy(context, toid); in test_move()
534 krb5_cc_destroy(context, fromid); in test_move()
539 test_prefix_ops(krb5_context context, const char *name, const krb5_cc_ops *ops) in test_prefix_ops() argument
543 o = krb5_cc_get_prefix_ops(context, name); in test_prefix_ops()
545 krb5_errx(context, 1, "found no match for prefix '%s'", name); in test_prefix_ops()
547 krb5_errx(context, 1, "ops for prefix '%s' is not " in test_prefix_ops()
552 test_cc_config(krb5_context context) in test_cc_config() argument
559 ret = krb5_cc_new_unique(context, "MEMORY", "bar", &id); in test_cc_config()
561 krb5_err(context, 1, ret, "krb5_cc_new_unique"); in test_cc_config()
563 ret = krb5_parse_name(context, "lha@SU.SE", &p); in test_cc_config()
565 krb5_err(context, 1, ret, "krb5_parse_name"); in test_cc_config()
567 ret = krb5_cc_initialize(context, id, p); in test_cc_config()
569 krb5_err(context, 1, ret, "krb5_cc_initialize"); in test_cc_config()
582 ret = krb5_cc_set_config(context, id, p1, "FriendlyName", &data); in test_cc_config()
584 krb5_errx(context, 1, "krb5_cc_set_config: add"); in test_cc_config()
586 ret = krb5_cc_get_config(context, id, p1, "FriendlyName", &data2); in test_cc_config()
588 krb5_errx(context, 1, "krb5_cc_get_config: first"); in test_cc_config()
591 ret = krb5_cc_set_config(context, id, p1, "FriendlyName", &data); in test_cc_config()
593 krb5_errx(context, 1, "krb5_cc_set_config: add -second"); in test_cc_config()
595 ret = krb5_cc_get_config(context, id, p1, "FriendlyName", &data2); in test_cc_config()
597 krb5_errx(context, 1, "krb5_cc_get_config: second"); in test_cc_config()
600 ret = krb5_cc_set_config(context, id, p1, "FriendlyName", NULL); in test_cc_config()
602 krb5_errx(context, 1, "krb5_cc_set_config: delete"); in test_cc_config()
604 ret = krb5_cc_get_config(context, id, p1, "FriendlyName", &data2); in test_cc_config()
606 krb5_errx(context, 1, "krb5_cc_get_config: non-existant"); in test_cc_config()
609 krb5_cc_destroy(context, id); in test_cc_config()
610 krb5_free_principal(context, p); in test_cc_config()
633 krb5_context context; in main() local
654 ret = krb5_init_context(&context); in main()
658 test_cache_remove(context, krb5_cc_type_file); in main()
659 test_cache_remove(context, krb5_cc_type_memory); in main()
661 test_cache_remove(context, krb5_cc_type_scc); in main()
664 test_default_name(context); in main()
665 test_mcache(context); in main()
666 test_init_vs_destroy(context, krb5_cc_type_memory); in main()
667 test_init_vs_destroy(context, krb5_cc_type_file); in main()
669 test_init_vs_destroy(context, krb5_cc_type_api); in main()
671 test_init_vs_destroy(context, krb5_cc_type_scc); in main()
673 test_def_cc_name(context); in main()
675 test_cache_iter_all(context); in main()
677 test_cache_iter(context, krb5_cc_type_memory, 0); in main()
680 krb5_cc_new_unique(context, krb5_cc_type_memory, "bar", &id1); in main()
681 krb5_cc_new_unique(context, krb5_cc_type_memory, "baz", &id2); in main()
682 krb5_parse_name(context, "lha@SU.SE", &p); in main()
683 krb5_cc_initialize(context, id1, p); in main()
684 krb5_free_principal(context, p); in main()
687 test_cache_find(context, "lha@SU.SE", 1); in main()
688 test_cache_find(context, "hulabundulahotentot@SU.SE", 0); in main()
690 test_cache_iter(context, krb5_cc_type_memory, 0); in main()
691 test_cache_iter(context, krb5_cc_type_memory, 1); in main()
692 test_cache_iter(context, krb5_cc_type_memory, 0); in main()
693 test_cache_iter(context, krb5_cc_type_file, 0); in main()
694 test_cache_iter(context, krb5_cc_type_api, 0); in main()
695 test_cache_iter(context, krb5_cc_type_scc, 0); in main()
696 test_cache_iter(context, krb5_cc_type_scc, 1); in main()
698 test_copy(context, krb5_cc_type_file, krb5_cc_type_file); in main()
699 test_copy(context, krb5_cc_type_memory, krb5_cc_type_memory); in main()
700 test_copy(context, krb5_cc_type_file, krb5_cc_type_memory); in main()
701 test_copy(context, krb5_cc_type_memory, krb5_cc_type_file); in main()
702 test_copy(context, krb5_cc_type_scc, krb5_cc_type_file); in main()
703 test_copy(context, krb5_cc_type_file, krb5_cc_type_scc); in main()
704 test_copy(context, krb5_cc_type_scc, krb5_cc_type_memory); in main()
705 test_copy(context, krb5_cc_type_memory, krb5_cc_type_scc); in main()
707 test_move(context, krb5_cc_type_file); in main()
708 test_move(context, krb5_cc_type_memory); in main()
710 test_move(context, krb5_cc_type_kcm); in main()
712 test_move(context, krb5_cc_type_scc); in main()
714 test_prefix_ops(context, "FILE:/tmp/foo", &krb5_fcc_ops); in main()
715 test_prefix_ops(context, "FILE", &krb5_fcc_ops); in main()
716 test_prefix_ops(context, "MEMORY", &krb5_mcc_ops); in main()
717 test_prefix_ops(context, "MEMORY:foo", &krb5_mcc_ops); in main()
718 test_prefix_ops(context, "/tmp/kaka", &krb5_fcc_ops); in main()
720 test_prefix_ops(context, "SCC:", &krb5_scc_ops); in main()
721 test_prefix_ops(context, "SCC:foo", &krb5_scc_ops); in main()
724 krb5_cc_destroy(context, id1); in main()
725 krb5_cc_destroy(context, id2); in main()
727 test_cc_config(context); in main()
729 krb5_free_context(context); in main()