--- /dev/null
+load_lib lib.t
+api_exit
+api_start
+
+test "modify-principal 100-104"
+proc test100_104 {} {
+ global test
+ global prompt
+
+ if {! (( [principal_exists "$test/a"]) ||
+ [create_principal "$test/a"])} {
+ error_and_restart "$test: couldn't create principal \"$test/a\""
+ return
+ }
+
+ if {! [cmd {
+ kadm5_init admin admin $KADM5_CHANGEPW_SERVICE null \
+ $KADM5_STRUCT_VERSION $KADM5_API_VERSION_2 \
+ server_handle
+ }]} {
+ error "$test: unexpected failure in init"
+ return
+ }
+
+ # test 100
+ one_line_succeed_test [format {
+ kadm5_modify_principal $server_handle [simple_principal "%s/a"] \
+ {KADM5_MAX_RLIFE}
+ } $test]
+
+ # test 101
+ one_line_fail_test {
+ kadm5_modify_principal $server_handle null \
+ {KADM5_LAST_SUCCESS}
+ } "BAD_MASK"
+ # test 102
+ one_line_fail_test {
+ kadm5_modify_principal $server_handle null \
+ {KADM5_LAST_FAILED}
+ } "BAD_MASK"
+ # test 103
+ one_line_fail_test {
+ kadm5_modify_principal $server_handle null \
+ {KADM5_FAIL_AUTH_COUNT}
+ } "BAD_MASK"
+ # test 103.5
+ one_line_fail_test {
+ kadm5_modify_principal $server_handle null \
+ {KADM5_KEY_DATA}
+ } "BAD_MASK"
+
+ # test 100,104
+ if { ! [cmd [format {
+ kadm5_modify_principal $server_handle \
+ "{%s/a} 0 0 0 0 {%s/a} 0 0 0 0 null 0 88 0 0 0 0 1 {} {{999 6 foobar}}" \
+ {KADM5_MAX_RLIFE KADM5_TL_DATA}
+ } $test $test]]} {
+ fail "$test: cannot set MAX_RLIFE or TL_DATA"
+ return
+ }
+ if {! [cmd [format {
+ kadm5_get_principal $server_handle "%s/a" principal {KADM5_PRINCIPAL_NORMAL_MASK KADM5_TL_DATA}
+ } $test]]} {
+ error_and_restart "$test: could not retrieve principal"
+ return
+ }
+ send "lindex \$principal 12\n"
+ expect {
+ -re "(\[0-9\]+)\n$prompt$" {set rlife $expect_out(1,string) }
+ timeout {
+ error_and_restart "$test: timeout getting rlife"
+ return
+ }
+ eof {
+ error_and_restart "$test: eof getting rlife"
+ return
+ }
+ }
+ send "lindex \$principal 19\n"
+ expect {
+ -re "\(\{.*\}\)\n$prompt$" {set tl $expect_out(1,string) }
+ timeout {
+ error_and_restart "$test: timeout getting tl_data"
+ return
+ }
+ eof {
+ error_and_restart "$test: eof getting tl_data"
+ return
+ }
+ }
+ if {($rlife == 88) && ([string match "*{999 6 foobar}*" $tl])} {
+ pass "$test"
+ } else {
+ fail "$test: $rlife should be 88, $tl should contain {999 6 foobar}"
+ }
+
+ if { ! [cmd {kadm5_destroy $server_handle}]} {
+ error "$test: unexpected failure in destroy"
+ return
+ }
+}
+test100_104