1load_lib lib.t 2api_exit 3api_start 4 5#test "create-principal 1" 6# 7#proc test1 {} { 8# global test 9# begin_dump 10# one_line_fail_test [format { 11# kadm5_create_principal $server_handle \ 12# [simple_principal "%s/a"] {KADM5_PRINCIPAL} "%s/a" 13# } $test $test] "NOT_INIT" 14# end_dump_compare "no-diffs" 15#} 16#test1 17 18# v2 create-principal 3 test, to avoid name conflict 19test "create-principal 1" 20proc test1 {} { 21 global test 22# set prms_id 777 23# setup_xfail {*-*-*} $prms_id 24 begin_dump 25 if {! [cmd { 26 kadm5_init admin admin $KADM5_ADMIN_SERVICE null \ 27 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \ 28 server_handle 29 }]} { 30 perror "$test: unexpected failure in init" 31 return 32 } 33 one_line_succeed_test [format { 34 kadm5_create_principal $server_handle [simple_principal "%s/a"] \ 35 {KADM5_PRINCIPAL} null 36 } $test] 37 if { ! [cmd {kadm5_destroy $server_handle}]} { 38 perror "$test: unexpected failure in destroy" 39 return 40 } 41 end_dump_compare "no-diffs" 42} 43test1 44 45test "create-principal 2" 46 47proc test2 {} { 48 global test 49 begin_dump 50 if {! [cmd { 51 kadm5_init admin admin $KADM5_ADMIN_SERVICE null \ 52 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \ 53 server_handle 54 }]} { 55 perror "$test: unexpected failure in init" 56 return 57 } 58 one_line_fail_test { 59 kadm5_create_principal $server_handle null \ 60 {KADM5_PRINCIPAL} testpass 61 } "EINVAL" 62 if { ! [cmd {kadm5_destroy $server_handle}]} { 63 perror "$test: unexpected failure in destroy" 64 return 65 } 66 end_dump_compare "no-diffs" 67} 68test2 69 70test "create-principal 4" 71proc test4 {} { 72 global test 73 74 begin_dump 75 if {! [cmd { 76 kadm5_init admin admin $KADM5_ADMIN_SERVICE null \ 77 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \ 78 server_handle 79 }]} { 80 perror "$test: unexpected failure in init" 81 return 82 } 83 one_line_fail_test [format { 84 kadm5_create_principal $server_handle [simple_principal "%s/a"] \ 85 {KADM5_PRINCIPAL} "" 86 } $test] "_Q_TOOSHORT" 87 if { ! [cmd {kadm5_destroy $server_handle}]} { 88 perror "$test: unexpected failure in destroy" 89 return 90 } 91 end_dump_compare "no-diffs" 92} 93test4 94 95test "create-principal 5" 96proc test5 {} { 97 global test 98 begin_dump 99 if {! [cmd { 100 kadm5_init admin admin $KADM5_ADMIN_SERVICE null \ 101 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \ 102 server_handle 103 }]} { 104 perror "$test: unexpected failure in init" 105 return 106 } 107 one_line_fail_test [format { 108 kadm5_create_principal $server_handle \ 109 [simple_principal "%s/a"] {0x100001} "%s/a" 110 } $test $test] "BAD_MASK" 111 if { ! [cmd {kadm5_destroy $server_handle}]} { 112 perror "$test: unexpected failure in destroy" 113 return 114 } 115 end_dump_compare "no-diffs" 116} 117test5 118 119test "create-principal 6" 120proc test6 {} { 121 global test 122 begin_dump 123 if {! [cmd { 124 kadm5_init admin admin $KADM5_ADMIN_SERVICE null \ 125 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \ 126 server_handle 127 }]} { 128 perror "$test: unexpected failure in init" 129 return 130 } 131 one_line_fail_test [format { 132 kadm5_create_principal $server_handle [simple_principal "%s/a"] \ 133 {KADM5_LAST_PWD_CHANGE} "%s/a" 134 } $test $test] "BAD_MASK" 135 if { ! [cmd {kadm5_destroy $server_handle}]} { 136 perror "$test: unexpected failure in destroy" 137 return 138 } 139 end_dump_compare "no-diffs" 140} 141test6 142 143test "create-principal 7" 144proc test7 {} { 145 global test 146 begin_dump 147 if {! [cmd { 148 kadm5_init admin admin $KADM5_ADMIN_SERVICE null \ 149 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \ 150 server_handle 151 }]} { 152 perror "$test: unexpected failure in init" 153 return 154 } 155 one_line_fail_test [format { 156 kadm5_create_principal $server_handle [simple_principal "%s/a"] \ 157 {KADM5_MOD_TIME} "%s/a" 158 } $test $test] "BAD_MASK" 159 if { ! [cmd {kadm5_destroy $server_handle}]} { 160 perror "$test: unexpected failure in destroy" 161 return 162 } 163 end_dump_compare "no-diffs" 164} 165test7 166 167test "create-principal 8" 168proc test8 {} { 169 global test 170 begin_dump 171 if {! [cmd { 172 kadm5_init admin admin $KADM5_ADMIN_SERVICE null \ 173 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \ 174 server_handle 175 }]} { 176 perror "$test: unexpected failure in init" 177 return 178 } 179 one_line_fail_test [format { 180 kadm5_create_principal $server_handle [simple_principal "%s/a"] \ 181 {KADM5_MOD_NAME} "%s/a" 182 } $test $test] "BAD_MASK" 183 if { ! [cmd {kadm5_destroy $server_handle}]} { 184 perror "$test: unexpected failure in destroy" 185 return 186 } 187 end_dump_compare "no-diffs" 188} 189test8 190 191test "create-principal 9" 192proc test9 {} { 193 global test 194 begin_dump 195 if {! [cmd { 196 kadm5_init admin admin $KADM5_ADMIN_SERVICE null \ 197 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \ 198 server_handle 199 }]} { 200 perror "$test: unexpected failure in init" 201 return 202 } 203 one_line_fail_test [format { 204 kadm5_create_principal $server_handle [simple_principal "%s/a"] \ 205 {KADM5_MKVNO} "%s/a" 206 } $test $test] "BAD_MASK" 207 if { ! [cmd {kadm5_destroy $server_handle}]} { 208 perror "$test: unexpected failure in destroy" 209 return 210 } 211 end_dump_compare "no-diffs" 212} 213test9 214 215test "create-principal 10" 216proc test10 {} { 217 global test 218 begin_dump 219 if {! [cmd { 220 kadm5_init admin admin $KADM5_ADMIN_SERVICE null \ 221 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \ 222 server_handle 223 }]} { 224 perror "$test: unexpected failure in init" 225 return 226 } 227 one_line_fail_test [format { 228 kadm5_create_principal $server_handle [simple_principal "%s/a"] \ 229 {KADM5_AUX_ATTRIBUTES} "%s/a" 230 } $test $test] "BAD_MASK" 231 if { ! [cmd {kadm5_destroy $server_handle}]} { 232 perror "$test: unexpected failure in destroy" 233 return 234 } 235 end_dump_compare "no-diffs" 236} 237test10 238 239test "create-principal 11" 240proc test11 {} { 241 global test 242 begin_dump 243 if {! [cmd { 244 kadm5_init admin admin $KADM5_ADMIN_SERVICE null \ 245 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \ 246 server_handle 247 }]} { 248 perror "$test: unexpected failure in init" 249 return 250 } 251 one_line_fail_test [format { 252 kadm5_create_principal $server_handle [simple_principal "%s/a"] \ 253 {KADM5_POLICY_CLR} "%s/a" 254 } $test $test] "BAD_MASK" 255 if { ! [cmd {kadm5_destroy $server_handle}]} { 256 perror "$test: unexpected failure in destroy" 257 return 258 } 259 end_dump_compare "no-diffs" 260} 261test11 262 263test "create-principal 12" 264proc test12 {} { 265 global test 266 begin_dump 267 if {! [cmd { 268 kadm5_init admin/none admin $KADM5_ADMIN_SERVICE null \ 269 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \ 270 server_handle 271 }]} { 272 perror "$test: unexpected failure in init" 273 return 274 } 275 one_line_fail_test [format { 276 kadm5_create_principal $server_handle [simple_principal "%s/a"] \ 277 {KADM5_PRINCIPAL} testpass 278 } $test] "AUTH_ADD" 279 if { ! [cmd {kadm5_destroy $server_handle}]} { 280 perror "$test: unexpected failure in destroy" 281 return 282 } 283 end_dump_compare "no-diffs" 284 285} 286if {$RPC} { test12 } 287 288test "create-principal 13" 289proc test13 {} { 290 global test 291 begin_dump 292 if {! (( ! [principal_exists "$test/a"]) || 293 [delete_principal "$test/a"])} { 294 error_and_restart "$test: couldn't delete principal \"$test/a\"" 295 return 296 } 297 if {! [cmd { 298 kadm5_init admin/get admin $KADM5_ADMIN_SERVICE null \ 299 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \ 300 server_handle 301 }]} { 302 perror "$test: unexpected failure in init" 303 return 304 } 305 one_line_fail_test [format { 306 kadm5_create_principal $server_handle [simple_principal "%s/a"] \ 307 {KADM5_PRINCIPAL} testpass 308 } $test] "AUTH_ADD" 309 if { ! [cmd {kadm5_destroy $server_handle}]} { 310 perror "$test: unexpected failure in destroy" 311 return 312 } 313 end_dump_compare "no-diffs" 314} 315if {$RPC} { test13 } 316 317test "create-principal 14" 318proc test14 {} { 319 global test 320 begin_dump 321 if {! ((! [principal_exists "$test/a"]) || 322 [delete_principal "$test/a"])} { 323 error_and_restart "$test: couldn't delete principal \"$test/a\"" 324 return 325 } 326 if {! [cmd { 327 kadm5_init admin/modify admin $KADM5_ADMIN_SERVICE null \ 328 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \ 329 server_handle 330 }]} { 331 perror "$test: unexpected failure in init" 332 return 333 } 334 one_line_fail_test [format { 335 kadm5_create_principal $server_handle [simple_principal "%s/a"] \ 336 {KADM5_PRINCIPAL} testpass 337 } $test] "AUTH_ADD" 338 if { ! [cmd {kadm5_destroy $server_handle}]} { 339 perror "$test: unexpected failure in destroy" 340 return 341 } 342 end_dump_compare "no-diffs" 343} 344if {$RPC} { test14 } 345 346test "create-principal 15" 347proc test15 {} { 348 global test 349 begin_dump 350 if {! ((! [principal_exists "$test/a"]) || 351 [delete_principal "$test/a"])} { 352 error_and_restart "$test: couldn't delete principal \"$test/a\"" 353 return 354 } 355 if {! [cmd { 356 kadm5_init admin/delete admin $KADM5_ADMIN_SERVICE null \ 357 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \ 358 server_handle 359 }]} { 360 perror "$test: unexpected failure in init" 361 return 362 } 363 one_line_fail_test [format { 364 kadm5_create_principal $server_handle [simple_principal "%s/a"] \ 365 {KADM5_PRINCIPAL} testpass 366 } $test] "AUTH_ADD" 367 if { ! [cmd {kadm5_destroy $server_handle}]} { 368 perror "$test: unexpected failure in destroy" 369 return 370 } 371 end_dump_compare "no-diffs" 372} 373if {$RPC} { test15 } 374 375test "create-principal 16" 376proc test16 {} { 377 global test 378 begin_dump 379 if {! [cmd { 380 kadm5_init admin admin $KADM5_CHANGEPW_SERVICE null \ 381 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \ 382 server_handle 383 }]} { 384 perror "$test: unexpected failure in init" 385 return 386 } 387 one_line_fail_test [format { 388 kadm5_create_principal $server_handle [simple_principal "%s/a"] \ 389 {KADM5_PRINCIPAL} testpass 390 } $test] "AUTH_ADD" 391 if { ! [cmd {kadm5_destroy $server_handle}]} { 392 perror "$test: unexpected failure in destroy" 393 return 394 } 395 end_dump_compare "no-diffs" 396} 397if {$RPC} { test16 } 398 399test "create-principal 17" 400proc test17 {} { 401 global test 402 403 begin_dump 404 if {! (( [principal_exists "$test/a"]) || [create_principal "$test/a"])} { 405 error_and_restart "$test: couldn't create principal \"$test/a\"" 406 return 407 } 408 if {! [cmd { 409 kadm5_init admin admin $KADM5_ADMIN_SERVICE null \ 410 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \ 411 server_handle 412 }]} { 413 perror "$test: unexpected failure in init" 414 return 415 } 416 one_line_fail_test [format { 417 kadm5_create_principal $server_handle [simple_principal "%s/a"] \ 418 {KADM5_PRINCIPAL} testpass 419 } $test] "DUP" 420 if { ! [cmd {kadm5_destroy $server_handle}]} { 421 perror "$test: unexpected failure in destroy" 422 return 423 } 424 end_dump_compare "no-diffs" 425} 426test17 427 428test "create-principal 18" 429proc test18 {} { 430 global test 431 432 begin_dump 433 if {! ((! [principal_exists "$test/a"]) || 434 [delete_principal "$test/a"])} { 435 error_and_restart "$test: couldn't delete principal \"$test/a\"" 436 return 437 } 438 if {! [cmd { 439 kadm5_init admin/add admin $KADM5_ADMIN_SERVICE null \ 440 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \ 441 server_handle 442 }]} { 443 perror "$test: unexpected failure in init" 444 return 445 } 446 one_line_fail_test [format { 447 kadm5_create_principal $server_handle \ 448 [princ_w_pol "%s/a" test-pol] \ 449 {KADM5_PRINCIPAL KADM5_POLICY} tP 450 } $test] "_Q_TOOSHORT" 451 if { ! [cmd {kadm5_destroy $server_handle}]} { 452 perror "$test: unexpected failure in destroy" 453 return 454 } 455 end_dump_compare "no-diffs" 456} 457test18 458 459test "create-principal 19" 460proc test19 {} { 461 global test 462 463 begin_dump 464 if {! ((! [principal_exists "$test/a"]) || 465 [delete_principal "$test/a"])} { 466 error_and_restart "$test: couldn't delete principal \"$test/a\"" 467 return 468 } 469 if {! [cmd { 470 kadm5_init admin admin $KADM5_ADMIN_SERVICE null \ 471 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \ 472 server_handle 473 }]} { 474 perror "$test: unexpected failure in init" 475 return 476 } 477 one_line_fail_test [format { 478 kadm5_create_principal $server_handle \ 479 [princ_w_pol "%s/a" test-pol] \ 480 {KADM5_PRINCIPAL KADM5_POLICY} testpassword 481 } $test] "_Q_CLASS" 482 if { ! [cmd {kadm5_destroy $server_handle}]} { 483 perror "$test: unexpected failure in destroy" 484 return 485 } 486 end_dump_compare "no-diffs" 487} 488test19 489 490test "create-principal 20" 491proc test20 {} { 492 global test 493 494 begin_dump 495 if {! ((! [principal_exists "$test/a"]) || 496 [delete_principal "$test/a"])} { 497 error_and_restart "$test: couldn't delete principal \"$test/a\"" 498 return 499 } 500 if {! [cmd { 501 kadm5_init admin admin $KADM5_ADMIN_SERVICE null \ 502 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \ 503 server_handle 504 }]} { 505 perror "$test: unexpected failure in init" 506 return 507 } 508 one_line_fail_test [format { 509 kadm5_create_principal $server_handle \ 510 [princ_w_pol "%s/a" test-pol] \ 511 {KADM5_PRINCIPAL KADM5_POLICY} Abyssinia 512 } $test] "_Q_DICT" 513 if { ! [cmd {kadm5_destroy $server_handle}]} { 514 perror "$test: unexpected failure in destroy" 515 return 516 } 517 end_dump_compare "no-diffs" 518} 519test20 520 521test "create-principal 21" 522proc test21 {} { 523 global test 524 525 begin_dump 526 if {! ((! [principal_exists "$test/a"]) || 527 [delete_principal "$test/a"])} { 528 error_and_restart "$test: couldn't delete principal \"$test/a\"" 529 return 530 } 531 if {! [cmd { 532 kadm5_init admin admin $KADM5_ADMIN_SERVICE null \ 533 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \ 534 server_handle 535 }]} { 536 perror "$test: unexpected failure in init" 537 return 538 } 539 one_line_succeed_test [format { 540 kadm5_create_principal $server_handle \ 541 [princ_w_pol "%s/a" non-existant-pol] \ 542 {KADM5_PRINCIPAL KADM5_POLICY} NotinTheDictionary 543 } $test] 544 if { ! [cmd {kadm5_destroy $server_handle}]} { 545 perror "$test: unexpected failure in destroy" 546 return 547 } 548 end_dump_compare "no-diffs" 549} 550test21 551 552test "create-principal 23" 553proc test23 {} { 554 global test 555 556 if {! ((! [principal_exists "$test/a"]) || 557 [delete_principal "$test/a"])} { 558 error_and_restart "$test: couldn't delete principal \"$test/a\"" 559 return 560 } 561 if {! [cmd { 562 kadm5_init admin admin $KADM5_ADMIN_SERVICE null \ 563 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \ 564 server_handle 565 }]} { 566 perror "$test: unexpected failure in init" 567 return 568 } 569 if {! [cmd [format { 570 kadm5_create_principal $server_handle [simple_principal "%s/a"] \ 571 {KADM5_PRINCIPAL} NotinTheDictionary 572 } $test]]} { 573 fail "$test: can not create principal" 574 return; 575 } 576 one_line_succeed_test \ 577 [format {kadm5_get_principal $server_handle "%s/a" p KADM5_PRINCIPAL_NORMAL_MASK} $test] 578 if { ! [cmd {kadm5_destroy $server_handle}]} { 579 perror "$test: unexpected failure in destroy" 580 return 581 } 582} 583test23 584 585test "create-principal 24" 586proc test24 {} { 587 global test 588 if {! ((! [principal_exists "$test/a"]) || 589 [delete_principal "$test/a"])} { 590 error_and_restart "$test: couldn't delete principal \"$test/a\"" 591 return 592 } 593 if {! [cmd { 594 kadm5_init admin/rename admin $KADM5_ADMIN_SERVICE null \ 595 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \ 596 server_handle 597 }]} { 598 perror "$test: unexpected failure in init" 599 return 600 } 601 if {! [cmd [format { 602 kadm5_create_principal $server_handle [simple_principal "%s/a"] \ 603 {KADM5_PRINCIPAL} NotinTheDictionary 604 } $test]]} { 605 fail "$test: can not create principal" 606 return; 607 } 608 one_line_succeed_test \ 609 [format {kadm5_get_principal $server_handle "%s/a" p KADM5_PRINCIPAL_NORMAL_MASK} $test] 610 if { ! [cmd {kadm5_destroy $server_handle}]} { 611 perror "$test: unexpected failure in destroy" 612 return 613 } 614} 615if {$RPC} { test24 } 616 617 618test "create-principal 28" 619proc test28 {} { 620 global test 621 global prompt 622 623 if {! ((! [principal_exists "$test/a"]) || 624 [delete_principal "$test/a"])} { 625 error_and_restart "$test: couldn't delete principal \"$test/a\"" 626 return 627 } 628 if {! [cmd { 629 kadm5_init admin admin $KADM5_ADMIN_SERVICE null \ 630 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \ 631 server_handle 632 }]} { 633 perror "$test: unexpected failure in init" 634 return 635 } 636 637 if {! [cmd [format { 638 kadm5_create_principal $server_handle \ 639 [princ_w_pol "%s/a" test-pol] \ 640 {KADM5_PRINCIPAL KADM5_POLICY} NotinTheDictionary 641 } $test]]} { 642 fail "$test: can not create principal" 643 return; 644 } 645 if {! [cmd [format { 646 kadm5_get_principal $server_handle "%s/a" principal KADM5_PRINCIPAL_NORMAL_MASK 647 } $test]]} { 648 fail "$test: can not retreive principal" 649 return 650 } 651 send "lindex \$principal 10\n" 652 expect { 653 -re "test-pol.*$prompt$" { pass "$test" } 654 timeout { fail "$test" } 655 } 656 if { ! [cmd {kadm5_destroy $server_handle}]} { 657 perror "$test: unexpected failure in destroy" 658 return 659 } 660} 661test28 662 663test "create-principal 29" 664proc test29 {} { 665 global test 666 global prompt 667 668 if {! ((! [principal_exists "$test/a"]) || 669 [delete_principal "$test/a"])} { 670 error_and_restart "$test: couldn't delete principal \"$test/a\"" 671 return 672 } 673 if {! [cmd { 674 kadm5_init admin admin $KADM5_ADMIN_SERVICE null \ 675 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \ 676 server_handle 677 }]} { 678 perror "$test: unexpected failure in init" 679 return 680 } 681 if {! [cmd [format { 682 kadm5_create_principal $server_handle [simple_principal "%s/a"] \ 683 {KADM5_PRINCIPAL KADM5_PRINC_EXPIRE_TIME} \ 684 inTheDictionary 685 } $test]]} { 686 fail "$test: can not create principal" 687 return; 688 } 689 if {! [cmd [format { 690 kadm5_get_principal $server_handle "%s/a" principal KADM5_PRINCIPAL_NORMAL_MASK 691 } $test]]} { 692 fail "$test: can not retreive principal" 693 return; 694 } 695 send "lindex \$principal 1\n" 696 expect { 697 -re "0.*$prompt$" { pass "$test" } 698 timeout { fail "$test" } 699 } 700 if { ! [cmd {kadm5_destroy $server_handle}]} { 701 perror "$test: unexpected failure in destroy" 702 return 703 } 704} 705test29 706 707test "create-principal 30" 708proc test30 {} { 709 global test 710 global prompt 711 712 if {! ((! [principal_exists "$test/a"]) || 713 [delete_principal "$test/a"])} { 714 error_and_restart "$test: couldn't delete principal \"$test/a\"" 715 return 716 } 717 if {! [cmd { 718 kadm5_init admin admin $KADM5_ADMIN_SERVICE null \ 719 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \ 720 server_handle 721 }]} { 722 perror "$test: unexpected failure in init" 723 return 724 } 725 if {! [cmd [format { 726 kadm5_create_principal $server_handle [simple_principal "%s/a"] \ 727 {KADM5_PRINCIPAL KADM5_PW_EXPIRATION} \ 728 NotinTheDictionary 729 } $test]]} { 730 fail "$test: can not create principal" 731 return; 732 } 733 if {! [cmd [format { 734 kadm5_get_principal $server_handle "%s/a" principal KADM5_PRINCIPAL_NORMAL_MASK 735 } $test]]} { 736 fail "$test: can not retreive principal" 737 return; 738 } 739 send "lindex \$principal 3\n" 740 expect { 741 -re "0.*$prompt$" { pass "$test" } 742 timeout { fail "$test" } 743 } 744 if { ! [cmd {kadm5_destroy $server_handle}]} { 745 perror "$test: unexpected failure in destroy" 746 return 747 } 748} 749test30 750 751test "create-principal 31" 752proc test31 {} { 753 global test 754 global prompt 755 756 if {! ((! [principal_exists "$test/a"]) || 757 [delete_principal "$test/a"])} { 758 error_and_restart "$test: couldn't delete principal \"$test/a\"" 759 return 760 } 761 if {! [cmd { 762 kadm5_init admin admin $KADM5_ADMIN_SERVICE null \ 763 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \ 764 server_handle 765 }]} { 766 perror "$test: unexpected failure in init" 767 return 768 } 769 if {! [cmd [format { 770 kadm5_create_principal $server_handle \ 771 [princ_w_pol "%s/a" test-pol-nopw] \ 772 {KADM5_PRINCIPAL KADM5_POLICY \ 773 KADM5_PW_EXPIRATION} NotinTheDictionary 774 } $test]]} { 775 fail "$test: can not create principal" 776 return; 777 } 778 if {! [cmd [format { 779 kadm5_get_principal $server_handle "%s/a" principal KADM5_PRINCIPAL_NORMAL_MASK 780 } $test]]} { 781 fail "$test: can not retreive principal" 782 return; 783 } 784 send "lindex \$principal 3\n" 785 expect { 786 -re "0.*$prompt$" { pass "$test" } 787 timeout { fail "$test" } 788 } 789 if { ! [cmd {kadm5_destroy $server_handle}]} { 790 perror "$test: unexpected failure in destroy" 791 return 792 } 793} 794test31 795 796test "create-principal 32" 797proc test32 {} { 798 global test 799 global prompt 800 801 if {! ((! [principal_exists "$test/a"]) || 802 [delete_principal "$test/a"])} { 803 error_and_restart "$test: couldn't delete principal \"$test/a\"" 804 return 805 } 806 if {! [cmd { 807 kadm5_init admin admin $KADM5_ADMIN_SERVICE null \ 808 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \ 809 server_handle 810 }]} { 811 perror "$test: unexpected failure in init" 812 return 813 } 814 if {! [cmd [format { 815 kadm5_create_principal $server_handle \ 816 [princ_w_pol "%s/a" test-pol] \ 817 {KADM5_PRINCIPAL KADM5_POLICY \ 818 KADM5_PW_EXPIRATION} NotinTheDictionary 819 } $test]]} { 820 fail "$test: can not create principal" 821 return; 822 } 823 if {! [cmd [format { 824 kadm5_get_principal $server_handle "%s/a" principal KADM5_PRINCIPAL_NORMAL_MASK 825 } $test]]} { 826 fail "$test: can not retreive principal" 827 return; 828 } 829 if { ! [cmd {kadm5_get_policy $server_handle test-pol policy}]} { 830 error_and_restart "$test: cannot retrieve policy" 831 return 832 } 833 834 send "lindex \$principal 6\n" 835 expect { 836 -re "(\[0-9\]+)\n$prompt" {set mod_date $expect_out(1,string) } 837 timeout { 838 error_and_restart "$test: timeout getting mod_date" 839 return 840 } 841 eof { 842 error_and_restart "$test: eof getting mod_date" 843 return 844 } 845 } 846 847 send "lindex \$principal 3\n" 848 expect { 849 -re "(\[0-9\]+)\n$prompt" {set pw_expire $expect_out(1,string) } 850 timeout { 851 error_and_restart "$test: timeout getting pw_expire" 852 return 853 } 854 eof { 855 error_and_restart "$test: eof getting pw_expire" 856 return 857 } 858 } 859 860 send "lindex \$policy 2\n" 861 expect { 862 -re "(\[0-9\]+)\n$prompt" {set pw_max_life $expect_out(1,string) } 863 timeout { 864 error_and_restart "$test: timeout getting pw_max_life" 865 return 866 } 867 eof { 868 error_and_restart "$test: eof getting pw_max_life" 869 return 870 } 871 } 872 if { $pw_expire != 0 } { 873 fail "$test: pw_expire $pw_expire should be 0" 874 return 875 } else { 876 pass "$test" 877 } 878 if { ! [cmd {kadm5_destroy $server_handle}]} { 879 perror "$test: unexpected failure in destroy" 880 return 881 } 882} 883test32 884 885test "create-principal 33" 886proc test33 {} { 887 global test 888 global prompt 889 890 if {! ((! [principal_exists "$test/a"]) || 891 [delete_principal "$test/a"])} { 892 error_and_restart "$test: couldn't delete principal \"$test/a\"" 893 return 894 } 895 if {! [cmd { 896 kadm5_init admin admin $KADM5_ADMIN_SERVICE null \ 897 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \ 898 server_handle 899 }]} { 900 perror "$test: unexpected failure in init" 901 return 902 } 903 if {! [cmd [format { 904 kadm5_create_principal $server_handle \ 905 {"%s/a" 0 0 1234 0 null 0 0 0 0 null 0} \ 906 {KADM5_PRINCIPAL KADM5_PW_EXPIRATION} \ 907 NotinTheDictionary 908 } $test]]} { 909 fail "$test: can not create principal" 910 return; 911 } 912 if {! [cmd [format { 913 kadm5_get_principal $server_handle "%s/a" principal KADM5_PRINCIPAL_NORMAL_MASK 914 } $test]]} { 915 fail "$test: can not retreive principal" 916 return; 917 } 918 send "lindex \$principal 3\n" 919 expect { 920 -re "1234.*$prompt$" { pass "$test" } 921 timeout { fail "$test" } 922 } 923 if { ! [cmd {kadm5_destroy $server_handle}]} { 924 perror "$test: unexpected failure in destroy" 925 return 926 } 927} 928test33 929 930test "create-principal 34" 931proc test34 {} { 932 global test 933 global prompt 934 935 if {! ((! [principal_exists "$test/a"]) || 936 [delete_principal "$test/a"])} { 937 error_and_restart "$test: couldn't delete principal \"$test/a\"" 938 return 939 } 940 if {! [cmd { 941 kadm5_init admin admin $KADM5_ADMIN_SERVICE null \ 942 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \ 943 server_handle 944 }]} { 945 perror "$test: unexpected failure in init" 946 return 947 } 948 if {! [cmd [format { 949 kadm5_create_principal $server_handle \ 950 { "%s/a" 0 0 1234 0 null 0 0 0 0 test-pol-nopw 0} \ 951 {KADM5_PRINCIPAL KADM5_POLICY \ 952 KADM5_PW_EXPIRATION} NotinTheDictionary 953 } $test]]} { 954 fail "$test: can not create principal" 955 return; 956 } 957 if {! [cmd [format { 958 kadm5_get_principal $server_handle "%s/a" principal KADM5_PRINCIPAL_NORMAL_MASK 959 } $test]]} { 960 fail "$test: can not retreive principal" 961 return; 962 } 963 send "lindex \$principal 3\n" 964 expect { 965 -re "1234.*$prompt$" { pass "$test" } 966 timeout { fail "$test" } 967 } 968 if { ! [cmd {kadm5_destroy $server_handle}]} { 969 perror "$test: unexpected failure in destroy" 970 return 971 } 972} 973test34 974 975test "create-principal 35" 976proc test35 {} { 977 global test 978 global prompt 979 980 if {! ((! [principal_exists "$test/a"]) || 981 [delete_principal "$test/a"])} { 982 error_and_restart "$test: couldn't delete principal \"$test/a\"" 983 return 984 } 985 if {! [cmd { 986 kadm5_init admin admin $KADM5_ADMIN_SERVICE null \ 987 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \ 988 server_handle 989 }]} { 990 perror "$test: unexpected failure in init" 991 return 992 } 993 if {! [cmd [format { 994 kadm5_create_principal $server_handle \ 995 {"%s/a" 0 0 1234 0 null 0 0 0 0 test-pol 0} \ 996 {KADM5_PRINCIPAL KADM5_POLICY \ 997 KADM5_PW_EXPIRATION} NotinTheDictionary 998 } $test]]} { 999 fail "$test: can not create principal" 1000 return; 1001 } 1002 if {! [cmd [format { 1003 kadm5_get_principal $server_handle "%s/a" principal KADM5_PRINCIPAL_NORMAL_MASK 1004 } $test]]} { 1005 fail "$test: can not retreive principal" 1006 return; 1007 } 1008 send "lindex \$principal 3\n" 1009 expect { 1010 -re "1234.*$prompt$" { pass "$test" } 1011 timeout { fail "$test" } 1012 } 1013 if { ! [cmd {kadm5_destroy $server_handle}]} { 1014 perror "$test: unexpected failure in destroy" 1015 return 1016 } 1017} 1018test35 1019 1020test "create-principal 36" 1021proc test36 {} { 1022 global test 1023 global prompt 1024 1025 if {! ((! [principal_exists "$test/a"]) || 1026 [delete_principal "$test/a"])} { 1027 error_and_restart "$test: couldn't delete principal \"$test/a\"" 1028 return 1029 } 1030 if {! [cmd { 1031 kadm5_init admin admin $KADM5_ADMIN_SERVICE null \ 1032 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \ 1033 server_handle 1034 }]} { 1035 perror "$test: unexpected failure in init" 1036 return 1037 } 1038 if {! [cmd [format { 1039 kadm5_create_principal $server_handle \ 1040 {"%s/a" 0 0 999999999 0 null 0 0 0 0 test-pol 0} \ 1041 {KADM5_PRINCIPAL KADM5_POLICY \ 1042 KADM5_PW_EXPIRATION} NotinTheDictionary 1043 } $test]]} { 1044 fail "$test: can not create principal" 1045 return; 1046 } 1047 if {! [cmd [format { 1048 kadm5_get_principal $server_handle "%s/a" principal KADM5_PRINCIPAL_NORMAL_MASK 1049 } $test]]} { 1050 fail "$test: can not retreive principal" 1051 return; 1052 } 1053 if { ! [cmd {kadm5_get_policy $server_handle test-pol policy} ]} { 1054 error_and_restart "$test: cannot retrieve policy" 1055 return 1056 } 1057 1058 send "lindex \$principal 6\n" 1059 expect { 1060 -re "(\[0-9\]+)\n$prompt" {set mod_date $expect_out(1,string) } 1061 timeout { 1062 error_and_restart "$test: timeout getting mod_date" 1063 return 1064 } 1065 eof { 1066 error_and_restart "$test: eof getting mod_date" 1067 return 1068 } 1069 } 1070 1071 send "lindex \$principal 3\n" 1072 expect { 1073 -re "(\[0-9\]+)\n$prompt" {set pw_expire $expect_out(1,string) } 1074 timeout { 1075 error_and_restart "$test: timeout getting pw_expire" 1076 return 1077 } 1078 eof { 1079 error_and_restart "$test: eof getting pw_expire" 1080 return 1081 } 1082 } 1083 1084 send "lindex \$policy 2\n" 1085 expect { 1086 -re "(\[0-9\]+)\n$prompt" {set pw_max_life $expect_out(1,string) } 1087 timeout { 1088 error_and_restart "$test: timeout getting pw_max_life" 1089 return 1090 } 1091 eof { 1092 error_and_restart "$test: eof getting pw_max_life" 1093 return 1094 } 1095 } 1096 if { $pw_expire != 999999999 } { 1097 fail "$test: pw_expire is wrong" 1098 return 1099 } else { 1100 pass "$test" 1101 } 1102 1103 if { ! [cmd {kadm5_destroy $server_handle}]} { 1104 perror "$test: unexpected failure in destroy" 1105 return 1106 } 1107} 1108test36 1109 1110test "create-principal 37" 1111proc test37 {} { 1112 global test 1113 global prompt 1114 1115 if {! ((! [principal_exists "$test/a"]) || 1116 [delete_principal "$test/a"])} { 1117 error_and_restart "$test: couldn't delete principal \"$test/a\"" 1118 return 1119 } 1120 if {! [cmd { 1121 kadm5_init admin admin $KADM5_ADMIN_SERVICE null \ 1122 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \ 1123 server_handle 1124 }]} { 1125 perror "$test: unexpected failure in init" 1126 return 1127 } 1128 if {! [cmd [format { 1129 kadm5_create_principal $server_handle [simple_principal "%s/a"] \ 1130 {KADM5_PRINCIPAL} NotinTheDictionary 1131 } $test]]} { 1132 fail "$test: can not create principal" 1133 return; 1134 } 1135 if {! [cmd [format { 1136 kadm5_get_principal $server_handle "%s/a" principal KADM5_PRINCIPAL_NORMAL_MASK 1137 } $test]]} { 1138 fail "$test: can not retreive principal" 1139 return; 1140 } 1141 send "lindex \$principal 3\n" 1142 expect { 1143 -re "0.*$prompt$" { pass "$test" } 1144 timeout { fail "$test" } 1145 } 1146 if { ! [cmd {kadm5_destroy $server_handle}]} { 1147 perror "$test: unexpected failure in destroy" 1148 return 1149 } 1150} 1151test37 1152 1153test "create-principal 38" 1154proc test38 {} { 1155 global test 1156 global prompt 1157 1158 if {! ((! [principal_exists "$test/a"]) || 1159 [delete_principal "$test/a"])} { 1160 error_and_restart "$test: couldn't delete principal \"$test/a\"" 1161 return 1162 } 1163 if {! [cmd { 1164 kadm5_init admin admin $KADM5_ADMIN_SERVICE null \ 1165 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \ 1166 server_handle 1167 }]} { 1168 perror "$test: unexpected failure in init" 1169 return 1170 } 1171 if {! [cmd [format { 1172 kadm5_create_principal $server_handle [princ_w_pol "%s/a" \ 1173 test-pol-nopw] {KADM5_PRINCIPAL KADM5_POLICY} \ 1174 NotinTheDictionary 1175 } $test]]} { 1176 fail "$test: can not create principal" 1177 return; 1178 } 1179 if {! [cmd [format { 1180 kadm5_get_principal $server_handle "%s/a" principal KADM5_PRINCIPAL_NORMAL_MASK 1181 } $test]]} { 1182 fail "$test: can not retreive principal" 1183 return; 1184 } 1185 send "lindex \$principal 3\n" 1186 expect { 1187 -re "0.*$prompt$" { pass "$test" } 1188 timeout { fail "$test" } 1189 } 1190 if { ! [cmd {kadm5_destroy $server_handle}]} { 1191 perror "$test: unexpected failure in destroy" 1192 return 1193 } 1194} 1195test38 1196 1197test "create-principal 39" 1198proc test39 {} { 1199 global test 1200 global prompt 1201 1202 if {! ((! [principal_exists "$test/a"]) || 1203 [delete_principal "$test/a"])} { 1204 error_and_restart "$test: couldn't delete principal \"$test/a\"" 1205 return 1206 } 1207 if {! [cmd { 1208 kadm5_init admin admin $KADM5_ADMIN_SERVICE null \ 1209 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \ 1210 server_handle 1211 }]} { 1212 perror "$test: unexpected failure in init" 1213 return 1214 } 1215 if {! [cmd [format { 1216 kadm5_create_principal $server_handle [princ_w_pol "%s/a" \ 1217 test-pol] {KADM5_PRINCIPAL KADM5_POLICY} \ 1218 NotinTheDictionary 1219 } $test]]} { 1220 fail "$test: can not create principal" 1221 return; 1222 } 1223 if { ! [cmd [format { 1224 kadm5_get_principal $server_handle "%s/a" principal KADM5_PRINCIPAL_NORMAL_MASK 1225 } $test]]} { 1226 error_and_restart "$test: cannot not retrieve principal" 1227 return 1228 } 1229 if { ! [cmd {kadm5_get_policy $server_handle test-pol policy}]} { 1230 error_and_restart "$test: cannot retrieve policy" 1231 return 1232 } 1233 send "lindex \$principal 6\n" 1234 expect { 1235 -re "(\[0-9\]+)\n$prompt" {set mod_date $expect_out(1,string) } 1236 timeout { 1237 error_and_restart "$test: timeout getting mod_date" 1238 return 1239 } 1240 eof { 1241 error_and_restart "$test: eof getting mod_date" 1242 return 1243 } 1244 } 1245 1246 send "lindex \$principal 3\n" 1247 expect { 1248 -re "(\[0-9\]+)\n$prompt" {set pw_expire $expect_out(1,string) } 1249 timeout { 1250 error_and_restart "$test: timeout getting pw_expire" 1251 return 1252 } 1253 eof { 1254 error_and_restart "$test: eof getting pw_expire" 1255 return 1256 } 1257 } 1258 1259 send "lindex \$policy 2\n" 1260 expect { 1261 -re "(\[0-9\]+)\n$prompt" {set pw_max_life $expect_out(1,string) } 1262 timeout { 1263 error_and_restart "$test: timeout getting pw_max_life" 1264 return 1265 } 1266 eof { 1267 error_and_restart "$test: eof getting pw_max_life" 1268 return 1269 } 1270 } 1271 if { [expr "$mod_date + $pw_max_life - $pw_expire"] > 5 } { 1272 fail "$test: pw_expire is wrong" 1273 return 1274 } 1275 if { ! [cmd {kadm5_destroy $server_handle}]} { 1276 perror "$test: unexpected failure in destroy" 1277 return 1278 } 1279} 1280test39 1281 1282test "create-principal 40" 1283proc test40 {} { 1284 global test 1285 global prompt 1286 1287 if {! ((! [principal_exists "$test/a"]) || 1288 [delete_principal "$test/a"])} { 1289 error_and_restart "$test: couldn't delete principal \"$test/a\"" 1290 return 1291 } 1292 if {! [cmd { 1293 kadm5_init admin admin $KADM5_ADMIN_SERVICE null \ 1294 $KADM5_STRUCT_VERSION $KADM5_API_VERSION_3 \ 1295 server_handle 1296 }]} { 1297 perror "$test: unexpected failure in init" 1298 return 1299 } 1300 if {! [cmd [format { 1301 kadm5_create_principal $server_handle [simple_principal "%s/a"] \ 1302 {KADM5_PRINCIPAL KADM5_PW_EXPIRATION} \ 1303 NotinTheDictionary 1304 } $test]]} { 1305 fail "$test: can not create principal" 1306 return; 1307 } 1308 if {! [cmd [format { 1309 kadm5_get_principal $server_handle "%s/a" principal KADM5_PRINCIPAL_NORMAL_MASK 1310 } $test]]} { 1311 fail "$test: can not retreive principal" 1312 return; 1313 } 1314 send "lindex \$principal 4\n" 1315 expect { 1316 -re "0.*$prompt$" { pass "$test" } 1317 timeout { fail "$test" } 1318 } 1319 if { ! [cmd {kadm5_destroy $server_handle}]} { 1320 perror "$test: unexpected failure in destroy" 1321 return 1322 } 1323} 1324test40 1325 1326test "create-principal 43" 1327proc test43 {} { 1328 global test 1329 one_line_fail_test [format { 1330 kadm5_create_principal null \ 1331 [simple_principal "%s/a"] {KADM5_PRINCIPAL} "%s/a" 1332 } $test $test] "BAD_SERVER_HANDLE" 1333} 1334test43 1335 1336return "" 1337