1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775
|
/*
* Copyright (c) 2003 - 2007 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of KTH nor the names of its contributors may be
* used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY KTH AND ITS CONTRIBUTORS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KTH OR ITS CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
#include "krb5_locl.h"
#include <getarg.h>
#include <err.h>
static int debug_flag = 0;
static int version_flag = 0;
static int help_flag = 0;
#ifdef KRB5_USE_PATH_TOKENS
#define TEST_CC_NAME "%{TEMP}/krb5-cc-test-foo"
#else
#define TEST_CC_NAME "/tmp/krb5-cc-test-foo"
#endif
static void
test_default_name(krb5_context context)
{
krb5_error_code ret;
const char *p, *test_cc_name = TEST_CC_NAME;
char *p1, *p2, *p3;
p = krb5_cc_default_name(context);
if (p == NULL)
krb5_errx (context, 1, "krb5_cc_default_name 1 failed");
p1 = estrdup(p);
ret = krb5_cc_set_default_name(context, NULL);
if (ret)
krb5_errx (context, 1, "krb5_cc_set_default_name failed");
p = krb5_cc_default_name(context);
if (p == NULL)
krb5_errx (context, 1, "krb5_cc_default_name 2 failed");
p2 = estrdup(p);
if (strcmp(p1, p2) != 0)
krb5_errx (context, 1, "krb5_cc_default_name no longer same");
ret = krb5_cc_set_default_name(context, test_cc_name);
if (ret)
krb5_errx (context, 1, "krb5_cc_set_default_name 1 failed");
p = krb5_cc_default_name(context);
if (p == NULL)
krb5_errx (context, 1, "krb5_cc_default_name 2 failed");
p3 = estrdup(p);
#ifndef KRB5_USE_PATH_TOKENS
/* If we are using path tokens, we don't expect the p3 and
test_cc_name to match since p3 is going to have expanded
tokens. */
if (strcmp(p3, test_cc_name) != 0)
krb5_errx (context, 1, "krb5_cc_set_default_name 1 failed");
#endif
free(p1);
free(p2);
free(p3);
}
/*
* Check that a closed cc still keeps it data and that it's no longer
* there when it's destroyed.
*/
static void
test_mcache(krb5_context context)
{
krb5_error_code ret;
krb5_ccache id, id2;
const char *nc, *tc;
char *c;
krb5_principal p, p2;
ret = krb5_parse_name(context, "lha@SU.SE", &p);
if (ret)
krb5_err(context, 1, ret, "krb5_parse_name");
ret = krb5_cc_new_unique(context, krb5_cc_type_memory, NULL, &id);
if (ret)
krb5_err(context, 1, ret, "krb5_cc_new_unique");
ret = krb5_cc_initialize(context, id, p);
if (ret)
krb5_err(context, 1, ret, "krb5_cc_initialize");
nc = krb5_cc_get_name(context, id);
if (nc == NULL)
krb5_errx(context, 1, "krb5_cc_get_name");
tc = krb5_cc_get_type(context, id);
if (tc == NULL)
krb5_errx(context, 1, "krb5_cc_get_name");
if (asprintf(&c, "%s:%s", tc, nc) < 0 || c == NULL)
errx(1, "malloc");
krb5_cc_close(context, id);
ret = krb5_cc_resolve(context, c, &id2);
if (ret)
krb5_err(context, 1, ret, "krb5_cc_resolve");
ret = krb5_cc_get_principal(context, id2, &p2);
if (ret)
krb5_err(context, 1, ret, "krb5_cc_get_principal");
if (krb5_principal_compare(context, p, p2) == FALSE)
krb5_errx(context, 1, "p != p2");
krb5_cc_destroy(context, id2);
krb5_free_principal(context, p);
krb5_free_principal(context, p2);
ret = krb5_cc_resolve(context, c, &id2);
if (ret)
krb5_err(context, 1, ret, "krb5_cc_resolve");
ret = krb5_cc_get_principal(context, id2, &p2);
if (ret == 0)
krb5_errx(context, 1, "krb5_cc_get_principal");
krb5_cc_destroy(context, id2);
free(c);
}
/*
* Test that init works on a destroyed cc.
*/
static void
test_init_vs_destroy(krb5_context context, const char *type)
{
krb5_error_code ret;
krb5_ccache id, id2;
krb5_principal p, p2;
char *n = NULL;
ret = krb5_parse_name(context, "lha@SU.SE", &p);
if (ret)
krb5_err(context, 1, ret, "krb5_parse_name");
ret = krb5_cc_new_unique(context, type, NULL, &id);
if (ret)
krb5_err(context, 1, ret, "krb5_cc_new_unique: %s", type);
if (asprintf(&n, "%s:%s",
krb5_cc_get_type(context, id),
krb5_cc_get_name(context, id)) < 0 || n == NULL)
errx(1, "malloc");
ret = krb5_cc_resolve(context, n, &id2);
free(n);
if (ret)
krb5_err(context, 1, ret, "krb5_cc_resolve");
krb5_cc_destroy(context, id);
ret = krb5_cc_initialize(context, id2, p);
if (ret)
krb5_err(context, 1, ret, "krb5_cc_initialize");
ret = krb5_cc_get_principal(context, id2, &p2);
if (ret)
krb5_err(context, 1, ret, "krb5_cc_get_principal");
krb5_cc_destroy(context, id2);
krb5_free_principal(context, p);
krb5_free_principal(context, p2);
}
static void
test_cache_remove(krb5_context context, const char *type)
{
krb5_error_code ret;
krb5_ccache id;
krb5_principal p;
krb5_creds cred;
ret = krb5_parse_name(context, "lha@SU.SE", &p);
if (ret)
krb5_err(context, 1, ret, "krb5_parse_name");
ret = krb5_cc_new_unique(context, type, NULL, &id);
if (ret)
krb5_err(context, 1, ret, "krb5_cc_gen_new: %s", type);
ret = krb5_cc_initialize(context, id, p);
if (ret)
krb5_err(context, 1, ret, "krb5_cc_initialize");
/* */
memset(&cred, 0, sizeof(cred));
ret = krb5_parse_name(context, "krbtgt/SU.SE@SU.SE", &cred.server);
if (ret)
krb5_err(context, 1, ret, "krb5_parse_name");
ret = krb5_parse_name(context, "lha@SU.SE", &cred.client);
if (ret)
krb5_err(context, 1, ret, "krb5_parse_name");
ret = krb5_cc_store_cred(context, id, &cred);
if (ret)
krb5_err(context, 1, ret, "krb5_cc_store_cred");
ret = krb5_cc_remove_cred(context, id, 0, &cred);
if (ret)
krb5_err(context, 1, ret, "krb5_cc_remove_cred");
ret = krb5_cc_destroy(context, id);
if (ret)
krb5_err(context, 1, ret, "krb5_cc_destroy");
krb5_free_principal(context, p);
krb5_free_principal(context, cred.server);
krb5_free_principal(context, cred.client);
}
static void
test_mcc_default(void)
{
krb5_context context;
krb5_error_code ret;
krb5_ccache id, id2;
int i;
for (i = 0; i < 10; i++) {
ret = krb5_init_context(&context);
if (ret)
krb5_err(context, 1, ret, "krb5_init_context");
ret = krb5_cc_set_default_name(context, "MEMORY:foo");
if (ret)
krb5_err(context, 1, ret, "krb5_cc_set_default_name");
ret = krb5_cc_default(context, &id);
if (ret)
krb5_err(context, 1, ret, "krb5_cc_default");
ret = krb5_cc_default(context, &id2);
if (ret)
krb5_err(context, 1, ret, "krb5_cc_default");
ret = krb5_cc_close(context, id);
if (ret)
krb5_err(context, 1, ret, "krb5_cc_close");
ret = krb5_cc_close(context, id2);
if (ret)
krb5_err(context, 1, ret, "krb5_cc_close");
krb5_free_context(context);
}
}
struct {
char *str;
int fail;
char *res;
} cc_names[] = {
{ "foo", 0, "foo" },
{ "foo%}", 0, "foo%}" },
{ "%{uid}", 0, NULL },
{ "foo%{null}", 0, "foo" },
{ "foo%{null}bar", 0, "foobar" },
{ "%{", 1, NULL },
{ "%{foo %{", 1, NULL },
{ "%{{", 1, NULL },
{ "%{{}", 1, NULL },
{ "%{nulll}", 1, NULL },
{ "%{does not exist}", 1, NULL },
{ "%{}", 1, NULL },
#ifdef KRB5_USE_PATH_TOKENS
{ "%{APPDATA}", 0, NULL },
{ "%{COMMON_APPDATA}", 0, NULL},
{ "%{LOCAL_APPDATA}", 0, NULL},
{ "%{SYSTEM}", 0, NULL},
{ "%{WINDOWS}", 0, NULL},
{ "%{TEMP}", 0, NULL},
{ "%{USERID}", 0, NULL},
{ "%{uid}", 0, NULL},
{ "%{USERCONFIG}", 0, NULL},
{ "%{COMMONCONFIG}", 0, NULL},
{ "%{LIBDIR}", 0, NULL},
{ "%{BINDIR}", 0, NULL},
{ "%{LIBEXEC}", 0, NULL},
{ "%{SBINDIR}", 0, NULL},
#endif
};
static void
test_def_cc_name(krb5_context context)
{
krb5_error_code ret;
char *str;
int i;
for (i = 0; i < sizeof(cc_names)/sizeof(cc_names[0]); i++) {
ret = _krb5_expand_default_cc_name(context, cc_names[i].str, &str);
if (ret) {
if (cc_names[i].fail == 0)
krb5_errx(context, 1, "test %d \"%s\" failed",
i, cc_names[i].str);
} else {
if (cc_names[i].fail)
krb5_errx(context, 1, "test %d \"%s\" was successful",
i, cc_names[i].str);
if (cc_names[i].res && strcmp(cc_names[i].res, str) != 0)
krb5_errx(context, 1, "test %d %s != %s",
i, cc_names[i].res, str);
if (debug_flag)
printf("%s => %s\n", cc_names[i].str, str);
free(str);
}
}
}
static void
test_cache_find(krb5_context context, const char *principal, int find)
{
krb5_principal client;
krb5_error_code ret;
krb5_ccache id = NULL;
ret = krb5_parse_name(context, principal, &client);
if (ret)
krb5_err(context, 1, ret, "parse_name for %s failed", principal);
ret = krb5_cc_cache_match(context, client, &id);
if (ret && find)
krb5_err(context, 1, ret, "cc_cache_match for %s failed", principal);
if (ret == 0 && !find)
krb5_err(context, 1, ret, "cc_cache_match for %s found", principal);
if (id)
krb5_cc_close(context, id);
krb5_free_principal(context, client);
}
static void
test_cache_iter(krb5_context context, const char *type, int destroy)
{
krb5_cc_cache_cursor cursor;
krb5_error_code ret;
krb5_ccache id;
ret = krb5_cc_cache_get_first (context, type, &cursor);
if (ret == KRB5_CC_NOSUPP)
return;
else if (ret)
krb5_err(context, 1, ret, "krb5_cc_cache_get_first(%s)", type);
while ((ret = krb5_cc_cache_next (context, cursor, &id)) == 0) {
krb5_principal principal;
char *name;
if (debug_flag)
printf("name: %s\n", krb5_cc_get_name(context, id));
ret = krb5_cc_get_principal(context, id, &principal);
if (ret == 0) {
ret = krb5_unparse_name(context, principal, &name);
if (ret == 0) {
if (debug_flag)
printf("\tprincipal: %s\n", name);
free(name);
}
krb5_free_principal(context, principal);
}
if (destroy)
krb5_cc_destroy(context, id);
else
krb5_cc_close(context, id);
}
krb5_cc_cache_end_seq_get(context, cursor);
}
static void
test_cache_iter_all(krb5_context context)
{
krb5_cccol_cursor cursor;
krb5_error_code ret;
krb5_ccache id;
ret = krb5_cccol_cursor_new (context, &cursor);
if (ret)
krb5_err(context, 1, ret, "krb5_cccol_cursor_new");
while ((ret = krb5_cccol_cursor_next (context, cursor, &id)) == 0 && id != NULL) {
krb5_principal principal;
char *name;
if (debug_flag)
printf("name: %s\n", krb5_cc_get_name(context, id));
ret = krb5_cc_get_principal(context, id, &principal);
if (ret == 0) {
ret = krb5_unparse_name(context, principal, &name);
if (ret == 0) {
if (debug_flag)
printf("\tprincipal: %s\n", name);
free(name);
}
krb5_free_principal(context, principal);
}
krb5_cc_close(context, id);
}
krb5_cccol_cursor_free(context, &cursor);
}
static void
test_copy(krb5_context context, const char *from, const char *to)
{
krb5_ccache fromid, toid;
krb5_error_code ret;
krb5_principal p, p2;
ret = krb5_parse_name(context, "lha@SU.SE", &p);
if (ret)
krb5_err(context, 1, ret, "krb5_parse_name");
ret = krb5_cc_new_unique(context, from, NULL, &fromid);
if (ret)
krb5_err(context, 1, ret, "krb5_cc_new_unique: %s", from);
ret = krb5_cc_initialize(context, fromid, p);
if (ret)
krb5_err(context, 1, ret, "krb5_cc_initialize");
ret = krb5_cc_new_unique(context, to, NULL, &toid);
if (ret)
krb5_err(context, 1, ret, "krb5_cc_gen_new: %s", to);
ret = krb5_cc_copy_cache(context, fromid, toid);
if (ret)
krb5_err(context, 1, ret, "krb5_cc_copy_cache");
ret = krb5_cc_get_principal(context, toid, &p2);
if (ret)
krb5_err(context, 1, ret, "krb5_cc_get_principal");
if (krb5_principal_compare(context, p, p2) == FALSE)
krb5_errx(context, 1, "p != p2");
krb5_free_principal(context, p);
krb5_free_principal(context, p2);
krb5_cc_destroy(context, fromid);
krb5_cc_destroy(context, toid);
}
static void
test_move(krb5_context context, const char *type)
{
const krb5_cc_ops *ops;
krb5_ccache fromid, toid;
krb5_error_code ret;
krb5_principal p, p2;
ops = krb5_cc_get_prefix_ops(context, type);
if (ops == NULL)
return;
ret = krb5_cc_new_unique(context, type, NULL, &fromid);
if (ret == KRB5_CC_NOSUPP)
return;
else if (ret)
krb5_err(context, 1, ret, "krb5_cc_new_unique: %s", type);
ret = krb5_parse_name(context, "lha@SU.SE", &p);
if (ret)
krb5_err(context, 1, ret, "krb5_parse_name");
ret = krb5_cc_initialize(context, fromid, p);
if (ret)
krb5_err(context, 1, ret, "krb5_cc_initialize");
ret = krb5_cc_new_unique(context, type, NULL, &toid);
if (ret)
krb5_err(context, 1, ret, "krb5_cc_new_unique");
ret = krb5_cc_initialize(context, toid, p);
if (ret)
krb5_err(context, 1, ret, "krb5_cc_initialize");
ret = krb5_cc_get_principal(context, toid, &p2);
if (ret)
krb5_err(context, 1, ret, "krb5_cc_get_principal");
if (krb5_principal_compare(context, p, p2) == FALSE)
krb5_errx(context, 1, "p != p2");
krb5_free_principal(context, p);
krb5_free_principal(context, p2);
krb5_cc_destroy(context, toid);
krb5_cc_destroy(context, fromid);
}
static void
test_prefix_ops(krb5_context context, const char *name, const krb5_cc_ops *ops)
{
const krb5_cc_ops *o;
o = krb5_cc_get_prefix_ops(context, name);
if (o == NULL)
krb5_errx(context, 1, "found no match for prefix '%s'", name);
if (strcmp(o->prefix, ops->prefix) != 0)
krb5_errx(context, 1, "ops for prefix '%s' is not "
"the expected %s != %s", name, o->prefix, ops->prefix);
}
static void
test_cc_config(krb5_context context, const char *cc_type,
const char *cc_name, size_t count)
{
krb5_error_code ret;
krb5_principal p;
krb5_ccache id;
unsigned int i;
ret = krb5_cc_new_unique(context, cc_type, cc_name, &id);
if (ret)
krb5_err(context, 1, ret, "krb5_cc_new_unique");
ret = krb5_parse_name(context, "lha@SU.SE", &p);
if (ret)
krb5_err(context, 1, ret, "krb5_parse_name");
ret = krb5_cc_initialize(context, id, p);
if (ret)
krb5_err(context, 1, ret, "krb5_cc_initialize");
for (i = 0; i < count; i++) {
krb5_data data, data2;
const char *name = "foo";
krb5_principal p1 = NULL;
if (i & 1)
p1 = p;
data.data = rk_UNCONST(name);
data.length = strlen(name);
/*
* Because of how krb5_cc_set_config() this will also test
* krb5_cc_remove_cred().
*/
ret = krb5_cc_set_config(context, id, p1, "FriendlyName", &data);
if (ret)
krb5_errx(context, 1, "krb5_cc_set_config: add");
ret = krb5_cc_get_config(context, id, p1, "FriendlyName", &data2);
if (ret)
krb5_errx(context, 1, "krb5_cc_get_config: first");
if (data.length != data2.length ||
memcmp(data.data, data2.data, data.length) != 0)
krb5_errx(context, 1, "krb5_cc_get_config: did not fetch what was set");
krb5_data_free(&data2);
data.data = rk_UNCONST("bar");
data.length = strlen("bar");
ret = krb5_cc_set_config(context, id, p1, "FriendlyName", &data);
if (ret)
krb5_errx(context, 1, "krb5_cc_set_config: add -second");
ret = krb5_cc_get_config(context, id, p1, "FriendlyName", &data2);
if (ret)
krb5_errx(context, 1, "krb5_cc_get_config: second");
if (data.length != data2.length ||
memcmp(data.data, data2.data, data.length) != 0)
krb5_errx(context, 1, "krb5_cc_get_config: replace failed");
krb5_data_free(&data2);
ret = krb5_cc_set_config(context, id, p1, "FriendlyName", NULL);
if (ret)
krb5_errx(context, 1, "krb5_cc_set_config: delete");
ret = krb5_cc_get_config(context, id, p1, "FriendlyName", &data2);
if (ret == 0)
krb5_errx(context, 1, "krb5_cc_get_config: non-existant");
if (data2.length)
krb5_errx(context, 1, "krb5_cc_get_config: delete failed");
}
krb5_cc_destroy(context, id);
krb5_free_principal(context, p);
}
static struct getargs args[] = {
{"debug", 'd', arg_flag, &debug_flag,
"turn on debuggin", NULL },
{"version", 0, arg_flag, &version_flag,
"print version", NULL },
{"help", 0, arg_flag, &help_flag,
NULL, NULL }
};
static void
usage (int ret)
{
arg_printusage (args, sizeof(args)/sizeof(*args), NULL, "hostname ...");
exit (ret);
}
int
main(int argc, char **argv)
{
krb5_context context;
krb5_error_code ret;
int optidx = 0;
krb5_ccache id1, id2;
setprogname(argv[0]);
if(getarg(args, sizeof(args) / sizeof(args[0]), argc, argv, &optidx))
usage(1);
if (help_flag)
usage (0);
if(version_flag){
print_version(NULL);
exit(0);
}
argc -= optidx;
argv += optidx;
ret = krb5_init_context(&context);
if (ret)
errx (1, "krb5_init_context failed: %d", ret);
test_cache_remove(context, krb5_cc_type_file);
test_cache_remove(context, krb5_cc_type_memory);
#ifdef USE_SQLITE
test_cache_remove(context, krb5_cc_type_scc);
#endif
test_default_name(context);
test_mcache(context);
test_init_vs_destroy(context, krb5_cc_type_memory);
test_init_vs_destroy(context, krb5_cc_type_file);
#if 0
test_init_vs_destroy(context, krb5_cc_type_api);
#endif
test_init_vs_destroy(context, krb5_cc_type_scc);
test_init_vs_destroy(context, krb5_cc_type_dcc);
test_mcc_default();
test_def_cc_name(context);
test_cache_iter_all(context);
test_cache_iter(context, krb5_cc_type_memory, 0);
{
krb5_principal p;
krb5_cc_new_unique(context, krb5_cc_type_memory, "bar", &id1);
krb5_cc_new_unique(context, krb5_cc_type_memory, "baz", &id2);
krb5_parse_name(context, "lha@SU.SE", &p);
krb5_cc_initialize(context, id1, p);
krb5_free_principal(context, p);
}
test_cache_find(context, "lha@SU.SE", 1);
test_cache_find(context, "hulabundulahotentot@SU.SE", 0);
test_cache_iter(context, krb5_cc_type_memory, 0);
test_cache_iter(context, krb5_cc_type_memory, 1);
test_cache_iter(context, krb5_cc_type_memory, 0);
test_cache_iter(context, krb5_cc_type_file, 0);
test_cache_iter(context, krb5_cc_type_api, 0);
test_cache_iter(context, krb5_cc_type_scc, 0);
test_cache_iter(context, krb5_cc_type_scc, 1);
#if 0
test_cache_iter(context, krb5_cc_type_dcc, 0);
test_cache_iter(context, krb5_cc_type_dcc, 1);
#endif
test_copy(context, krb5_cc_type_file, krb5_cc_type_file);
test_copy(context, krb5_cc_type_memory, krb5_cc_type_memory);
test_copy(context, krb5_cc_type_file, krb5_cc_type_memory);
test_copy(context, krb5_cc_type_memory, krb5_cc_type_file);
test_copy(context, krb5_cc_type_scc, krb5_cc_type_file);
test_copy(context, krb5_cc_type_file, krb5_cc_type_scc);
test_copy(context, krb5_cc_type_scc, krb5_cc_type_memory);
test_copy(context, krb5_cc_type_memory, krb5_cc_type_scc);
#if 0
test_copy(context, krb5_cc_type_dcc, krb5_cc_type_memory);
test_copy(context, krb5_cc_type_dcc, krb5_cc_type_file);
test_copy(context, krb5_cc_type_dcc, krb5_cc_type_scc);
#endif
test_move(context, krb5_cc_type_file);
test_move(context, krb5_cc_type_memory);
#ifdef HAVE_KCM
test_move(context, krb5_cc_type_kcm);
#endif
test_move(context, krb5_cc_type_scc);
#if 0
test_move(context, krb5_cc_type_dcc);
#endif
test_prefix_ops(context, "FILE:/tmp/foo", &krb5_fcc_ops);
test_prefix_ops(context, "FILE", &krb5_fcc_ops);
test_prefix_ops(context, "MEMORY", &krb5_mcc_ops);
test_prefix_ops(context, "MEMORY:foo", &krb5_mcc_ops);
test_prefix_ops(context, "/tmp/kaka", &krb5_fcc_ops);
#ifdef HAVE_SCC
test_prefix_ops(context, "SCC:", &krb5_scc_ops);
test_prefix_ops(context, "SCC:foo", &krb5_scc_ops);
#endif
#if 0
test_prefix_ops(context, "DIR:", &krb5_dcc_ops);
test_prefix_ops(context, "DIR:tkt1", &krb5_dcc_ops);
#endif
krb5_cc_destroy(context, id1);
krb5_cc_destroy(context, id2);
test_cc_config(context, "MEMORY", "bar", 1000); /* 1000 because fast */
test_cc_config(context, "FILE", "/tmp/foocc", 30); /* 30 because slower */
krb5_free_context(context);
#if 0
sleep(60);
#endif
return 0;
}
|